@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.
Files changed (34) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/addon/components/hds/dropdown/footer.hbs +3 -0
  3. package/addon/components/hds/dropdown/header.hbs +3 -0
  4. package/addon/components/hds/dropdown/index.hbs +20 -13
  5. package/addon/components/hds/dropdown/index.js +27 -10
  6. package/addon/components/hds/dropdown/list-item/checkbox.hbs +14 -0
  7. package/addon/components/hds/dropdown/list-item/checkbox.js +11 -0
  8. package/addon/components/hds/dropdown/list-item/checkmark.hbs +34 -0
  9. package/addon/components/hds/dropdown/list-item/checkmark.js +23 -0
  10. package/addon/components/hds/dropdown/list-item/copy-item.js +1 -1
  11. package/addon/components/hds/dropdown/list-item/description.js +1 -1
  12. package/addon/components/hds/dropdown/list-item/generic.hbs +1 -1
  13. package/addon/components/hds/dropdown/list-item/interactive.js +1 -1
  14. package/addon/components/hds/dropdown/list-item/radio.hbs +12 -0
  15. package/addon/components/hds/dropdown/list-item/radio.js +11 -0
  16. package/addon/components/hds/dropdown/list-item/separator.hbs +1 -1
  17. package/addon/components/hds/dropdown/list-item/title.js +4 -1
  18. package/addon/components/hds/dropdown/toggle/button.hbs +30 -21
  19. package/addon/components/hds/dropdown/toggle/button.js +52 -0
  20. package/addon/components/hds/dropdown/toggle/chevron.hbs +3 -0
  21. package/addon/components/hds/dropdown/toggle/icon.hbs +2 -2
  22. package/addon/components/hds/dropdown/toggle/icon.js +40 -0
  23. package/app/components/hds/dropdown/footer.js +1 -0
  24. package/app/components/hds/dropdown/header.js +1 -0
  25. package/app/components/hds/dropdown/list-item/checkbox.js +1 -0
  26. package/app/components/hds/dropdown/list-item/checkmark.js +1 -0
  27. package/app/components/hds/dropdown/list-item/radio.js +1 -0
  28. package/app/components/hds/dropdown/toggle/chevron.js +6 -0
  29. package/app/styles/components/button.scss +9 -254
  30. package/app/styles/components/dropdown.scss +260 -65
  31. package/app/styles/mixins/_button.scss +280 -0
  32. package/blueprints/hds-component-test/index.js +4 -2
  33. package/package.json +1 -1
  34. /package/blueprints/hds-component-test/files/tests/dummy/app/styles/{pages → showcase-pages}/__dummyCSSFileName__.scss +0 -0
@@ -9,25 +9,10 @@
9
9
  // notice: pseudo-classes for the states *must* follow the order link > visited > hover > focus > active
10
10
  //
11
11
 
12
- $hds-button-sizes: ( "small", "medium", "large" );
13
- $hds-button-border-radius: 5px;
14
- $hds-button-border-width: 1px;
15
- $hds-button-focus-border-width: 3px;
16
-
12
+ @use "../mixins/button" as *;
17
13
 
18
14
  .hds-button {
19
- position: relative;
20
- display: flex;
21
- align-items: center;
22
- justify-content: center;
23
- width: auto;
24
- font-family: var(--token-typography-font-stack-text);
25
- text-decoration: none;
26
- border: $hds-button-border-width solid transparent; // We need this to be transparent for a11y
27
- border-radius: $hds-button-border-radius;
28
- outline-style: solid; // used to avoid double outline+focus-ring in Safari (see https://github.com/hashicorp/design-system-components/issues/161#issuecomment-1031548656)
29
- outline-color: transparent; // We need this to be transparent for a11y
30
- isolation: isolate;
15
+ @include hds-button();
31
16
 
32
17
  // the <a> element behaves differently than a <button>
33
18
  @at-root a#{&} {
@@ -59,15 +44,7 @@ $hds-button-focus-border-width: 3px;
59
44
  &:disabled:hover,
60
45
  &[disabled]:hover,
61
46
  &.mock-disabled:hover {
62
- color: var(--token-color-foreground-disabled);
63
- background-color: var(--token-color-surface-faint);
64
- border-color: var(--token-color-border-primary);
65
- box-shadow: none;
66
- cursor: not-allowed;
67
-
68
- &::before {
69
- border-color: transparent;
70
- }
47
+ @include hds-button-state-disabled();
71
48
  }
72
49
 
73
50
  &.hds-button--width-full {
@@ -81,22 +58,7 @@ $hds-button-focus-border-width: 3px;
81
58
 
82
59
  &:focus,
83
60
  &.mock-focus {
84
- box-shadow: none;
85
-
86
- &::before {
87
- // the position absolute of an element is computed from the inside of the border of the container
88
- // so we have to take in account the border width of the pseudo-element container itself
89
- $shift: $hds-button-border-width + $hds-button-focus-border-width;
90
- position: absolute;
91
- top: -$shift;
92
- right: -$shift;
93
- bottom: -$shift;
94
- left: -$shift;
95
- z-index: -1;
96
- border: $hds-button-focus-border-width solid transparent;
97
- border-radius: $hds-button-border-radius + $hds-button-focus-border-width;
98
- content: "";
99
- }
61
+ @include hds-button-state-focus();
100
62
  }
101
63
  }
102
64
 
@@ -114,232 +76,25 @@ $hds-button-focus-border-width: 3px;
114
76
 
115
77
 
116
78
  // SIZE
117
-
118
- // these values later may come from the design tokens
119
- $size-props: (
120
- "small": (
121
- "font-size": 0.8125rem, // 13px;
122
- "line-height": 0.875rem, // 14px - we need to make it even (so we set it slighly larger than the font-size; notice: in Figma is 12px but this would cut some ascendants/descendants)
123
- "min-height": 1.75rem, // 28px
124
- "padding": 0.375rem 0.6875rem, // 6px 11px - here we're taking into account the 1px border
125
- "icon-size": 0.75rem, // 12px
126
- ),
127
- "medium": (
128
- "font-size": 0.875rem, // 14px
129
- "line-height": 1rem,// 16px
130
- "min-height": 2.25rem, // 36px
131
- "padding": 0.5625rem 0.9375rem, // 9px 15px - here we're taking into account the 1px border
132
- "icon-size": 1rem, // 16px
133
- ),
134
- "large": (
135
- "font-size": 1rem, // 16px
136
- "line-height": 1.5rem, // 24px
137
- "min-height": 3rem, // 48px
138
- "padding": 0.6875rem 1.1875rem, // 11px 19px - here we're taking into account the 1px border
139
- "icon-size": 1.5rem, // 24px
140
- )
141
- );
142
-
143
- @each $size in $hds-button-sizes {
144
- .hds-button--size-#{$size} {
145
- min-height: map-get($size-props, $size, "min-height");
146
- padding: map-get($size-props, $size, "padding");
147
-
148
- .hds-button__icon {
149
- width: map-get($size-props, $size, "icon-size");
150
- height: map-get($size-props, $size, "icon-size");
151
- }
152
-
153
- .hds-button__text {
154
- font-size: map-get($size-props, $size, "font-size");
155
- line-height: map-get($size-props, $size, "line-height");
156
- }
157
- }
158
- }
159
-
79
+ @include hds-button-size-classes("hds-button");
160
80
 
161
81
  // COLORS & STATES
162
82
  // Note: the order of the pseuo-selectors need to stay the way they are; it doesn't match the Figma file but it's the correct order for browsers to render the styles correctly.
163
83
 
164
84
  .hds-button--color-primary {
165
- color: var(--token-color-foreground-high-contrast);
166
- background-color: var(--token-color-palette-blue-200);
167
- border-color: var(--token-color-palette-blue-300);
168
- box-shadow: var(--token-elevation-low-box-shadow);
169
-
170
- &:hover,
171
- &.mock-hover {
172
- color: var(--token-color-foreground-high-contrast);
173
- background-color: var(--token-color-palette-blue-300);
174
- border-color: var(--token-color-palette-blue-400);
175
- cursor: pointer;
176
- }
177
-
178
- &:focus,
179
- &.mock-focus {
180
- color: var(--token-color-foreground-high-contrast);
181
- background-color: var(--token-color-palette-blue-200);
182
- border-color: var(--token-color-focus-action-internal);
183
-
184
- &::before {
185
- // the position absolute of an element is computed from the inside of the border of the container
186
- // so we have to take in account the border width of the pseudo-element container itself
187
- // plus for the primary button we want to have a 2px gap between the button and the focus
188
- $shift: $hds-button-border-width + $hds-button-focus-border-width + 2px;
189
- top: -$shift;
190
- right: -$shift;
191
- bottom: -$shift;
192
- left: -$shift;
193
- border-color: var(--token-color-focus-action-external);
194
- border-radius: $hds-button-border-radius + $hds-button-focus-border-width + 2px;
195
- }
196
- }
197
-
198
- &:active,
199
- &.mock-active {
200
- color: var(--token-color-foreground-high-contrast);
201
- background-color: var(--token-color-palette-blue-400);
202
- border-color: var(--token-color-palette-blue-400);
203
- box-shadow: none;
204
-
205
- &::before {
206
- border-color: transparent;
207
- }
208
- }
85
+ @include hds-button-color-primary();
209
86
  }
210
87
 
211
88
  .hds-button--color-secondary {
212
- color: var(--token-color-foreground-primary);
213
- background-color: var(--token-color-surface-faint);
214
- border-color: var(--token-color-border-strong);
215
- box-shadow: var(--token-elevation-low-box-shadow);
216
-
217
- &:hover,
218
- &.mock-hover {
219
- color: var(--token-color-foreground-primary);
220
- background-color: var(--token-color-surface-primary);
221
- border-color: var(--token-color-border-strong);
222
- cursor: pointer;
223
- }
224
-
225
- &:focus,
226
- &.mock-focus {
227
- color: var(--token-color-foreground-primary);
228
- background-color: var(--token-color-surface-faint);
229
- border-color: var(--token-color-focus-action-internal);
230
-
231
- &::before {
232
- border-color: var(--token-color-focus-action-external);
233
- }
234
- }
235
-
236
- &:active,
237
- &.mock-active {
238
- color: var(--token-color-foreground-primary);
239
- background-color: var(--token-color-surface-interactive-active);
240
- border-color: var(--token-color-border-strong);
241
- box-shadow: none;
242
-
243
- &::before {
244
- border-color: transparent;
245
- }
246
- }
89
+ @include hds-button-color-secondary();
247
90
  }
248
91
 
249
92
  .hds-button--color-tertiary {
250
- color: var(--token-color-foreground-action);
251
- background-color: transparent;
252
- border-color: transparent;
253
-
254
- &:hover,
255
- &.mock-hover {
256
- color: var(--token-color-foreground-action-hover);
257
- background-color: var(--token-color-surface-primary);
258
- border-color: var(--token-color-border-strong);
259
- cursor: pointer;
260
- }
261
-
262
- &:focus,
263
- &.mock-focus {
264
- color: var(--token-color-foreground-action);
265
- border-color: var(--token-color-focus-action-internal);
266
-
267
- &::before {
268
- border-color: var(--token-color-focus-action-external);
269
- }
270
- }
271
-
272
- &:active,
273
- &.mock-active {
274
- color: var(--token-color-foreground-action-active);
275
- background-color: var(--token-color-surface-interactive-active);
276
- border-color: var(--token-color-border-strong);
277
- box-shadow: none;
278
-
279
- &::before {
280
- border-color: transparent;
281
- }
282
- }
283
-
284
- //
285
- // IMPORTANT: we need to use also the [disabled] selector because if the "disabled" attribute is applied to a "Button as link",
286
- // the ":disabled" pseudo-selector is not applied to the element in the browser (rightly) because a link can't be disabled
287
- // but from the product perspective there may be use cases where they need to have a "Button as link" that looks disabled anyway
288
- //
289
- &:disabled,
290
- &[disabled],
291
- &.mock-disabled,
292
- &:disabled:focus,
293
- &[disabled]:focus,
294
- &.mock-disabled:focus,
295
- &:disabled:hover,
296
- &[disabled]:hover,
297
- &.mock-disabled:hover {
298
- background-color: transparent;
299
- border-color: transparent;
300
-
301
- &::before {
302
- border-color: transparent;
303
- }
304
- }
93
+ @include hds-button-color-tertiary();
305
94
  }
306
95
 
307
96
  .hds-button--color-critical {
308
- color: var(--token-color-foreground-critical-on-surface);
309
- background-color: var(--token-color-surface-critical);
310
- border-color: var(--token-color-foreground-critical-on-surface);
311
- box-shadow: var(--token-elevation-low-box-shadow);
312
-
313
- &:hover,
314
- &.mock-hover {
315
- color: var(--token-color-foreground-high-contrast);
316
- background-color: var(--token-color-palette-red-300);
317
- border-color: var(--token-color-palette-red-400);
318
- cursor: pointer;
319
- }
320
-
321
- &:focus,
322
- &.mock-focus {
323
- color: var(--token-color-foreground-critical-on-surface);
324
- background-color: var(--token-color-surface-critical);
325
- border-color: var(--token-color-focus-critical-internal);
326
-
327
- &::before {
328
- border-color: var(--token-color-focus-critical-external);
329
- }
330
- }
331
-
332
- &:active,
333
- &.mock-active {
334
- color: var(--token-color-foreground-high-contrast);
335
- background-color: var(--token-color-palette-red-400);
336
- border-color: var(--token-color-palette-red-400);
337
- box-shadow: none;
338
-
339
- &::before {
340
- border-color: transparent;
341
- }
342
- }
97
+ @include hds-button-color-critical();
343
98
  }
344
99
 
345
100