@hashicorp/design-system-components 0.11.1 → 0.12.1

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 (38) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/addon/components/hds/alert/index.hbs +1 -3
  3. package/addon/components/hds/breadcrumb/truncation.hbs +1 -0
  4. package/addon/components/hds/button/index.hbs +14 -2
  5. package/addon/components/hds/button/index.js +0 -21
  6. package/addon/components/hds/disclosure/index.hbs +2 -2
  7. package/addon/components/hds/disclosure/index.js +4 -4
  8. package/addon/components/hds/dropdown/index.hbs +2 -2
  9. package/addon/components/hds/dropdown/list-item/copy-item.hbs +1 -5
  10. package/addon/components/hds/dropdown/list-item/interactive.hbs +19 -41
  11. package/addon/components/hds/dropdown/toggle/button.hbs +1 -0
  12. package/addon/components/hds/dropdown/toggle/icon.hbs +8 -1
  13. package/addon/components/hds/interactive/index.hbs +33 -0
  14. package/addon/components/hds/interactive/index.js +33 -0
  15. package/addon/components/hds/link/inline.hbs +23 -0
  16. package/addon/components/hds/link/inline.js +71 -0
  17. package/addon/components/hds/link/standalone.hbs +15 -5
  18. package/addon/components/hds/link/standalone.js +7 -0
  19. package/addon/components/hds/toast/index.hbs +1 -8
  20. package/app/components/hds/{link/cta.js → interactive/index.js} +1 -1
  21. package/app/components/hds/{link-to/cta.js → link/inline.js} +1 -1
  22. package/app/styles/@hashicorp/design-system-components.scss +4 -1
  23. package/app/styles/components/button.scss +44 -19
  24. package/app/styles/components/dropdown.scss +10 -10
  25. package/app/styles/components/link/inline.scss +66 -0
  26. package/app/styles/components/link/standalone.scss +4 -4
  27. package/app/styles/mixins/_focus-ring.scss +8 -4
  28. package/blueprints/hds-component/files/addon/components/hds/__name__/index.hbs +1 -1
  29. package/blueprints/hds-component/index.js +34 -0
  30. package/package.json +4 -3
  31. package/addon/components/hds/link/cta.hbs +0 -50
  32. package/addon/components/hds/link/cta.js +0 -150
  33. package/addon/components/hds/link-to/cta.hbs +0 -51
  34. package/addon/components/hds/link-to/cta.js +0 -165
  35. package/addon/components/hds/link-to/standalone.hbs +0 -25
  36. package/addon/components/hds/link-to/standalone.js +0 -151
  37. package/app/components/hds/link-to/standalone.js +0 -1
  38. package/app/styles/components/link/cta.scss +0 -28
@@ -1,51 +0,0 @@
1
- {{!
2
- // ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
3
- // ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
4
- // ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
5
- // ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
6
- // ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
7
- //
8
- // Notice: in this component we're using directly the styles from the `Hds::Button` component
9
- // using the `hds-button` class names (and adding a specialized class for the "cta", 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 `CTA` 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
- <LinkTo
20
- class={{this.classNames}}
21
- @current-when={{@current-when}}
22
- @models={{hds-link-to-models @model @models}}
23
- @query={{hds-link-to-query @query}}
24
- @replace={{@replace}}
25
- @route={{this.route}}
26
- ...attributes
27
- {{did-insert this.didInsert}}
28
- {{on-key "Space" this.onKeySpace}}
29
- >
30
- {{#if this.icon}}
31
- {{#if (eq this.iconPosition "leading")}}
32
- <div class="hds-button__icon">
33
- <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
34
- </div>
35
- <div class="hds-button__text">
36
- {{this.text}}
37
- </div>
38
- {{else}}
39
- <div class="hds-button__text">
40
- {{this.text}}
41
- </div>
42
- <div class="hds-button__icon">
43
- <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
44
- </div>
45
- {{/if}}
46
- {{else}}
47
- <div class="hds-button__text">
48
- {{this.text}}
49
- </div>
50
- {{/if}}
51
- </LinkTo>
@@ -1,165 +0,0 @@
1
- // ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
2
- // ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
3
- // ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
4
- // ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
5
- // ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
6
- //
7
- // Notice: in this component we're using directly the styles from the `Hds::Button` component
8
- // using the `hds-button` class names (and adding a specialized class for the "cta", see below)
9
- // If you need to change the styling of the `Button` component, remember that this will impact also
10
- // this component too.
11
- // If instead you need to change only the styling of the `CTA` component, you can do it
12
- // in the CSS file using the specialized class declared there.
13
- // This is NOT a standard approach that we use in the HDS design system implementation, but it's been
14
- // the least worst option we could find to solve the problem of sharing the exact same style of the
15
- // `Button (primary)` with other components.
16
-
17
- import Component from '@glimmer/component';
18
- import { assert } from '@ember/debug';
19
- import { action } from '@ember/object';
20
-
21
- export const DEFAULT_SIZE = 'medium';
22
- export const DEFAULT_ICONPOSITION = 'leading';
23
- export const SIZES = ['small', 'medium', 'large'];
24
- export const ICONPOSITIONS = ['leading', 'trailing'];
25
-
26
- export default class HdsLinkToCtaComponent extends Component {
27
- /**
28
- * @param text
29
- * @type {string}
30
- * @description The text of the component. If no text value is defined an error will be thrown.
31
- */
32
- get text() {
33
- let { text } = this.args;
34
-
35
- assert(
36
- '@text for "Hds::LinkTo::Cta" must have a valid value',
37
- text !== undefined
38
- );
39
-
40
- return text;
41
- }
42
-
43
- /**
44
- * @param size
45
- * @type {string}
46
- * @default medium
47
- * @description The size of the component; acceptable values are `small`, `medium`, and `large`
48
- */
49
- get size() {
50
- let { size = DEFAULT_SIZE } = this.args;
51
-
52
- assert(
53
- `@size for "Hds::LinkTo::Cta" must be one of the following: ${SIZES.join(
54
- ', '
55
- )}; received: ${size}`,
56
- SIZES.includes(size)
57
- );
58
-
59
- return size;
60
- }
61
-
62
- /**
63
- * @param icon
64
- * @type {string}
65
- * @default null
66
- * @description The name of the icon to be used.
67
- */
68
- get icon() {
69
- return this.args.icon ?? null;
70
- }
71
-
72
- /**
73
- * @param iconPosition
74
- * @type {string}
75
- * @default leading
76
- * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
77
- */
78
- get iconPosition() {
79
- let { iconPosition = DEFAULT_ICONPOSITION } = this.args;
80
-
81
- assert(
82
- `@iconPosition for "Hds::LinkTo::Cta" must be one of the following: ${ICONPOSITIONS.join(
83
- ', '
84
- )}; received: ${iconPosition}`,
85
- ICONPOSITIONS.includes(iconPosition)
86
- );
87
-
88
- return iconPosition;
89
- }
90
-
91
- /**
92
- * @param iconSize
93
- * @type {string}
94
- * @default 16
95
- * @description ensures that the correct icon size is used. Automatically calculated.
96
- */
97
- get iconSize() {
98
- if (this.args.size === 'large') {
99
- return '24';
100
- } else {
101
- return '16';
102
- }
103
- }
104
-
105
- /**
106
- * @param isFullWidth
107
- * @type {boolean}
108
- * @default false
109
- * @description Indicates that the component should take up the full width of the parent container. The default is false.
110
- */
111
- get isFullWidth() {
112
- return this.args.isFullWidth ?? false;
113
- }
114
-
115
- /**
116
- * @param route
117
- * @type {string|null}
118
- * @description Checks to make sure route is defined.
119
- */
120
- get route() {
121
- let { route } = this.args;
122
- assert(
123
- '@route must be defined for "Hds::LinkTo::Cta"',
124
- route !== undefined
125
- );
126
-
127
- return route;
128
- }
129
-
130
- /**
131
- * Get the class names to apply to the component.
132
- * @method classNames
133
- * @return {string} The "class" attribute to apply to the component.
134
- */
135
- get classNames() {
136
- let classes = [
137
- 'hds-button',
138
- 'hds-button--color-primary',
139
- 'hds-link-cta--inherit-button-styles',
140
- ];
141
-
142
- // add a class based on the @size argument
143
- classes.push(`hds-button--size-${this.size}`);
144
-
145
- // add a class based on the @isFullWidth argument
146
- if (this.isFullWidth) {
147
- classes.push('hds-button--width-full');
148
- }
149
-
150
- return classes.join(' ');
151
- }
152
-
153
- @action
154
- didInsert(el) {
155
- // we need to register the element to compare it with the one that triggered the "key/space" event
156
- this.el = el;
157
- }
158
-
159
- @action
160
- onKeySpace(event) {
161
- if (event.target === this.el) {
162
- event.target.click();
163
- }
164
- }
165
- }
@@ -1,25 +0,0 @@
1
- <LinkTo
2
- class={{this.classNames}}
3
- @current-when={{@current-when}}
4
- @models={{hds-link-to-models @model @models}}
5
- @query={{hds-link-to-query @query}}
6
- @replace={{@replace}}
7
- @route={{this.route}}
8
- ...attributes
9
- >
10
- {{#if (eq this.iconPosition "leading")}}
11
- <div class="hds-link-standalone__icon">
12
- <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
13
- </div>
14
- <div class="hds-link-standalone__text">
15
- {{this.text}}
16
- </div>
17
- {{else}}
18
- <div class="hds-link-standalone__text">
19
- {{this.text}}
20
- </div>
21
- <div class="hds-link-standalone__icon">
22
- <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />
23
- </div>
24
- {{/if}}
25
- </LinkTo>
@@ -1,151 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { assert } from '@ember/debug';
3
-
4
- export const DEFAULT_ICONPOSITION = 'leading';
5
- export const DEFAULT_COLOR = 'primary';
6
- export const DEFAULT_SIZE = 'medium';
7
- export const ICONPOSITIONS = ['leading', 'trailing'];
8
- export const COLORS = ['primary', 'secondary'];
9
- export const SIZES = ['small', 'medium', 'large'];
10
-
11
- export default class HdsLinkToStandaloneComponent extends Component {
12
- /**
13
- * @param text
14
- * @type {string}
15
- * @description The text of the link. If no text value is defined an error will be thrown.
16
- */
17
- get text() {
18
- let { text } = this.args;
19
-
20
- assert(
21
- '@text for "Hds::LinkTo::Standalone" must have a valid value',
22
- text !== undefined
23
- );
24
-
25
- return text;
26
- }
27
-
28
- /**
29
- * @param route
30
- * @type {string|null}
31
- * @description Checks to make sure route is defined.
32
- */
33
- get route() {
34
- let { route } = this.args;
35
- assert(
36
- '@route must be defined for "Hds::LinkTo::Standalone"',
37
- route !== undefined
38
- );
39
-
40
- return route;
41
- }
42
-
43
- /**
44
- * @param color
45
- * @type {string}
46
- * @default primary
47
- * @description Determines the color of link to be used; acceptable values are `primary` and `secondary`
48
- */
49
- get color() {
50
- let { color = DEFAULT_COLOR } = this.args;
51
-
52
- assert(
53
- `@color for "Hds::LinkTo::Standalone" must be one of the following: ${COLORS.join(
54
- ', '
55
- )}; received: ${color}`,
56
- COLORS.includes(color)
57
- );
58
-
59
- return color;
60
- }
61
-
62
- /**
63
- * @param icon
64
- * @type {string|null}
65
- * @default null
66
- * @description The name of the icon to be used. An icon name must be defined.
67
- */
68
- get icon() {
69
- let { icon } = this.args;
70
-
71
- assert(
72
- '@icon for "Hds::LinkTo::Standalone" must have a valid value',
73
- icon !== undefined
74
- );
75
-
76
- return icon;
77
- }
78
-
79
- /**
80
- * @param iconPosition
81
- * @type {string}
82
- * @default leading
83
- * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
84
- */
85
- get iconPosition() {
86
- let { iconPosition = DEFAULT_ICONPOSITION } = this.args;
87
-
88
- assert(
89
- `@iconPosition for "Hds::LinkTo::Standalone" must be one of the following: ${ICONPOSITIONS.join(
90
- ', '
91
- )}; received: ${iconPosition}`,
92
- ICONPOSITIONS.includes(iconPosition)
93
- );
94
-
95
- return iconPosition;
96
- }
97
-
98
- /**
99
- * @param size
100
- * @type {string}
101
- * @default medium
102
- * @description The size of the standalone link; acceptable values are `small`, `medium`, and `large`
103
- */
104
- get size() {
105
- let { size = DEFAULT_SIZE } = this.args;
106
-
107
- assert(
108
- `@size for "Hds::LinkTo::Standalone" must be one of the following: ${SIZES.join(
109
- ', '
110
- )}; received: ${size}`,
111
- SIZES.includes(size)
112
- );
113
-
114
- return size;
115
- }
116
-
117
- /**
118
- * @param iconSize
119
- * @type {string}
120
- * @default 16
121
- * @description ensures that the correct icon size is used. Automatically calculated.
122
- */
123
- get iconSize() {
124
- if (this.args.size === 'large') {
125
- return '24';
126
- } else {
127
- return '16';
128
- }
129
- }
130
-
131
- /**
132
- * Get the class names to apply to the component.
133
- * @method LinkToStandalone#classNames
134
- * @return {string} The "class" attribute to apply to the component.
135
- */
136
- get classNames() {
137
- // Notice: we've left this class name the same as the hds::link::standalone (we didn't add the "-to") so we didn't have to replicate the CSS
138
- let classes = ['hds-link-standalone'];
139
-
140
- // add a class based on the @size argument
141
- classes.push(`hds-link-standalone--size-${this.size}`);
142
-
143
- // add a class based on the @color argument
144
- classes.push(`hds-link-standalone--color-${this.color}`);
145
-
146
- // add a class based on the @iconPosition argument
147
- classes.push(`hds-link-standalone--icon-position-${this.iconPosition}`);
148
-
149
- return classes.join(' ');
150
- }
151
- }
@@ -1 +0,0 @@
1
- export { default } from '@hashicorp/design-system-components/components/hds/link-to/standalone';
@@ -1,28 +0,0 @@
1
- // ██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
2
- // ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
3
- // ██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
4
- // ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
5
- // ███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
6
- //
7
- // Notice: in this component we're using directly the styles from the `Hds::Button` component
8
- // using the `hds-button` class names (and adding a specialized class for the "cta", see below)
9
- // If you need to change the styling of the `Button` component, remember that this will impact also
10
- // this component too.
11
- // If instead you need to change only the styling of the `CTA` component, you can do it here using
12
- // the specialized class declared below.
13
- // This is NOT a standard approach that we use in the HDS design system implementation, but it's been
14
- // the least worst option we could find to solve the problem of sharing the exact same style of the
15
- // `Button (primary)` with other components.
16
-
17
- //
18
- // LINK > CTA COMPONENT
19
- //
20
- // properties within each class are sorted alphabetically
21
- //
22
- //
23
-
24
- .hds-link-cta--inherit-button-styles {
25
- isolation: isolate;
26
- text-decoration: none;
27
- width: fit-content;
28
- }