@hashicorp/design-system-components 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/NEW-COMPONENT-CHECKLIST.md +20 -11
  3. package/addon/components/hds/disclosure/index.js +4 -0
  4. package/addon/components/hds/dropdown/index.hbs +10 -13
  5. package/addon/components/hds/dropdown/index.js +45 -0
  6. package/addon/components/hds/dropdown/list-item/copy-item.hbs +20 -0
  7. package/addon/components/hds/dropdown/list-item/copy-item.js +48 -0
  8. package/addon/components/hds/dropdown/list-item/description.hbs +3 -0
  9. package/addon/components/hds/dropdown/list-item/description.js +38 -0
  10. package/addon/components/hds/dropdown/list-item/generic.hbs +3 -0
  11. package/addon/components/hds/dropdown/list-item/interactive.hbs +44 -0
  12. package/addon/components/hds/dropdown/list-item/interactive.js +59 -0
  13. package/addon/components/hds/dropdown/list-item/separator.hbs +1 -0
  14. package/addon/components/hds/dropdown/list-item/title.hbs +3 -0
  15. package/addon/components/hds/dropdown/list-item/title.js +35 -0
  16. package/addon/components/hds/dropdown/{toggle-button.hbs → toggle/button.hbs} +3 -3
  17. package/addon/components/hds/dropdown/{toggle-button.js → toggle/button.js} +21 -3
  18. package/addon/components/hds/dropdown/toggle/icon.hbs +12 -0
  19. package/addon/components/hds/dropdown/{toggle-icon.js → toggle/icon.js} +28 -13
  20. package/app/components/hds/dropdown/list-item/copy-item.js +1 -0
  21. package/app/components/hds/dropdown/list-item/description.js +1 -0
  22. package/app/components/hds/dropdown/list-item/generic.js +1 -0
  23. package/app/components/hds/dropdown/list-item/interactive.js +1 -0
  24. package/app/components/hds/dropdown/list-item/separator.js +1 -0
  25. package/app/components/hds/dropdown/{toggle-icon.js → list-item/title.js} +1 -1
  26. package/app/components/hds/dropdown/{toggle-button.js → toggle/button.js} +1 -1
  27. package/app/components/hds/dropdown/{list-item.js → toggle/icon.js} +1 -1
  28. package/app/styles/components/breadcrumb.scss +14 -11
  29. package/app/styles/components/button.scss +36 -30
  30. package/app/styles/components/dropdown.scss +121 -114
  31. package/app/styles/components/link/standalone.scss +1 -2
  32. package/package.json +3 -2
  33. package/addon/components/hds/dropdown/list-item.hbs +0 -84
  34. package/addon/components/hds/dropdown/list-item.js +0 -120
  35. package/addon/components/hds/dropdown/toggle-icon.hbs +0 -22
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @hashicorp/design-system-components
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#200](https://github.com/hashicorp/design-system/pull/200) [`a8072537`](https://github.com/hashicorp/design-system/commit/a8072537542791398d375cde4a7a85c2955c66da) Thanks [@didoo](https://github.com/didoo)! - Updated Dropdown component:
8
+
9
+ - added chevron animation for `toggle` elements
10
+ - fixed issue with `list-item/interactive` height
11
+ - added handling of dynamic `width` for the list
12
+ - exposed an `onClose` event
13
+ - removed the default icon for `toggle/icon`
14
+ - removed icon requirement from the `critical` list item
15
+ - updated the documentation and integration tests
16
+ - some code refactorings, reorganizations and cleanups
17
+
18
+ ## 0.9.2
19
+
20
+ ### Patch Changes
21
+
22
+ - [#209](https://github.com/hashicorp/design-system/pull/209) [`6021d433`](https://github.com/hashicorp/design-system/commit/6021d43352b8e38b268b06cd98ca0c62adb14999) Thanks [@didoo](https://github.com/didoo)! - Re-ordered declarations of CSS states
23
+
24
+ ## 0.9.1
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies []:
29
+ - @hashicorp/ember-flight-icons@2.0.5
30
+
3
31
  ## 0.9.0
4
32
 
5
33
  ### Minor Changes
@@ -14,25 +14,27 @@ The engineering checklist has six parts: creating the feature branch, component
14
14
 
15
15
  ### Component Creation
16
16
 
17
- - [ ] create new branch from main for the component.
17
+ - [ ] create new branch from main for the component (`git checkout -b USER/COMPONENT-NAME`)
18
18
  - [ ] create new component
19
- - `ember generate component hds/COMPONENT_NAME/index --gc` (the component won't need to be invoked with index, it's just to put all the files in the correct place)
20
- - if it's a variation on a component, then `hds/COMPONENT_NAME/VARIATION` instead of `index`
19
+ - `ember generate component hds/COMPONENT-NAME/index --gc` (the component won't need to be invoked with index, it's just to put all the files in the correct place)
20
+ - tip: if you forget to generate the backing class (via `--gc`), you can add it with `ember generate component-class hds/COMPONENT-NAME/index`.
21
+ - if it's a child component, then `hds/COMPONENT_NAME/CHILD_NAME` instead of `index`
22
+ - tip: if you need to destroy a component and start over again, `ember destroy component hds/COMPONENT-NAME/index` will remove the component and the related files as appropriate.
21
23
  - [ ] **component template**
22
24
  - use semantic HTML
23
25
  - the component should have a css class that is the same as the component (e.g. `hds/button` should have a class name of `hds-button` on the component, and additional CSS classes should start with this same class name.
24
26
  - add `...attributes` unless doing so would be detrimental (e.g., a parent element and child element in the same component that both have ...attributes)
25
27
  - [ ] **component class**
26
28
  - use getters (vs template conditionals or constructors, if possible)
27
- - write API comments in the JS doc way (copy from an existing DS component)
28
- - use the same naming as the Figma file for the components API unless it conflicts with a pre-existing HTML attribute. If that is the case, document the difference in the comment.
29
- - ensure that all existing functionality (from a Structure component) is accounted for in some way. If we are not providing existing functionality at all, it should be documented (along with the reason why). If we are providing temporary functionality, explain that it's temporary and why.
30
- - check the [design system website](https://design-system-website.vercel.app/?path=/story/example-introduction--page) to see what kind of component functionality is being used across all products
29
+ - we have chosen to define the value of the `class` attribute (containing the different CSS class names) for the "root" of the element's code in the backing class, UNLESS that component only has one CSS class name.
30
+ - write API comments in the [JS doc](https://jsdoc.app/) format (look at existing components for examples)
31
+ - use the same naming as the Figma file for the components API, unless it conflicts with a pre-existing HTML attribute. If that is the case, document the difference in a comment.
32
+ - if there is an existing Structure component that is similar to the HDS component being created, ensure that all existing functionality is accounted for in some way. If we are not providing existing functionality at all, it should be documented (along with the reason why). If we are providing temporary functionality, explain that it's temporary and why.
31
33
  - booleans should start with a verb (is/has/etc)
32
- - assertion text should match the content style of the other components.
33
- - goal is a terse invocation
34
+ - assertions should match the content style of the other components, e.g., `'@text for "Hds::Button" must have a valid value'`,
35
+ - program with intent; think about the invocation for the developer who will use the component. The goal is a terse invocation, but we also want to consider the big picture. Try to get feedback when you can.
34
36
  - [ ] **component style**
35
- - create `component/COMPONENT_NAME.scss` in `app/styles`
37
+ - create `component/COMPONENT-NAME.scss` in `app/styles`
36
38
  - add `@use` to `app/styles/@hashicorp/design-system-components.scss` (see existing code for precise syntax)
37
39
  - use design tokens wherever possible, comment where they are not
38
40
  - sizes should be in relative units
@@ -42,12 +44,18 @@ The engineering checklist has six parts: creating the feature branch, component
42
44
  - [ ] test defaults
43
45
  - [ ] try not to repeat tests (i.e., don't have to test all sizes, all colors, etc.)
44
46
  - [ ] test all accessibility attributes
47
+ - [ ] test assertions
45
48
  - [ ] **documentation**
46
49
  - create component page `ember generate route components/COMPONENT_NAME --dummy`
47
50
  - add link to `templates/index.hbs` page
48
- - [ ] API docs
51
+ - [ ] Definition of component (from CRD) (this should be a paragraph under the component name, and before the first section)
52
+ - [ ] Component API
49
53
  - [ ] Usage
54
+ - [ ] Design Guidelines
50
55
  - [ ] Accessibility
56
+ - Conformance Rating [(internal document)](https://docs.google.com/document/d/1OjTKpQLB_wuZSVJNLbbguTzMDMYCHKhNdKQz7-Kfqic/edit#bookmark=id.v7r42vfu4pdd)
57
+ - Known Issues (if any)
58
+ - Related WCAG (pull from CRD or ask Melanie)
51
59
  - [ ] Showcase
52
60
 
53
61
  ### Component Review
@@ -69,5 +77,6 @@ Pre-review request checks:
69
77
  - Edge (once available)
70
78
 
71
79
  When ready for review:
80
+
72
81
  - [ ] add situationally appropriate reviewers
73
82
  - [ ] added instructions for reviewers in your PR, letting them know what kind of review you need
@@ -38,6 +38,10 @@ export default class HdsDisclosureComponent extends Component {
38
38
  this.isActive = false;
39
39
  // we need to reset this check
40
40
  this.isToggleClicked = false;
41
+ // we call the "onClose" callback if it exists (and is a function)
42
+ if (this.args.onClose && typeof this.args.onClose === 'function') {
43
+ this.args.onClose();
44
+ }
41
45
  }
42
46
  }
43
47
  }
@@ -1,25 +1,22 @@
1
- <Hds::Disclosure class="hds-dropdown">
1
+ <Hds::Disclosure class="hds-dropdown" @onClose={{@onClose}} ...attributes>
2
2
  <:toggle as |t|>
3
3
  {{yield
4
4
  (hash
5
- ToggleButton=(component "hds/dropdown/toggle-button" isOpen=t.isActive onClick=t.onClickToggle)
6
- ToggleIcon=(component "hds/dropdown/toggle-icon" isOpen=t.isActive onClick=t.onClickToggle)
5
+ ToggleButton=(component "hds/dropdown/toggle/button" isOpen=t.isActive onClick=t.onClickToggle)
6
+ ToggleIcon=(component "hds/dropdown/toggle/icon" isOpen=t.isActive onClick=t.onClickToggle)
7
7
  )
8
8
  }}
9
9
  </:toggle>
10
10
  <:content>
11
- <ul
12
- class="hds-dropdown-list
13
- {{if (eq @listPosition 'left') 'hds-dropdown-list--position-left' 'hds-dropdown-list--position-right'}}"
14
- >
11
+ <ul class={{this.listClassNames}} {{style width=@width}}>
15
12
  {{yield
16
13
  (hash
17
- CopyItem=(component "hds/dropdown/list-item" item="copy-item")
18
- Description=(component "hds/dropdown/list-item" item="description")
19
- Generic=(component "hds/dropdown/list-item" item="generic")
20
- Interactive=(component "hds/dropdown/list-item")
21
- Separator=(component "hds/dropdown/list-item" item="separator")
22
- Title=(component "hds/dropdown/list-item" item="title")
14
+ CopyItem=(component "hds/dropdown/list-item/copy-item")
15
+ Description=(component "hds/dropdown/list-item/description")
16
+ Generic=(component "hds/dropdown/list-item/generic")
17
+ Interactive=(component "hds/dropdown/list-item/interactive")
18
+ Separator=(component "hds/dropdown/list-item/separator")
19
+ Title=(component "hds/dropdown/list-item/title")
23
20
  )
24
21
  }}
25
22
  </ul>
@@ -0,0 +1,45 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ export const DEFAULT_POSITION = 'right';
5
+ export const POSITIONS = ['right', 'left'];
6
+
7
+ export default class HdsDropdownIndexComponent extends Component {
8
+ /**
9
+ * @param listPosition
10
+ * @type {string}
11
+ * @default primary
12
+ * @description Determines the position of the "list"
13
+ */
14
+ get listPosition() {
15
+ let { listPosition = DEFAULT_POSITION } = this.args;
16
+
17
+ assert(
18
+ `@listPosition for "Hds::Dropdown::Index" must be one of the following: ${POSITIONS.join(
19
+ ', '
20
+ )}; received: ${listPosition}`,
21
+ POSITIONS.includes(listPosition)
22
+ );
23
+
24
+ return listPosition;
25
+ }
26
+
27
+ /**
28
+ * Get the class names to apply to the "list"
29
+ * @method DropdownIndex#listClassNames
30
+ * @return {string} The "class" attribute to apply to the "list" element
31
+ */
32
+ get listClassNames() {
33
+ let classes = ['hds-dropdown-list'];
34
+
35
+ // add a class based on the @listPosition argument
36
+ classes.push(`hds-dropdown-list--position-${this.listPosition}`);
37
+
38
+ // add a class based on the @width argument
39
+ if (this.args.width) {
40
+ classes.push('hds-dropdown-list--fixed-width');
41
+ }
42
+
43
+ return classes.join(' ');
44
+ }
45
+ }
@@ -0,0 +1,20 @@
1
+ <li class={{this.classNames}} ...attributes>
2
+ {{#if @copyItemTitle}}
3
+ <div
4
+ class="hds-dropdown-list-item__copy-item-title hds-typography-body-100 hds-font-weight-semibold"
5
+ >{{@copyItemTitle}}</div>
6
+ {{/if}}
7
+ <button
8
+ type="button"
9
+ class="{{if @state (concat 'is-' @state)}} {{if this.isSuccess 'is-success'}}"
10
+ {{on "click" this.copyCode}}
11
+ >
12
+ <div class="hds-dropdown-list-item__copy-item-text hds-typography-code-100">
13
+ {{this.text}}
14
+ </div>
15
+ <FlightIcon
16
+ @name="{{if this.isSuccess 'clipboard-checked' 'clipboard-copy'}}"
17
+ class="hds-dropdown-list-item__copy-item-icon"
18
+ />
19
+ </button>
20
+ </li>
@@ -0,0 +1,48 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+ import { tracked } from '@glimmer/tracking';
4
+ import { action } from '@ember/object';
5
+
6
+ export default class HdsDropdownListItemCopyItemComponent extends Component {
7
+ @tracked isSuccess = this.args.isSuccess ?? false;
8
+
9
+ /**
10
+ * @param text
11
+ * @type {string}
12
+ * @description The text of the item. If no text value is defined an error will be thrown
13
+ */
14
+ get text() {
15
+ let { text } = this.args;
16
+
17
+ assert(
18
+ '@text for "Hds::Dropdown::ListItem::CopyItem" must have a valid value',
19
+ text !== undefined
20
+ );
21
+
22
+ return text;
23
+ }
24
+
25
+ /**
26
+ * Get the class names to apply to the component.
27
+ * @method classNames
28
+ * @return {string} The "class" attribute to apply to the component.
29
+ */
30
+ get classNames() {
31
+ let classes = [
32
+ 'hds-dropdown-list-item',
33
+ 'hds-dropdown-list-item--copy-item',
34
+ ];
35
+
36
+ return classes.join(' ');
37
+ }
38
+
39
+ @action
40
+ copyCode() {
41
+ navigator.clipboard.writeText(this.args.text);
42
+ // this if statement resolves to [object Promise] so maybe some improvements
43
+ // could be made here
44
+ if (navigator.clipboard.readText()) {
45
+ this.isSuccess = true;
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,3 @@
1
+ <li class={{this.classNames}} ...attributes>
2
+ {{this.text}}
3
+ </li>
@@ -0,0 +1,38 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ export default class HdsDropdownListItemDescriptionComponent extends Component {
5
+ /**
6
+ * @param text
7
+ * @type {string}
8
+ * @description The text of the item. If no text value is defined an error will be thrown
9
+ */
10
+ get text() {
11
+ let { text } = this.args;
12
+
13
+ assert(
14
+ '@text for "Hds::Dropdown::ListItem::Description" must have a valid value',
15
+ text !== undefined
16
+ );
17
+
18
+ return text;
19
+ }
20
+
21
+ /**
22
+ * Get the class names to apply to the component.
23
+ * @method classNames
24
+ * @return {string} The "class" attribute to apply to the component.
25
+ */
26
+ get classNames() {
27
+ let classes = [
28
+ 'hds-dropdown-list-item',
29
+ 'hds-dropdown-list-item--description',
30
+ ];
31
+
32
+ // add classes for the typographic style
33
+ classes.push('hds-typography-body-100');
34
+ classes.push('hds-font-weight-regular');
35
+
36
+ return classes.join(' ');
37
+ }
38
+ }
@@ -0,0 +1,3 @@
1
+ <li class="hds-dropdown-list-item hds-dropdown-list-item--generic" ...attributes>
2
+ {{yield}}
3
+ </li>
@@ -0,0 +1,44 @@
1
+ <li class={{this.classNames}}>
2
+ {{#if @route}}
3
+ <LinkTo
4
+ class="{{if @state (concat 'is-' @state)}}"
5
+ @current-when={{@current-when}}
6
+ @models={{hds-link-to-models @model @models}}
7
+ @query={{hds-link-to-query @query}}
8
+ @replace={{@replace}}
9
+ @route={{@route}}
10
+ ...attributes
11
+ >
12
+ {{#if @icon}}
13
+ <div class="hds-dropdown-list-item__interactive-icon">
14
+ <FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
15
+ </div>
16
+ {{/if}}
17
+ <div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
18
+ {{this.text}}
19
+ </div>
20
+ </LinkTo>
21
+ {{else if @href}}
22
+ <a target="_blank" rel="noopener noreferrer" href={{@href}} class="{{if @state (concat 'is-' @state)}}">
23
+ {{#if @icon}}
24
+ <div class="hds-dropdown-list-item__interactive-icon">
25
+ <FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
26
+ </div>
27
+ {{/if}}
28
+ <div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
29
+ {{this.text}}
30
+ </div>
31
+ </a>
32
+ {{else}}
33
+ <button class="{{if @state (concat 'is-' @state)}}" type="button" ...attributes>
34
+ {{#if @icon}}
35
+ <div class="hds-dropdown-list-item__interactive-icon">
36
+ <FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
37
+ </div>
38
+ {{/if}}
39
+ <div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
40
+ {{this.text}}
41
+ </div>
42
+ </button>
43
+ {{/if}}
44
+ </li>
@@ -0,0 +1,59 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ export const DEFAULT_COLOR = 'action';
5
+ export const COLORS = ['action', 'critical'];
6
+
7
+ export default class HdsDropdownListItemInteractiveComponent extends Component {
8
+ /**
9
+ * @param text
10
+ * @type {string}
11
+ * @description The text of the item. If no text value is defined an error will be thrown
12
+ */
13
+ get text() {
14
+ let { text } = this.args;
15
+
16
+ assert(
17
+ '@text for "Hds::Dropdown::ListItem::Interactive" must have a valid value',
18
+ text !== undefined
19
+ );
20
+
21
+ return text;
22
+ }
23
+
24
+ /**
25
+ * @param color
26
+ * @type {string}
27
+ * @default primary
28
+ * @description Determines the color of the item (when item is set to interactive)
29
+ */
30
+ get color() {
31
+ let { color = DEFAULT_COLOR } = this.args;
32
+
33
+ assert(
34
+ `@color for "Hds::Dropdown::ListItem::Interactive" must be one of the following: ${COLORS.join(
35
+ ', '
36
+ )}; received: ${color}`,
37
+ COLORS.includes(color)
38
+ );
39
+
40
+ return color;
41
+ }
42
+
43
+ /**
44
+ * Get the class names to apply to the component.
45
+ * @method classNames
46
+ * @return {string} The "class" attribute to apply to the component.
47
+ */
48
+ get classNames() {
49
+ let classes = [
50
+ 'hds-dropdown-list-item',
51
+ 'hds-dropdown-list-item--interactive',
52
+ ];
53
+
54
+ // add a class based on the @color argument
55
+ classes.push(`hds-dropdown-list-item--color-${this.color}`);
56
+
57
+ return classes.join(' ');
58
+ }
59
+ }
@@ -0,0 +1 @@
1
+ <li class="hds-dropdown-list-item hds-dropdown-list-item--separator" role="separator" ...attributes></li>
@@ -0,0 +1,3 @@
1
+ <li class={{this.classNames}} ...attributes>
2
+ {{this.text}}
3
+ </li>
@@ -0,0 +1,35 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ export default class HdsDropdownListItemTitleComponent extends Component {
5
+ /**
6
+ * @param text
7
+ * @type {string}
8
+ * @description The text of the item. If no text value is defined an error will be thrown
9
+ */
10
+ get text() {
11
+ let { text } = this.args;
12
+
13
+ assert(
14
+ '@text for "Hds::Dropdown::ListItem::Title" must have a valid value',
15
+ text !== undefined
16
+ );
17
+
18
+ return text;
19
+ }
20
+
21
+ /**
22
+ * Get the class names to apply to the component.
23
+ * @method classNames
24
+ * @return {string} The "class" attribute to apply to the component.
25
+ */
26
+ get classNames() {
27
+ let classes = ['hds-dropdown-list-item', 'hds-dropdown-list-item--title'];
28
+
29
+ // add classes for the typographic style
30
+ classes.push('hds-typography-body-100');
31
+ classes.push('hds-font-weight-semibold');
32
+
33
+ return classes.join(' ');
34
+ }
35
+ }
@@ -13,11 +13,11 @@
13
13
  }}
14
14
 
15
15
  <Hds::Button
16
+ class={{this.classNames}}
16
17
  @text={{this.text}}
17
- @icon="chevron-{{if @isOpen 'up' 'down'}}"
18
+ @icon="chevron-down"
18
19
  @iconPosition="trailing"
19
20
  @color={{this.color}}
20
- class="hds-dropdown-toggle--with-button-component"
21
- {{on "click" this.onClick}}
22
21
  ...attributes
22
+ {{on "click" this.onClick}}
23
23
  />
@@ -4,6 +4,8 @@ import { assert } from '@ember/debug';
4
4
  export const DEFAULT_COLOR = 'primary';
5
5
  export const COLORS = ['primary', 'secondary'];
6
6
 
7
+ const NOOP = () => {};
8
+
7
9
  export default class HdsDropdownToggleButtonComponent extends Component {
8
10
  /**
9
11
  * @param text
@@ -14,7 +16,7 @@ export default class HdsDropdownToggleButtonComponent extends Component {
14
16
  let { text } = this.args;
15
17
 
16
18
  assert(
17
- '@text for "Hds::Dropdown::ToggleButton" must have a valid value',
19
+ '@text for "Hds::Dropdown::Toggle::Button" must have a valid value',
18
20
  text !== undefined
19
21
  );
20
22
 
@@ -31,7 +33,7 @@ export default class HdsDropdownToggleButtonComponent extends Component {
31
33
  let { color = DEFAULT_COLOR } = this.args;
32
34
 
33
35
  assert(
34
- `@color for "Hds::Dropdown::ToggleButton" must be one of the following: ${COLORS.join(
36
+ `@color for "Hds::Dropdown::Toggle::Button" must be one of the following: ${COLORS.join(
35
37
  ', '
36
38
  )}; received: ${color}`,
37
39
  COLORS.includes(color)
@@ -53,7 +55,23 @@ export default class HdsDropdownToggleButtonComponent extends Component {
53
55
  if (typeof onClick === 'function') {
54
56
  return onClick;
55
57
  } else {
56
- return () => {};
58
+ return NOOP;
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Get the class names to apply to the component.
64
+ * @method ToggleButton#classNames
65
+ * @return {string} The "class" attribute to apply to the component.
66
+ */
67
+ get classNames() {
68
+ let classes = ['hds-dropdown-toggle-button'];
69
+
70
+ // add a class based on the @isOpen argument
71
+ if (this.args.isOpen) {
72
+ classes.push('hds-dropdown-toggle-button--is-open');
57
73
  }
74
+
75
+ return classes.join(' ');
58
76
  }
59
77
  }
@@ -0,0 +1,12 @@
1
+ <button class={{this.classNames}} aria-label={{this.text}} ...attributes {{on "click" this.onClick}} type="button">
2
+ <div class="hds-dropdown-toggle-icon__wrapper">
3
+ {{#if @imageSrc}}
4
+ <img src={{@imageSrc}} alt="" role="presentation" height="32" width="32" />
5
+ {{else if @icon}}
6
+ <FlightIcon @name={{@icon}} @size="24" />
7
+ {{/if}}
8
+ </div>
9
+ {{#if this.hasChevron}}
10
+ <FlightIcon @name="chevron-down" class="hds-dropdown-toggle-icon__chevron" @isInlineBlock={{false}} />
11
+ {{/if}}
12
+ </button>
@@ -1,7 +1,17 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { assert } from '@ember/debug';
3
3
 
4
+ const NOOP = () => {};
4
5
  export default class HdsDropdownToggleIconComponent extends Component {
6
+ constructor() {
7
+ super(...arguments);
8
+ if (!(this.args.icon || this.args.imageSrc)) {
9
+ assert(
10
+ '@icon or @imageSrc must be defined for "Hds::Dropdown::Toggle::Icon"'
11
+ );
12
+ }
13
+ }
14
+
5
15
  /**
6
16
  * @param text
7
17
  * @type {string}
@@ -11,7 +21,7 @@ export default class HdsDropdownToggleIconComponent extends Component {
11
21
  let { text } = this.args;
12
22
 
13
23
  assert(
14
- '@text for "Hds::Dropdown::ToggleIcon" must have a valid value',
24
+ '@text for "Hds::Dropdown::Toggle::Icon" must have a valid value',
15
25
  text !== undefined
16
26
  );
17
27
 
@@ -29,17 +39,6 @@ export default class HdsDropdownToggleIconComponent extends Component {
29
39
  return this.args.hasChevron ?? true;
30
40
  }
31
41
 
32
- /**
33
- * Sets the icon name
34
- *
35
- * @param icon
36
- * @type {string}
37
- * @default user
38
- */
39
- get icon() {
40
- return this.args.icon ?? 'user';
41
- }
42
-
43
42
  /**
44
43
  * @param onClick
45
44
  * @type {function}
@@ -53,7 +52,23 @@ export default class HdsDropdownToggleIconComponent extends Component {
53
52
  if (typeof onClick === 'function') {
54
53
  return onClick;
55
54
  } else {
56
- return () => {};
55
+ return NOOP;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Get the class names to apply to the component.
61
+ * @method ToggleIcon#classNames
62
+ * @return {string} The "class" attribute to apply to the component.
63
+ */
64
+ get classNames() {
65
+ let classes = ['hds-dropdown-toggle-icon'];
66
+
67
+ // add a class based on the @isOpen argument
68
+ if (this.args.isOpen) {
69
+ classes.push('hds-dropdown-toggle-icon--is-open');
57
70
  }
71
+
72
+ return classes.join(' ');
58
73
  }
59
74
  }
@@ -0,0 +1 @@
1
+ export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item/copy-item';
@@ -0,0 +1 @@
1
+ export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item/description';
@@ -0,0 +1 @@
1
+ export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item/generic';
@@ -0,0 +1 @@
1
+ export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item/interactive';
@@ -0,0 +1 @@
1
+ export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item/separator';
@@ -1 +1 @@
1
- export { default } from '@hashicorp/design-system-components/components/hds/dropdown/toggle-icon';
1
+ export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item/title';
@@ -1 +1 @@
1
- export { default } from '@hashicorp/design-system-components/components/hds/dropdown/toggle-button';
1
+ export { default } from '@hashicorp/design-system-components/components/hds/dropdown/toggle/button';
@@ -1 +1 @@
1
- export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item';
1
+ export { default } from '@hashicorp/design-system-components/components/hds/dropdown/toggle/icon';