Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Alert" + "Toast" components - Finalize implementation in code (feature branch) #245

Merged
merged 165 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from 160 commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
b96cb0d
Set up Alert base branch
amyrlam Mar 18, 2022
e75a7b5
Add scratch reference and API sections
amyrlam Mar 18, 2022
2580c01
Add base component: icon, title, body only
amyrlam Mar 18, 2022
e98da6d
Fix prop name in comment
amyrlam Mar 18, 2022
2a1e405
Delete second Alert in scrappy docs
amyrlam Mar 18, 2022
fd1005c
Rename `body` to `description`
amyrlam Mar 19, 2022
80e2757
Move classNames to bottom of file per repo pattern
amyrlam Mar 19, 2022
1c942c4
Add TODO for later
amyrlam Mar 19, 2022
d8c7985
Temp skip tests and fix prettier
amyrlam Mar 19, 2022
b9eff6b
Remove mention of icon size of 24
amyrlam Mar 19, 2022
72830c8
Remove <p> from alert
amyrlam Mar 19, 2022
d8b3a9a
Add title or description required logic
amyrlam Mar 19, 2022
6381994
Change to this to be consistent
amyrlam Mar 19, 2022
1320e24
simplified β€œalert” base implementation
didoo Mar 21, 2022
a6a2e42
Lint tests and remove /tests from .prettierignore
amyrlam Mar 21, 2022
23db6a8
Tweak description to allow rich content
amyrlam Mar 21, 2022
2f1cfaa
Fix semantic HTML
amyrlam Mar 22, 2022
5e3bcb3
Bring in <a> styling
amyrlam Mar 22, 2022
7ed9b00
Manually alphabetize the properties
amyrlam Mar 22, 2022
51b8d18
Set up Alert base branch
amyrlam Mar 18, 2022
ef2f9c4
Add scratch reference and API sections
amyrlam Mar 18, 2022
ff0bf32
Add base component: icon, title, body only
amyrlam Mar 18, 2022
912828b
Fix prop name in comment
amyrlam Mar 18, 2022
2741e9d
Delete second Alert in scrappy docs
amyrlam Mar 18, 2022
74001ec
Rename `body` to `description`
amyrlam Mar 19, 2022
f2e2f9e
Move classNames to bottom of file per repo pattern
amyrlam Mar 19, 2022
51761c7
Add TODO for later
amyrlam Mar 19, 2022
38fbd00
Temp skip tests and fix prettier
amyrlam Mar 19, 2022
c8bd4ef
Merge branch 'amy/alert-overall-branch' into amy/base-tweaks
amyrlam Mar 22, 2022
b0e21dd
fixed styling for the β€œdescription” text in β€œAlert”
didoo Mar 22, 2022
6f056df
Merge pull request #99 from hashicorp/amy/base-tweaks
amyrlam Mar 22, 2022
fd7c25c
Merge branch 'main' into amy/alert-overall-branch
amyrlam Mar 24, 2022
99d4bc0
Change alert name types per latest from CRD
amyrlam Mar 24, 2022
3587aca
Implement color manually
amyrlam Mar 25, 2022
dc93906
Add icon implementation with manual showcase
amyrlam Mar 26, 2022
1e8fc6e
Made showcase and API description tweaks for clarity
amyrlam Mar 26, 2022
8146dde
Make styling tweaks from Figma
amyrlam Mar 26, 2022
fd9f1e0
Add a11y section and make docs tweaks
amyrlam Mar 26, 2022
16d5f69
DRY description styling
amyrlam Mar 26, 2022
9f7490b
More alert tweaks
amyrlam Mar 26, 2022
b0eaeef
Fix lint
amyrlam Mar 26, 2022
dd964a8
Tweak Percy
amyrlam Mar 26, 2022
2280ec0
Address PR feedback, with addl edits
amyrlam Mar 29, 2022
6bd33a8
added the β€œactions” for the β€œAlert” component as named block with yi…
didoo Mar 28, 2022
e21735f
fixed wrong nesting
didoo Mar 28, 2022
92f8ea7
fixed regex used in the β€œDummyPlaceholder”
didoo Mar 28, 2022
156bf05
added showcase for β€œactions” in β€œAlert” component
didoo Mar 28, 2022
6f1e2cc
added TODO in component API for the β€œactions”
didoo Mar 28, 2022
5a35035
Merge pull request #130 from hashicorp/alert-actions-as-named-block
amyrlam Mar 29, 2022
7e0fa17
Make docs tweaks pre-type extraction
amyrlam Mar 29, 2022
de912c6
Add page styling
amyrlam Mar 29, 2022
7dc4120
Improve readability of .hbs
amyrlam Mar 29, 2022
5765ef1
Fix lint
amyrlam Mar 29, 2022
11a056b
Tweak docs
amyrlam Mar 29, 2022
ecf9886
Add Alert (Inline)
amyrlam Mar 29, 2022
c954945
Update Actions Showcases to use default icon
amyrlam Mar 29, 2022
2d400a2
More docs tweaks
amyrlam Mar 29, 2022
c69d33f
More docs tweaks
amyrlam Mar 29, 2022
4733f44
added β€œdismiss” button to the β€œAlert” component
didoo Mar 29, 2022
676bf6c
reverted changes committed by error
didoo Mar 29, 2022
41bc9f1
added very simple showcase for β€œdismiss” for testing
didoo Mar 29, 2022
1ebac3c
improved β€œonDismiss” hook
didoo Mar 29, 2022
a8117b3
Update packages/components/app/styles/components/alert.scss
amyrlam Mar 29, 2022
0350cb1
Address PR feedback / questions
amyrlam Mar 29, 2022
86a28ab
Merge branch 'amy/alert-page' of github.com:hashicorp/design-system i…
amyrlam Mar 29, 2022
ecf3890
Update color order to match Figma
amyrlam Mar 29, 2022
e01372d
Improve no icon logic with test
amyrlam Mar 30, 2022
86e792f
Start Alert (Compact)
amyrlam Mar 30, 2022
920f7e3
Merge pull request #124 from hashicorp/amy/alert-page
didoo Mar 30, 2022
eb829da
Merge branch 'amy/alert-overall-branch' into alert-dismiss
didoo Mar 30, 2022
2dad5c7
added new section for the showcase of the β€œAlert” component
didoo Mar 30, 2022
6812b89
updated the β€œdismiss” button in the β€œAlert” component according to th…
didoo Mar 30, 2022
5679ae7
added styling for the β€œToast” variant of the β€œAlert” component
didoo Mar 30, 2022
a7a27b1
added styling for β€œcompact” type of β€œAlert"
didoo Mar 30, 2022
f499764
added handling of β€œoutlined/filled” icons for β€œcompact” vs other types
didoo Mar 30, 2022
e4bd49b
handled icon size depending on the β€œalert” type
didoo Mar 30, 2022
d6c37ec
fixed margin-right of the icon for β€œcompact"
didoo Mar 30, 2022
41b6787
Merge pull request #146 from hashicorp/alert-toast
didoo Mar 30, 2022
1265013
Merge branch 'amy/alert-overall-branch' into amy/alert-compact
didoo Mar 30, 2022
77f27f3
Fix lint
amyrlam Mar 30, 2022
17a0b0a
Merge pull request #135 from hashicorp/amy/alert-compact
amyrlam Mar 30, 2022
97847a2
Merge branch 'main' into amy/alert-overall-branch
amyrlam Mar 30, 2022
67a2dd3
Merge branch 'amy/alert-overall-branch' into alert-dismiss
didoo Mar 31, 2022
e31fe0a
Merge branch 'amy/alert-overall-branch' into alert-showcase
didoo Mar 31, 2022
671b852
removed old showcases
didoo Mar 31, 2022
31ee9e5
added very subtle border around β€œcompact” alert to show bounding box
didoo Mar 31, 2022
024ec32
Merge pull request #138 from hashicorp/alert-showcase
didoo Mar 31, 2022
6ca7aac
Merge branch 'amy/alert-overall-branch' into alert-dismiss
didoo Mar 31, 2022
3793a5d
added animate icon case to β€œAlerts” showcase
didoo Mar 31, 2022
4e7a642
changed order of colors in showcase
didoo Mar 31, 2022
f566408
renamed β€œonDismiss” to β€œonClose” and used this to determine if β€œAlert…
didoo Mar 31, 2022
a6907e2
fixed vertical alignment of text with icon in case of a single line
didoo Mar 31, 2022
f0aafe3
linting
didoo Mar 31, 2022
abe2cb6
Fix test failure
amyrlam Apr 1, 2022
2bb8d99
Merge pull request #132 from hashicorp/alert-dismiss
amyrlam Apr 1, 2022
31b44a0
Merge branch 'main' into amy/alert-overall-branch
amyrlam Apr 1, 2022
d312018
fixed annoying warning in console
didoo Apr 1, 2022
a66fbc2
Merge branch 'main' into amy/alert-overall-branch
didoo Apr 1, 2022
09b892f
fixed issue with the β€œnoop” in the β€œAlerts” dummy page
didoo Apr 1, 2022
defb43c
first batch of tests
didoo Apr 1, 2022
8b190ee
second batch of tests
didoo Apr 1, 2022
0a8a23f
lint
didoo Apr 1, 2022
6fd18ac
Merge pull request #159 from hashicorp/alert-integration-tests
didoo Apr 1, 2022
62dab75
removed line added days ago in testing β€œnoop” helper
didoo Apr 5, 2022
d7d0f32
Merge branch 'main' into amy/alert-overall-branch
amyrlam Apr 5, 2022
81b6f8c
Update docs
amyrlam Apr 6, 2022
dbc6036
Add a11y no formatting or code logic
amyrlam Apr 6, 2022
26153c4
fixed formatting of code for β€œalerts” block
didoo Apr 7, 2022
37f4a73
re-ordered CSS declarations for states
didoo Apr 12, 2022
52f520d
Move scratch links to bottom
amyrlam Apr 14, 2022
3642065
Add Overview definition from CRD
amyrlam Apr 14, 2022
3945f89
Update docs
amyrlam Apr 14, 2022
0ffc9b7
Add a11y doc details
amyrlam Apr 14, 2022
822103a
Update a11y
amyrlam Apr 14, 2022
f068845
Add stickersheet
amyrlam Apr 14, 2022
92bafb0
Merge pull request #186 from hashicorp/amy/alert-a11y
amyrlam Apr 14, 2022
ef97dbb
Merge branch 'main' into amy/alert-overall-branch
amyrlam Apr 14, 2022
f220378
updated documentation about alerts
didoo Apr 25, 2022
97b2e69
Merge branch 'main' into amy/alert-overall-branch
didoo Apr 25, 2022
18365d7
updated documentation
didoo Apr 25, 2022
c6de101
added changeset (to create PR)
didoo Apr 25, 2022
061933c
Merge pull request #91 from hashicorp/amy/alert-overall-branch
didoo Apr 25, 2022
8e710d8
fixed icon color for `alert/compact/neutral`
didoo Apr 27, 2022
33954f2
removed β€œpage” as default for the β€œtype” of alert
didoo Apr 27, 2022
3d90c49
added handlebars β€œsquishiesβ€œ to `alert` template to fix issue with wh…
didoo Apr 27, 2022
b938e7a
Merge branch 'main' into alert/finalize-implementation
didoo Apr 28, 2022
d6c057a
extracted toast - part 1
didoo Apr 29, 2022
bacbe69
removed override of border color
didoo Apr 29, 2022
26cd762
added todo
didoo Apr 29, 2022
950eba1
updated the alerts according to new design specs + refactored CSS cod…
didoo Apr 29, 2022
6878232
Merge branch 'alert/finalize-implementation' into alert/spike-extract…
didoo Apr 29, 2022
496adca
re-removed the classes for β€œtoast” in Alert.css
didoo Apr 29, 2022
cf68d45
more updates to the documentation page for Toast
didoo Apr 29, 2022
72afc93
finalized API for `Alert` and `Toast` using forwarding of named block…
didoo May 3, 2022
e079cc5
updated documentation for `Alert`
didoo May 3, 2022
dfa5b5e
removed test code
didoo May 3, 2022
42eec1f
Merge branch 'main' into alert/finalize-implementation
didoo May 3, 2022
002a170
more documentation update
didoo May 3, 2022
a40cb62
renamed `onClose` function to `onDismiss` (more consistent with desig…
didoo May 3, 2022
964612c
updated documentation for `Alert` and `Toast` to follow PR request
didoo May 3, 2022
084ff3d
updated toast min-max width values
didoo May 3, 2022
51ba70c
finalized CSS for `Alert`
didoo May 3, 2022
d05cc46
updated integration tests for `Alert` component
didoo May 3, 2022
04f561d
moved role attribute before ...attributes
didoo May 3, 2022
da10fb7
added missing `aria-label` to the `dismiss` button
didoo May 4, 2022
302af1e
found a fix/hack to the issue of the extra space in the Toast component
didoo May 4, 2022
bc97245
Merge branch 'main' into alert/finalize-implementation
didoo May 5, 2022
57fbcb4
found fix for whitespace problem
didoo May 5, 2022
f209c72
updated changeset
didoo May 5, 2022
f7c6825
small fixes pre-review
didoo May 5, 2022
fc6525b
linting
didoo May 5, 2022
06bda12
added generic β€œyield” component (to be uses as yielded component in `…
didoo May 5, 2022
eb6f11c
refactored API of Alert and Toast components to follow approach used …
didoo May 5, 2022
c385228
updated documentation following the API updates
didoo May 5, 2022
07ed281
removed extra β€œsquidgies”
didoo May 5, 2022
45615c7
fix for linter (not sure why it was failing)
didoo May 5, 2022
e4ebffb
forgot to fix the integration tests (:facepalm)
didoo May 5, 2022
97304e2
improved responsiveness of `Toast`
didoo May 6, 2022
1a8ad25
small tweak
didoo May 6, 2022
fe7aea9
improved tests for `Alert` component
didoo May 6, 2022
b3c9b29
fixed skipped test. thanks brian!
didoo May 6, 2022
30575fc
Update packages/components/tests/dummy/app/templates/components/alert…
didoo May 6, 2022
a12987e
fixed linting on merged suggestion
didoo May 6, 2022
21e86e0
fixes after code reviews
didoo May 9, 2022
d9c63b8
Updated font weight of `title` text in Alert component
didoo May 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/stale-teachers-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@hashicorp/design-system-components": minor
---

- Added `Alert` component
- Added `Toast` component
35 changes: 35 additions & 0 deletions packages/components/addon/components/hds/alert/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class={{this.classNames}} role="alert" ...attributes>
{{#if this.icon}}
<div class="hds-alert__icon">
<FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} @isInlineBlock={{false}} />
</div>
{{/if}}

<div class="hds-alert__content">
<div class="hds-alert__text">
{{#if @title}}
<div class="hds-alert__title">{{@title}}</div>
{{/if}}
{{#if @description}}
<div class="hds-alert__description">{{html-safe @description}}</div>
{{/if}}
</div>

<div class="hds-alert__actions">
{{yield
(hash
Button=(component "hds/button" size="small")
Link::Standalone=(component "hds/link/standalone" size="small")
LinkTo::Standalone=(component "hds/link-to/standalone" size="small")
)
}}
</div>
{{yield (hash Generic=(component "hds/yield"))}}
</div>

{{#if this.onDismiss}}
<button class="hds-alert__dismiss" type="button" aria-label="Dismiss" {{on "click" this.onDismiss}}>
<FlightIcon @name="x" @size="16" @isInlineBlock={{false}} />
</button>
{{/if}}
</div>
128 changes: 128 additions & 0 deletions packages/components/addon/components/hds/alert/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import Component from '@glimmer/component';
import { assert } from '@ember/debug';

export const TYPES = ['page', 'inline', 'compact'];
export const DEFAULT_COLOR = 'neutral';
export const COLORS = [
'neutral',
'highlight',
'success',
'warning',
'critical',
];
export const MAPPING_COLORS_TO_ICONS = {
neutral: 'info',
highlight: 'info',
success: 'check-circle',
warning: 'alert-triangle',
critical: 'alert-diamond',
};

export default class HdsAlertIndexComponent extends Component {
constructor() {
super(...arguments);

assert(
`@type for "Hds::Alert" must be one of the following: ${TYPES.join(
', '
)}; received: ${this.args.type}`,
TYPES.includes(this.args.type)
);
}

/**
* @param color
* @type {enum}
* @default neutral
* @description Determines the color scheme for the alert.
*/
get color() {
let { color = DEFAULT_COLOR } = this.args;

assert(
`@color for "Hds::Alert" must be one of the following: ${COLORS.join(
', '
)}; received: ${color}`,
COLORS.includes(color)
);

return color;
}

/**
* @param icon
* @type {string}
* @default null
* @description The name of the icon to be used.
*/
get icon() {
let { icon } = this.args;

// If `icon` isn't passed, use the pre-defined one from `color`
if (icon === undefined) {
if (this.args.type === 'compact') {
// for the "compact" type by default we use filled icons
return `${MAPPING_COLORS_TO_ICONS[this.color]}-fill`;
} else {
// for all the other types by default we use outlined icons
return MAPPING_COLORS_TO_ICONS[this.color];
}
// If `icon` is set explicitly to false, user doesn't want any icon in the alert
} else if (icon === false) {
assert(
`@icon for "Hds::Alert" with @type "compact" is required`,
this.args.type !== 'compact'
);

return false;
} else {
// If a name for `icon` is passed, set FlightIcon to that name
return icon;
}
}

/**
* @param onDismiss
* @type {function}
* @default () => {}
*/
get onDismiss() {
let { onDismiss } = this.args;

if (typeof onDismiss === 'function') {
return onDismiss;
} else {
return false;
}
}

/**
* @param iconSize
* @type {string}
* @description ensures that the correct icon size is used. Automatically calculated.
*/
get iconSize() {
if (this.args.type === 'compact') {
return '16';
} else {
return '24';
}
}

/**
* Get the class names to apply to the component.
* @method Alert#classNames
* @return {string} The "class" attribute to apply to the component.
*/
get classNames() {
let classes = ['hds-alert'];

// Add a class based on the @type argument
classes.push(`hds-alert--type-${this.args.type}`);

// Add a class based on the @color argument
classes.push(`hds-alert--color-${this.color}`);

return classes.join(' ');
}
}
15 changes: 15 additions & 0 deletions packages/components/addon/components/hds/toast/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Hds::Alert
class="hds-toast"
@type="inline"
@color={{@color}}
@icon={{@icon}}
@title={{@title}}
@description={{@description}}
@onDismiss={{@onDismiss}}
...attributes
as |A|
>
{{yield
(hash Button=A.Button Link::Standalone=A.Link::Standalone LinkTo::Standalone=A.LinkTo::Standalone Generic=A.Generic)
}}
</Hds::Alert>
3 changes: 3 additions & 0 deletions packages/components/addon/components/hds/yield/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div ...attributes>
{{yield}}
</div>
1 change: 1 addition & 0 deletions packages/components/app/components/hds/alert/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@hashicorp/design-system-components/components/hds/alert/index';
1 change: 1 addition & 0 deletions packages/components/app/components/hds/toast/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@hashicorp/design-system-components/components/hds/toast/index';
1 change: 1 addition & 0 deletions packages/components/app/components/hds/yield/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@hashicorp/design-system-components/components/hds/yield/index';
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@use "helpers/focus-ring";
@use "helpers/typography";

@use "../components/alert";
@use "../components/badge";
@use "../components/badge-count";
@use "../components/breadcrumb";
Expand All @@ -15,6 +16,7 @@
@use "../components/icon-tile";
@use "../components/link/cta";
@use "../components/link/standalone";
@use "../components/toast";

.sr-only {
border: 0 !important;
Expand Down
Loading