@hashicorp/design-system-components 1.8.1 → 2.0.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.
- package/CHANGELOG.md +44 -0
- package/addon/components/hds/dropdown/footer.hbs +3 -0
- package/addon/components/hds/dropdown/header.hbs +3 -0
- package/addon/components/hds/dropdown/index.hbs +20 -13
- package/addon/components/hds/dropdown/index.js +27 -10
- package/addon/components/hds/dropdown/list-item/checkbox.hbs +14 -0
- package/addon/components/hds/dropdown/list-item/checkbox.js +11 -0
- package/addon/components/hds/dropdown/list-item/checkmark.hbs +34 -0
- package/addon/components/hds/dropdown/list-item/checkmark.js +23 -0
- package/addon/components/hds/dropdown/list-item/copy-item.js +1 -1
- package/addon/components/hds/dropdown/list-item/description.js +1 -1
- package/addon/components/hds/dropdown/list-item/generic.hbs +1 -1
- package/addon/components/hds/dropdown/list-item/interactive.js +1 -1
- package/addon/components/hds/dropdown/list-item/radio.hbs +12 -0
- package/addon/components/hds/dropdown/list-item/radio.js +11 -0
- package/addon/components/hds/dropdown/list-item/separator.hbs +1 -1
- package/addon/components/hds/dropdown/list-item/title.js +4 -1
- package/addon/components/hds/dropdown/toggle/button.hbs +30 -21
- package/addon/components/hds/dropdown/toggle/button.js +52 -0
- package/addon/components/hds/dropdown/toggle/chevron.hbs +3 -0
- package/addon/components/hds/dropdown/toggle/icon.hbs +2 -2
- package/addon/components/hds/dropdown/toggle/icon.js +40 -0
- package/app/components/hds/dropdown/footer.js +1 -0
- package/app/components/hds/dropdown/header.js +1 -0
- package/app/components/hds/dropdown/list-item/checkbox.js +1 -0
- package/app/components/hds/dropdown/list-item/checkmark.js +1 -0
- package/app/components/hds/dropdown/list-item/radio.js +1 -0
- package/app/components/hds/dropdown/toggle/chevron.js +6 -0
- package/app/styles/components/button.scss +9 -254
- package/app/styles/components/dropdown.scss +260 -65
- package/app/styles/mixins/_button.scss +280 -0
- package/blueprints/hds-component-test/index.js +4 -2
- package/package.json +1 -1
- /package/blueprints/hds-component-test/files/tests/dummy/app/styles/{pages → showcase-pages}/__dummyCSSFileName__.scss +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @hashicorp/design-system-components
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1185](https://github.com/hashicorp/design-system/pull/1185) [`a883e7fd7`](https://github.com/hashicorp/design-system/commit/a883e7fd763ae7a93ecc5ef3d49ed0230b48ea11) Thanks [@alex-ju](https://github.com/alex-ju)! - Add `Checkmark`, `Checkbox` and `Radio` as `Hds::Dropdown::ListItem`s
|
|
8
|
+
|
|
9
|
+
Rename `Hds::Dropdown::ListItem` internal CSS classes as follows:
|
|
10
|
+
|
|
11
|
+
- `hds-dropdown-list-item--copy-item` → `hds-dropdown-list-item--variant-copy-item`
|
|
12
|
+
- `hds-dropdown-list-item--description` → `hds-dropdown-list-item--variant-description`
|
|
13
|
+
- `hds-dropdown-list-item--generic` → `hds-dropdown-list-item--variant-generic`
|
|
14
|
+
- `hds-dropdown-list-item--interactive` → `hds-dropdown-list-item--variant-interactive`
|
|
15
|
+
- `hds-dropdown-list-item--separator` → `hds-dropdown-list-item--variant-separator`
|
|
16
|
+
- `hds-dropdown-list-item--title` → `hds-dropdown-list-item--variant-title`
|
|
17
|
+
|
|
18
|
+
**Note:** If test assertions are relying on these class names, tests will fail. If extensions/overrides have been applied to these classes, they will suffer visual changes.
|
|
19
|
+
|
|
20
|
+
- [#1212](https://github.com/hashicorp/design-system/pull/1212) [`6e79216a8`](https://github.com/hashicorp/design-system/commit/6e79216a880ae140cce15f1dc6494f0aeca8e0b8) Thanks [@alex-ju](https://github.com/alex-ju)! - Add `Hds::Dropdown::Header` and `Hds::Dropdown::Footer` as generic blocks to `Hds::Dropdown`
|
|
21
|
+
|
|
22
|
+
Rename `Hds::Dropdown` internal CSS class `hds-dropdown-list` → `hds-dropdown__list`
|
|
23
|
+
|
|
24
|
+
The `hds-dropdown__list` element is now wrapped in a `hds-dropdown__content` element to accommodate the new header and footer elements. As a result, the following modifiers will be applied to the wrapper element.
|
|
25
|
+
|
|
26
|
+
- `hds-dropdown-list--fixed-width` → `hds-dropdown__content--fixed-width`
|
|
27
|
+
- `hds-dropdown-list--position-left` → `hds-dropdown__content--position-left`
|
|
28
|
+
- `hds-dropdown-list--position-right` → `hds-dropdown__content--position-right`
|
|
29
|
+
|
|
30
|
+
**Note:** If test assertions are relying on these class names, tests will fail. If extensions/overrides have been applied to these classes, they will suffer visual changes.
|
|
31
|
+
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- [#1266](https://github.com/hashicorp/design-system/pull/1266) [`082842b59`](https://github.com/hashicorp/design-system/commit/082842b59321f843c4955e4cdaf2ce2674a8913d) Thanks [@alex-ju](https://github.com/alex-ju)! - Add `@icon`, `@count`, `@badge` and `@badgeCount` to `Dropdown::Toggle::Button`
|
|
35
|
+
|
|
36
|
+
- [#1276](https://github.com/hashicorp/design-system/pull/1276) [`5ad29412d`](https://github.com/hashicorp/design-system/commit/5ad29412d2edc0cc4265d3c0bbbf388e821f1cc7) Thanks [@alex-ju](https://github.com/alex-ju)! - Allow small `@size` on `Dropdown::ToggleIcon`
|
|
37
|
+
|
|
38
|
+
- [#1262](https://github.com/hashicorp/design-system/pull/1262) [`3eb78b8de`](https://github.com/hashicorp/design-system/commit/3eb78b8de7c678cff977c9d3a677c47a3216caad) Thanks [@alex-ju](https://github.com/alex-ju)! - Add new `@listPositions` for `Dropdown` as follows:
|
|
39
|
+
|
|
40
|
+
- `bottom-left`
|
|
41
|
+
- `bottom-right` (default)
|
|
42
|
+
- `top-left`
|
|
43
|
+
- `top-right`
|
|
44
|
+
|
|
45
|
+
**Note:** `left` and `right` are now deprecated and will be removed in a future major release
|
|
46
|
+
|
|
3
47
|
## 1.8.1
|
|
4
48
|
|
|
5
49
|
### Patch Changes
|
|
@@ -12,18 +12,25 @@
|
|
|
12
12
|
}}
|
|
13
13
|
</:toggle>
|
|
14
14
|
<:content as |c|>
|
|
15
|
-
<
|
|
16
|
-
{{yield
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
<div class={{this.classNames}} {{style width=@width height=@height}}>
|
|
16
|
+
{{yield (hash Header=(component "hds/dropdown/header"))}}
|
|
17
|
+
<ul class="hds-dropdown__list" {{did-insert this.didInsertList}}>
|
|
18
|
+
{{yield
|
|
19
|
+
(hash
|
|
20
|
+
close=c.close
|
|
21
|
+
Checkbox=(component "hds/dropdown/list-item/checkbox")
|
|
22
|
+
Checkmark=(component "hds/dropdown/list-item/checkmark")
|
|
23
|
+
CopyItem=(component "hds/dropdown/list-item/copy-item")
|
|
24
|
+
Description=(component "hds/dropdown/list-item/description")
|
|
25
|
+
Generic=(component "hds/dropdown/list-item/generic")
|
|
26
|
+
Interactive=(component "hds/dropdown/list-item/interactive")
|
|
27
|
+
Radio=(component "hds/dropdown/list-item/radio")
|
|
28
|
+
Separator=(component "hds/dropdown/list-item/separator")
|
|
29
|
+
Title=(component "hds/dropdown/list-item/title")
|
|
30
|
+
)
|
|
31
|
+
}}
|
|
32
|
+
</ul>
|
|
33
|
+
{{yield (hash close=c.close Footer=(component "hds/dropdown/footer"))}}
|
|
34
|
+
</div>
|
|
28
35
|
</:content>
|
|
29
36
|
</Hds::Disclosure>
|
|
@@ -4,16 +4,25 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import Component from '@glimmer/component';
|
|
7
|
+
import { action } from '@ember/object';
|
|
7
8
|
import { assert } from '@ember/debug';
|
|
8
9
|
|
|
9
|
-
export const DEFAULT_POSITION = 'right';
|
|
10
|
-
|
|
10
|
+
export const DEFAULT_POSITION = 'bottom-right';
|
|
11
|
+
// TODO: retire 'right' and 'left' in favor of `bottom-right` and `bottom-left` https://github.com/hashicorp/design-system/pull/1262
|
|
12
|
+
export const POSITIONS = [
|
|
13
|
+
'right',
|
|
14
|
+
'left',
|
|
15
|
+
'bottom-left',
|
|
16
|
+
'bottom-right',
|
|
17
|
+
'top-left',
|
|
18
|
+
'top-right',
|
|
19
|
+
];
|
|
11
20
|
|
|
12
21
|
export default class HdsDropdownIndexComponent extends Component {
|
|
13
22
|
/**
|
|
14
23
|
* @param listPosition
|
|
15
24
|
* @type {string}
|
|
16
|
-
* @default
|
|
25
|
+
* @default bottom-right
|
|
17
26
|
* @description Determines the position of the "list"
|
|
18
27
|
*/
|
|
19
28
|
get listPosition() {
|
|
@@ -30,21 +39,29 @@ export default class HdsDropdownIndexComponent extends Component {
|
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
/**
|
|
33
|
-
* Get the class names to apply to the
|
|
34
|
-
* @method
|
|
35
|
-
* @return {string} The "class" attribute to apply to the
|
|
42
|
+
* Get the class names to apply to the content
|
|
43
|
+
* @method classNames
|
|
44
|
+
* @return {string} The "class" attribute to apply to the disclosed content
|
|
36
45
|
*/
|
|
37
|
-
get
|
|
38
|
-
let classes = ['hds-
|
|
46
|
+
get classNames() {
|
|
47
|
+
let classes = ['hds-dropdown__content'];
|
|
39
48
|
|
|
40
49
|
// add a class based on the @listPosition argument
|
|
41
|
-
classes.push(`hds-
|
|
50
|
+
classes.push(`hds-dropdown__content--position-${this.listPosition}`);
|
|
42
51
|
|
|
43
52
|
// add a class based on the @width argument
|
|
44
53
|
if (this.args.width) {
|
|
45
|
-
classes.push('hds-
|
|
54
|
+
classes.push('hds-dropdown__content--fixed-width');
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
return classes.join(' ');
|
|
49
58
|
}
|
|
59
|
+
|
|
60
|
+
@action
|
|
61
|
+
didInsertList(element) {
|
|
62
|
+
let checkmarkItems = element.querySelectorAll(`[role="option"]`);
|
|
63
|
+
if (checkmarkItems.length) {
|
|
64
|
+
element.setAttribute('role', 'listbox');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
50
67
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<li class="hds-dropdown-list-item hds-dropdown-list-item--variant-checkbox">
|
|
2
|
+
<Hds::Form::Checkbox::Base class="hds-dropdown-list-item__control" id={{this.id}} @value={{@value}} ...attributes />
|
|
3
|
+
{{#if @icon}}
|
|
4
|
+
<div class="hds-dropdown-list-item__icon">
|
|
5
|
+
<FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
|
|
6
|
+
</div>
|
|
7
|
+
{{/if}}
|
|
8
|
+
<label class="hds-dropdown-list-item__label hds-typography-body-200" for={{this.id}}>
|
|
9
|
+
{{yield}}
|
|
10
|
+
</label>
|
|
11
|
+
{{#if @count}}
|
|
12
|
+
<span class="hds-dropdown-list-item__count hds-typography-body-100 hds-font-weight-medium">{{@count}}</span>
|
|
13
|
+
{{/if}}
|
|
14
|
+
</li>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { getElementId } from '../../form/utils/getElementId';
|
|
3
|
+
|
|
4
|
+
export default class HdsDropdownListItemCheckboxComponent extends Component {
|
|
5
|
+
/**
|
|
6
|
+
* Determines the unique ID to assign to the checkbox control
|
|
7
|
+
*/
|
|
8
|
+
get id() {
|
|
9
|
+
return getElementId(this);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{{! template-lint-disable require-context-role require-presentational-children }}
|
|
2
|
+
<li class={{this.classNames}}>
|
|
3
|
+
<Hds::Interactive
|
|
4
|
+
@current-when={{@current-when}}
|
|
5
|
+
@models={{hds-link-to-models @model @models}}
|
|
6
|
+
@query={{hds-link-to-query @query}}
|
|
7
|
+
@replace={{@replace}}
|
|
8
|
+
@route={{@route}}
|
|
9
|
+
@isRouteExternal={{@isRouteExternal}}
|
|
10
|
+
@href={{@href}}
|
|
11
|
+
@isHrefExternal={{@isHrefExternal}}
|
|
12
|
+
class="hds-dropdown-list-item__interactive"
|
|
13
|
+
...attributes
|
|
14
|
+
role="option"
|
|
15
|
+
aria-selected={{if @selected "true" "false"}}
|
|
16
|
+
>
|
|
17
|
+
{{#if @icon}}
|
|
18
|
+
<div class="hds-dropdown-list-item__interactive-icon">
|
|
19
|
+
<FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
|
|
20
|
+
</div>
|
|
21
|
+
{{/if}}
|
|
22
|
+
<div class="hds-dropdown-list-item__interactive-text hds-typography-body-200 hds-font-weight-medium">
|
|
23
|
+
{{yield}}
|
|
24
|
+
</div>
|
|
25
|
+
{{#if @count}}
|
|
26
|
+
<span class="hds-dropdown-list-item__count hds-typography-body-100 hds-font-weight-medium">{{@count}}</span>
|
|
27
|
+
{{/if}}
|
|
28
|
+
<span class="hds-dropdown-list-item__checkmark">
|
|
29
|
+
{{#if @selected}}
|
|
30
|
+
<FlightIcon class="hds-dropdown-list-item__checkmark-icon" @name="check" @isInlineBlock={{false}} />
|
|
31
|
+
{{/if}}
|
|
32
|
+
</span>
|
|
33
|
+
</Hds::Interactive>
|
|
34
|
+
</li>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
|
|
3
|
+
export default class HdsDropdownListItemCheckmarkComponent extends Component {
|
|
4
|
+
/**
|
|
5
|
+
* Get the class names to apply to the component.
|
|
6
|
+
* @method classNames
|
|
7
|
+
* @return {string} The "class" attribute to apply to the component.
|
|
8
|
+
*/
|
|
9
|
+
get classNames() {
|
|
10
|
+
let classes = [
|
|
11
|
+
'hds-dropdown-list-item',
|
|
12
|
+
'hds-dropdown-list-item--color-action',
|
|
13
|
+
'hds-dropdown-list-item--variant-checkmark',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
// add a class based on the @selected argument
|
|
17
|
+
if (this.args.selected) {
|
|
18
|
+
classes.push('hds-dropdown-list-item--variant-checkmark-selected');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return classes.join(' ');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -35,7 +35,7 @@ export default class HdsDropdownListItemCopyItemComponent extends Component {
|
|
|
35
35
|
get classNames() {
|
|
36
36
|
let classes = [
|
|
37
37
|
'hds-dropdown-list-item',
|
|
38
|
-
'hds-dropdown-list-item--copy-item',
|
|
38
|
+
'hds-dropdown-list-item--variant-copy-item',
|
|
39
39
|
];
|
|
40
40
|
|
|
41
41
|
return classes.join(' ');
|
|
@@ -31,7 +31,7 @@ export default class HdsDropdownListItemDescriptionComponent extends Component {
|
|
|
31
31
|
get classNames() {
|
|
32
32
|
let classes = [
|
|
33
33
|
'hds-dropdown-list-item',
|
|
34
|
-
'hds-dropdown-list-item--description',
|
|
34
|
+
'hds-dropdown-list-item--variant-description',
|
|
35
35
|
];
|
|
36
36
|
|
|
37
37
|
// add classes for the typographic style
|
|
@@ -53,7 +53,7 @@ export default class HdsDropdownListItemInteractiveComponent extends Component {
|
|
|
53
53
|
get classNames() {
|
|
54
54
|
let classes = [
|
|
55
55
|
'hds-dropdown-list-item',
|
|
56
|
-
'hds-dropdown-list-item--interactive',
|
|
56
|
+
'hds-dropdown-list-item--variant-interactive',
|
|
57
57
|
];
|
|
58
58
|
|
|
59
59
|
// add a class based on the @color argument
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<li class="hds-dropdown-list-item hds-dropdown-list-item--variant-radio">
|
|
2
|
+
<Hds::Form::Radio::Base class="hds-dropdown-list-item__control" id={{this.id}} @value={{@value}} ...attributes />
|
|
3
|
+
{{#if @icon}}
|
|
4
|
+
<div class="hds-dropdown-list-item__icon">
|
|
5
|
+
<FlightIcon @name={{@icon}} @isInlineBlock={{false}} />
|
|
6
|
+
</div>
|
|
7
|
+
{{/if}}
|
|
8
|
+
<label class="hds-dropdown-list-item__label hds-typography-body-200" for={{this.id}}>{{yield}}</label>
|
|
9
|
+
{{#if @count}}
|
|
10
|
+
<span class="hds-dropdown-list-item__count hds-typography-body-100 hds-font-weight-medium">{{@count}}</span>
|
|
11
|
+
{{/if}}
|
|
12
|
+
</li>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { getElementId } from '../../form/utils/getElementId';
|
|
3
|
+
|
|
4
|
+
export default class HdsDropdownListItemRadioComponent extends Component {
|
|
5
|
+
/**
|
|
6
|
+
* Determines the unique ID to assign to the radio control
|
|
7
|
+
*/
|
|
8
|
+
get id() {
|
|
9
|
+
return getElementId(this);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Copyright (c) HashiCorp, Inc.
|
|
3
3
|
SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
}}
|
|
5
|
-
<li class="hds-dropdown-list-item hds-dropdown-list-item--separator" role="separator" ...attributes></li>
|
|
5
|
+
<li class="hds-dropdown-list-item hds-dropdown-list-item--variant-separator" role="separator" ...attributes></li>
|
|
@@ -29,7 +29,10 @@ export default class HdsDropdownListItemTitleComponent extends Component {
|
|
|
29
29
|
* @return {string} The "class" attribute to apply to the component.
|
|
30
30
|
*/
|
|
31
31
|
get classNames() {
|
|
32
|
-
let classes = [
|
|
32
|
+
let classes = [
|
|
33
|
+
'hds-dropdown-list-item',
|
|
34
|
+
'hds-dropdown-list-item--variant-title',
|
|
35
|
+
];
|
|
33
36
|
|
|
34
37
|
// add classes for the typographic style
|
|
35
38
|
classes.push('hds-typography-body-100');
|
|
@@ -2,28 +2,37 @@
|
|
|
2
2
|
Copyright (c) HashiCorp, Inc.
|
|
3
3
|
SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
}}
|
|
5
|
-
|
|
6
|
-
// >>>>>>>>>>> WARNING <<<<<<<<<<
|
|
7
|
-
//
|
|
8
|
-
// Notice: in this component we're directly using the `Hds::Button` component
|
|
9
|
-
// (and adding a specialized class for the "toggle-button" variant, see below)
|
|
10
|
-
// If you need to change the styling of the `Button` component, remember that this will impact also
|
|
11
|
-
// this component too.
|
|
12
|
-
// If instead you need to change only the styling of the `toggle-button` component, you can do it
|
|
13
|
-
// in the CSS file using the specialized class declared there.
|
|
14
|
-
// This is NOT a standard approach that we use in the HDS design system implementation, but it's been
|
|
15
|
-
// the least worst option we could find to solve the problem of sharing the exact same style of the
|
|
16
|
-
// `Button (primary)` with other components.
|
|
17
|
-
}}
|
|
18
|
-
|
|
19
|
-
<Hds::Button
|
|
5
|
+
<button
|
|
20
6
|
class={{this.classNames}}
|
|
21
|
-
@text={{this.text}}
|
|
22
|
-
@icon="chevron-down"
|
|
23
|
-
@iconPosition="trailing"
|
|
24
|
-
@color={{this.color}}
|
|
25
|
-
@size={{@size}}
|
|
26
7
|
...attributes
|
|
8
|
+
type="button"
|
|
27
9
|
aria-expanded={{if @isOpen "true" "false"}}
|
|
28
10
|
{{on "click" this.onClick}}
|
|
29
|
-
|
|
11
|
+
>
|
|
12
|
+
{{#if @icon}}
|
|
13
|
+
<div class="hds-dropdown-toggle-button__icon">
|
|
14
|
+
<FlightIcon @name={{@icon}} @stretched={{true}} />
|
|
15
|
+
</div>
|
|
16
|
+
{{/if}}
|
|
17
|
+
<div class="hds-dropdown-toggle-button__text">
|
|
18
|
+
{{this.text}}
|
|
19
|
+
</div>
|
|
20
|
+
{{#if @count}}
|
|
21
|
+
<Hds::BadgeCount
|
|
22
|
+
@text={{@count}}
|
|
23
|
+
@size="small"
|
|
24
|
+
@type={{this.badgeType}}
|
|
25
|
+
class="hds-dropdown-toggle-button__count"
|
|
26
|
+
/>
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{#if @badge}}
|
|
29
|
+
<Hds::Badge
|
|
30
|
+
@text={{@badge}}
|
|
31
|
+
@icon={{@badgeIcon}}
|
|
32
|
+
@size="small"
|
|
33
|
+
@type={{this.badgeType}}
|
|
34
|
+
class="hds-dropdown-toggle-button__badge"
|
|
35
|
+
/>
|
|
36
|
+
{{/if}}
|
|
37
|
+
<Hds::Dropdown::Toggle::Chevron />
|
|
38
|
+
</button>
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
import Component from '@glimmer/component';
|
|
7
7
|
import { assert } from '@ember/debug';
|
|
8
8
|
|
|
9
|
+
export const DEFAULT_SIZE = 'medium';
|
|
9
10
|
export const DEFAULT_COLOR = 'primary';
|
|
11
|
+
export const SIZES = ['small', 'medium'];
|
|
10
12
|
export const COLORS = ['primary', 'secondary'];
|
|
11
13
|
|
|
12
14
|
const NOOP = () => {};
|
|
@@ -28,6 +30,25 @@ export default class HdsDropdownToggleButtonComponent extends Component {
|
|
|
28
30
|
return text;
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @param size
|
|
35
|
+
* @type {string}
|
|
36
|
+
* @default medium
|
|
37
|
+
* @description The size of the button; acceptable values are `small` and `medium`
|
|
38
|
+
*/
|
|
39
|
+
get size() {
|
|
40
|
+
let { size = DEFAULT_SIZE } = this.args;
|
|
41
|
+
|
|
42
|
+
assert(
|
|
43
|
+
`@size for "Hds::Dropdown::Toggle::Button" must be one of the following: ${SIZES.join(
|
|
44
|
+
', '
|
|
45
|
+
)}; received: ${size}`,
|
|
46
|
+
SIZES.includes(size)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return size;
|
|
50
|
+
}
|
|
51
|
+
|
|
31
52
|
/**
|
|
32
53
|
* @param color
|
|
33
54
|
* @type {string}
|
|
@@ -47,6 +68,16 @@ export default class HdsDropdownToggleButtonComponent extends Component {
|
|
|
47
68
|
return color;
|
|
48
69
|
}
|
|
49
70
|
|
|
71
|
+
/**
|
|
72
|
+
* @param isFullWidth
|
|
73
|
+
* @type {boolean}
|
|
74
|
+
* @default false
|
|
75
|
+
* @description Indicates that a button should take up the full width of the parent container. The default is false.
|
|
76
|
+
*/
|
|
77
|
+
get isFullWidth() {
|
|
78
|
+
return this.args.isFullWidth ?? false;
|
|
79
|
+
}
|
|
80
|
+
|
|
50
81
|
/**
|
|
51
82
|
* @param onClick
|
|
52
83
|
* @type {function}
|
|
@@ -64,6 +95,16 @@ export default class HdsDropdownToggleButtonComponent extends Component {
|
|
|
64
95
|
}
|
|
65
96
|
}
|
|
66
97
|
|
|
98
|
+
/**
|
|
99
|
+
* @param badgeType
|
|
100
|
+
* @type {string}
|
|
101
|
+
* @default 'filled'
|
|
102
|
+
* @description ensures that the correct Badge/BadgeCount type is used to meet contrast requirements
|
|
103
|
+
*/
|
|
104
|
+
get badgeType() {
|
|
105
|
+
return this.color !== 'primary' ? 'inverted' : 'filled';
|
|
106
|
+
}
|
|
107
|
+
|
|
67
108
|
/**
|
|
68
109
|
* Get the class names to apply to the component.
|
|
69
110
|
* @method ToggleButton#classNames
|
|
@@ -72,6 +113,17 @@ export default class HdsDropdownToggleButtonComponent extends Component {
|
|
|
72
113
|
get classNames() {
|
|
73
114
|
let classes = ['hds-dropdown-toggle-button'];
|
|
74
115
|
|
|
116
|
+
// add a class based on the @size argument
|
|
117
|
+
classes.push(`hds-dropdown-toggle-button--size-${this.size}`);
|
|
118
|
+
|
|
119
|
+
// add a class based on the @color argument
|
|
120
|
+
classes.push(`hds-dropdown-toggle-button--color-${this.color}`);
|
|
121
|
+
|
|
122
|
+
// add a class based on the @isFullWidth argument
|
|
123
|
+
if (this.isFullWidth) {
|
|
124
|
+
classes.push('hds-dropdown-toggle-button--width-full');
|
|
125
|
+
}
|
|
126
|
+
|
|
75
127
|
// add a class based on the @isOpen argument
|
|
76
128
|
if (this.args.isOpen) {
|
|
77
129
|
classes.push('hds-dropdown-toggle-button--is-open');
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
{{#if @imageSrc}}
|
|
15
15
|
<img src={{@imageSrc}} alt="" role="presentation" height="32" width="32" />
|
|
16
16
|
{{else if @icon}}
|
|
17
|
-
<FlightIcon @name={{@icon}} @size=
|
|
17
|
+
<FlightIcon @name={{@icon}} @size={{this.iconSize}} />
|
|
18
18
|
{{/if}}
|
|
19
19
|
</div>
|
|
20
20
|
{{#if this.hasChevron}}
|
|
21
|
-
<
|
|
21
|
+
<Hds::Dropdown::Toggle::Chevron />
|
|
22
22
|
{{/if}}
|
|
23
23
|
</button>
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
import Component from '@glimmer/component';
|
|
7
7
|
import { assert } from '@ember/debug';
|
|
8
8
|
|
|
9
|
+
export const DEFAULT_SIZE = 'medium';
|
|
10
|
+
export const SIZES = ['small', 'medium'];
|
|
11
|
+
|
|
9
12
|
const NOOP = () => {};
|
|
13
|
+
|
|
10
14
|
export default class HdsDropdownToggleIconComponent extends Component {
|
|
11
15
|
constructor() {
|
|
12
16
|
super(...arguments);
|
|
@@ -33,6 +37,39 @@ export default class HdsDropdownToggleIconComponent extends Component {
|
|
|
33
37
|
return text;
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
/**
|
|
41
|
+
* @param size
|
|
42
|
+
* @type {string}
|
|
43
|
+
* @default medium
|
|
44
|
+
* @description The size of the button; acceptable values are `small` and `medium`
|
|
45
|
+
*/
|
|
46
|
+
get size() {
|
|
47
|
+
let { size = DEFAULT_SIZE } = this.args;
|
|
48
|
+
|
|
49
|
+
assert(
|
|
50
|
+
`@size for "Hds::Dropdown::Toggle::Icon" must be one of the following: ${SIZES.join(
|
|
51
|
+
', '
|
|
52
|
+
)}; received: ${size}`,
|
|
53
|
+
SIZES.includes(size)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return size;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param iconSize
|
|
61
|
+
* @type {string}
|
|
62
|
+
* @default 24
|
|
63
|
+
* @description ensures that the correct icon size is used
|
|
64
|
+
*/
|
|
65
|
+
get iconSize() {
|
|
66
|
+
if (this.args.size === 'small') {
|
|
67
|
+
return '16';
|
|
68
|
+
} else {
|
|
69
|
+
return '24';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
36
73
|
/**
|
|
37
74
|
* Indicates if a dropdown chevron icon should be displayed; should be displayed unless the "more-horizontal" icon is used.
|
|
38
75
|
*
|
|
@@ -69,6 +106,9 @@ export default class HdsDropdownToggleIconComponent extends Component {
|
|
|
69
106
|
get classNames() {
|
|
70
107
|
let classes = ['hds-dropdown-toggle-icon'];
|
|
71
108
|
|
|
109
|
+
// add a class based on the @size argument
|
|
110
|
+
classes.push(`hds-dropdown-toggle-icon--size-${this.size}`);
|
|
111
|
+
|
|
72
112
|
// add a class based on the @isOpen argument
|
|
73
113
|
if (this.args.isOpen) {
|
|
74
114
|
classes.push('hds-dropdown-toggle-icon--is-open');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/dropdown/footer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/dropdown/header';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item/checkbox';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item/checkmark';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item/radio';
|