@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.
- package/CHANGELOG.md +28 -0
- package/NEW-COMPONENT-CHECKLIST.md +20 -11
- package/addon/components/hds/disclosure/index.js +4 -0
- package/addon/components/hds/dropdown/index.hbs +10 -13
- package/addon/components/hds/dropdown/index.js +45 -0
- package/addon/components/hds/dropdown/list-item/copy-item.hbs +20 -0
- package/addon/components/hds/dropdown/list-item/copy-item.js +48 -0
- package/addon/components/hds/dropdown/list-item/description.hbs +3 -0
- package/addon/components/hds/dropdown/list-item/description.js +38 -0
- package/addon/components/hds/dropdown/list-item/generic.hbs +3 -0
- package/addon/components/hds/dropdown/list-item/interactive.hbs +44 -0
- package/addon/components/hds/dropdown/list-item/interactive.js +59 -0
- package/addon/components/hds/dropdown/list-item/separator.hbs +1 -0
- package/addon/components/hds/dropdown/list-item/title.hbs +3 -0
- package/addon/components/hds/dropdown/list-item/title.js +35 -0
- package/addon/components/hds/dropdown/{toggle-button.hbs → toggle/button.hbs} +3 -3
- package/addon/components/hds/dropdown/{toggle-button.js → toggle/button.js} +21 -3
- package/addon/components/hds/dropdown/toggle/icon.hbs +12 -0
- package/addon/components/hds/dropdown/{toggle-icon.js → toggle/icon.js} +28 -13
- package/app/components/hds/dropdown/list-item/copy-item.js +1 -0
- package/app/components/hds/dropdown/list-item/description.js +1 -0
- package/app/components/hds/dropdown/list-item/generic.js +1 -0
- package/app/components/hds/dropdown/list-item/interactive.js +1 -0
- package/app/components/hds/dropdown/list-item/separator.js +1 -0
- package/app/components/hds/dropdown/{toggle-icon.js → list-item/title.js} +1 -1
- package/app/components/hds/dropdown/{toggle-button.js → toggle/button.js} +1 -1
- package/app/components/hds/dropdown/{list-item.js → toggle/icon.js} +1 -1
- package/app/styles/components/breadcrumb.scss +14 -11
- package/app/styles/components/button.scss +36 -30
- package/app/styles/components/dropdown.scss +121 -114
- package/app/styles/components/link/standalone.scss +1 -2
- package/package.json +3 -2
- package/addon/components/hds/dropdown/list-item.hbs +0 -84
- package/addon/components/hds/dropdown/list-item.js +0 -120
- package/addon/components/hds/dropdown/toggle-icon.hbs +0 -22
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
{{#if (eq this.item "title")}}
|
|
2
|
-
<li class={{this.classNames}}>
|
|
3
|
-
{{this.text}}
|
|
4
|
-
</li>
|
|
5
|
-
|
|
6
|
-
{{else if (eq this.item "generic")}}
|
|
7
|
-
<li class={{this.classNames}}>
|
|
8
|
-
{{yield}}
|
|
9
|
-
</li>
|
|
10
|
-
|
|
11
|
-
{{else if (eq this.item "copy-item")}}
|
|
12
|
-
<li class={{this.classNames}}>
|
|
13
|
-
{{#if @copyItemTitle}}
|
|
14
|
-
<div class="hds-dropdown-list-item__copy-item-title">{{@copyItemTitle}}</div>
|
|
15
|
-
{{/if}}
|
|
16
|
-
<button
|
|
17
|
-
type="button"
|
|
18
|
-
class="{{if @state (concat 'is-' @state)}} {{if this.isSuccess 'is-success'}}"
|
|
19
|
-
{{on "click" this.copyCode}}
|
|
20
|
-
>
|
|
21
|
-
<div class="hds-dropdown-list-item__copy-item-text">
|
|
22
|
-
{{this.text}}
|
|
23
|
-
</div>
|
|
24
|
-
<FlightIcon
|
|
25
|
-
@name="{{if this.isSuccess 'clipboard-checked' 'clipboard-copy'}}"
|
|
26
|
-
class="hds-dropdown-list-item__copy-item-icon"
|
|
27
|
-
/>
|
|
28
|
-
</button>
|
|
29
|
-
</li>
|
|
30
|
-
|
|
31
|
-
{{else if (eq this.item "description")}}
|
|
32
|
-
<li class={{this.classNames}}>
|
|
33
|
-
{{this.text}}
|
|
34
|
-
</li>
|
|
35
|
-
|
|
36
|
-
{{else if (eq this.item "separator")}}
|
|
37
|
-
<li class={{this.classNames}} role="separator"></li>
|
|
38
|
-
|
|
39
|
-
{{else if (eq this.item "interactive")}}
|
|
40
|
-
<li class={{this.classNames}}>
|
|
41
|
-
{{#if @route}}
|
|
42
|
-
<LinkTo
|
|
43
|
-
class="{{if @state (concat 'is-' @state)}}"
|
|
44
|
-
@current-when={{@current-when}}
|
|
45
|
-
@models={{hds-link-to-models @model @models}}
|
|
46
|
-
@query={{hds-link-to-query @query}}
|
|
47
|
-
@replace={{@replace}}
|
|
48
|
-
@route={{@route}}
|
|
49
|
-
...attributes
|
|
50
|
-
>
|
|
51
|
-
{{#if @icon}}
|
|
52
|
-
<div class="hds-dropdown-list-item__interactive-icon">
|
|
53
|
-
<FlightIcon @name={{this.icon}} @isInlineBlock={{false}} />
|
|
54
|
-
</div>
|
|
55
|
-
{{/if}}
|
|
56
|
-
<div class="hds-dropdown-list-item__interactive-text">
|
|
57
|
-
{{this.text}}
|
|
58
|
-
</div>
|
|
59
|
-
</LinkTo>
|
|
60
|
-
{{else if @href}}
|
|
61
|
-
<a target="_blank" rel="noopener noreferrer" href={{@href}} class="{{if @state (concat 'is-' @state)}}">
|
|
62
|
-
{{#if this.icon}}
|
|
63
|
-
<div class="hds-dropdown-list-item__interactive-icon">
|
|
64
|
-
<FlightIcon @name={{this.icon}} @isInlineBlock={{false}} />
|
|
65
|
-
</div>
|
|
66
|
-
{{/if}}
|
|
67
|
-
<div class="hds-dropdown-list-item__interactive-text">
|
|
68
|
-
{{this.text}}
|
|
69
|
-
</div>
|
|
70
|
-
</a>
|
|
71
|
-
{{else}}
|
|
72
|
-
<button class="{{if @state (concat 'is-' @state)}}" type="button" ...attributes>
|
|
73
|
-
{{#if this.icon}}
|
|
74
|
-
<div class="hds-dropdown-list-item__interactive-icon">
|
|
75
|
-
<FlightIcon @name={{this.icon}} @isInlineBlock={{false}} />
|
|
76
|
-
</div>
|
|
77
|
-
{{/if}}
|
|
78
|
-
<div class="hds-dropdown-list-item__interactive-text">
|
|
79
|
-
{{this.text}}
|
|
80
|
-
</div>
|
|
81
|
-
</button>
|
|
82
|
-
{{/if}}
|
|
83
|
-
</li>
|
|
84
|
-
{{/if}}
|
|
@@ -1,120 +0,0 @@
|
|
|
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 const DEFAULT_COLOR = 'action';
|
|
7
|
-
export const DEFAULT_ITEM = 'interactive';
|
|
8
|
-
export const COLORS = ['action', 'critical'];
|
|
9
|
-
export const ITEMS = [
|
|
10
|
-
'copy-item',
|
|
11
|
-
'description',
|
|
12
|
-
'generic',
|
|
13
|
-
'interactive',
|
|
14
|
-
'separator',
|
|
15
|
-
'title',
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
export default class HdsDropdownListItemComponent extends Component {
|
|
19
|
-
@tracked isSuccess = this.args.isSuccess ?? false;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @param item
|
|
23
|
-
* @type {string}
|
|
24
|
-
* @default interactive
|
|
25
|
-
* @description Determines the type of item to show
|
|
26
|
-
*/
|
|
27
|
-
get item() {
|
|
28
|
-
let { item = DEFAULT_ITEM } = this.args;
|
|
29
|
-
|
|
30
|
-
assert(
|
|
31
|
-
`@item for "Hds::Dropdown::ListItem" must be one of the following: ${ITEMS.join(
|
|
32
|
-
', '
|
|
33
|
-
)}; received: ${item}`,
|
|
34
|
-
ITEMS.includes(item)
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
return item;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @param text
|
|
42
|
-
* @type {string}
|
|
43
|
-
* @description The text of the item. If no text value is defined an error will be thrown unless it is the generic or separator item type.
|
|
44
|
-
*/
|
|
45
|
-
get text() {
|
|
46
|
-
let { text } = this.args;
|
|
47
|
-
|
|
48
|
-
assert(
|
|
49
|
-
'@text for "Hds::Dropdown::ListItem" must have a valid value',
|
|
50
|
-
text !== undefined
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
return text;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @param color
|
|
58
|
-
* @type {string}
|
|
59
|
-
* @default primary
|
|
60
|
-
* @description Determines the color of the item (when item is set to interactive)
|
|
61
|
-
*/
|
|
62
|
-
get color() {
|
|
63
|
-
let { color = DEFAULT_COLOR } = this.args;
|
|
64
|
-
|
|
65
|
-
assert(
|
|
66
|
-
`@color for "Hds::Dropdown::ListItem" must be one of the following: ${COLORS.join(
|
|
67
|
-
', '
|
|
68
|
-
)}; received: ${color}`,
|
|
69
|
-
COLORS.includes(color)
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
return color;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @param icon
|
|
77
|
-
* @type {string}
|
|
78
|
-
* @default null
|
|
79
|
-
* @description The name of the icon to be used.
|
|
80
|
-
*/
|
|
81
|
-
get icon() {
|
|
82
|
-
assert(
|
|
83
|
-
`when the "Hds::ListItem" @color is "critical" an @icon is required`,
|
|
84
|
-
!(this.color === 'critical' && !this.args.icon)
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
return this.args.icon ?? null;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Get the class names to apply to the component.
|
|
92
|
-
* @method classNames
|
|
93
|
-
* @return {string} The "class" attribute to apply to the component.
|
|
94
|
-
*/
|
|
95
|
-
get classNames() {
|
|
96
|
-
let classes = ['hds-dropdown-list-item'];
|
|
97
|
-
|
|
98
|
-
// add a class based on the @item argument
|
|
99
|
-
if (this.item) {
|
|
100
|
-
classes.push(`hds-dropdown-list-item--${this.item}`);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// add a class based on the @color argument
|
|
104
|
-
if (this.item === 'interactive') {
|
|
105
|
-
classes.push(`hds-dropdown-list-item--color-${this.color}`);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return classes.join(' ');
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
@action
|
|
112
|
-
copyCode() {
|
|
113
|
-
navigator.clipboard.writeText(this.args.text);
|
|
114
|
-
// this if statement resolves to [object Promise] so maybe some improvements
|
|
115
|
-
// could be made here
|
|
116
|
-
if (navigator.clipboard.readText()) {
|
|
117
|
-
this.isSuccess = true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<button
|
|
2
|
-
class="hds-dropdown-toggle-icon"
|
|
3
|
-
aria-label={{this.text}}
|
|
4
|
-
...attributes
|
|
5
|
-
{{on "click" this.onClick}}
|
|
6
|
-
type="button"
|
|
7
|
-
>
|
|
8
|
-
<div class="hds-dropdown-toggle-icon__wrapper">
|
|
9
|
-
{{#if @imageSrc}}
|
|
10
|
-
<img src={{@imageSrc}} alt="" role="presentation" height="32" width="32" />
|
|
11
|
-
{{else}}
|
|
12
|
-
<FlightIcon @name={{this.icon}} @size="24" />
|
|
13
|
-
{{/if}}
|
|
14
|
-
</div>
|
|
15
|
-
{{#if this.hasChevron}}
|
|
16
|
-
<FlightIcon
|
|
17
|
-
@name="chevron-{{if @isOpen 'up' 'down'}}"
|
|
18
|
-
class="hds-dropdown-toggle-icon__chevron"
|
|
19
|
-
@isInlineBlock={{false}}
|
|
20
|
-
/>
|
|
21
|
-
{{/if}}
|
|
22
|
-
</button>
|