@hashicorp/design-system-components 0.0.14 → 0.0.15

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.
@@ -127,6 +127,9 @@ export default class HdsLinkStandaloneComponent extends Component {
127
127
  // add a class based on the @color argument
128
128
  classes.push(`hds-link-standalone--color-${this.color}`);
129
129
 
130
+ // add a class based on the @iconPosition argument
131
+ classes.push(`hds-link-standalone--icon-position-${this.iconPosition}`);
132
+
130
133
  return classes.join(' ');
131
134
  }
132
135
  }
@@ -153,6 +153,9 @@ export default class HdsLinkToStandaloneComponent extends Component {
153
153
  // add a class based on the @color argument
154
154
  classes.push(`hds-link-standalone--color-${this.color}`);
155
155
 
156
+ // add a class based on the @iconPosition argument
157
+ classes.push(`hds-link-standalone--icon-position-${this.iconPosition}`);
158
+
156
159
  return classes.join(' ');
157
160
  }
158
161
  }
@@ -1,10 +1,18 @@
1
- // Button Component Styles
1
+ //
2
+ // BUTTON COMPONENT
3
+ //
4
+ // properties within each class are sorted alphabetically
5
+ // notice: pseudo-classes for the states *must* follow the order link > visited > focus > hover > active
6
+ // see https://github.com/hashicorp/design-system-components/issues/132
7
+ //
8
+ //
9
+
10
+ $hds-button-sizes: ( 'small', 'medium', 'large' );
2
11
 
3
12
  $hds-button-border-radius: 5px;
4
13
  $hds-button-border-width: 1px;
5
14
  $hds-button-focus-border-width: 3px;
6
15
 
7
- $hds-button-sizes: ( 'small', 'medium', 'large' );
8
16
 
9
17
  .hds-button {
10
18
  align-items: center;
@@ -23,15 +31,15 @@ $hds-button-sizes: ( 'small', 'medium', 'large' );
23
31
  &:disabled,
24
32
  &[disabled],
25
33
  &.is-disabled,
26
- &:disabled:hover,
27
- &[disabled]:hover,
28
- &.is-disabled:hover,
29
34
  &:disabled:focus,
30
35
  &[disabled]:focus,
31
36
  &.is-disabled:focus,
32
37
  &:disabled:focus-visible,
33
38
  &[disabled]:focus-visible,
34
- &.is-disabled:focus-visible {
39
+ &.is-disabled:focus-visible,
40
+ &:disabled:hover,
41
+ &[disabled]:hover,
42
+ &.is-disabled:hover {
35
43
  background-color: var(--token-color-palette-neutral-50);
36
44
  border-color: var(--token-color-palette-alpha-200);
37
45
  box-shadow: none;
@@ -53,11 +61,12 @@ $hds-button-sizes: ( 'small', 'medium', 'large' );
53
61
  }
54
62
  }
55
63
 
56
- &.is-focus,
57
64
  &:focus,
58
- &:focus-visible {
65
+ &:focus-visible,
66
+ &.is-focus {
59
67
  &::before {
60
- // the position absolute is computed from the inside of the border, so we have to take in account the border width
68
+ // the position absolute of an element is computed from the inside of the border of the container
69
+ // so we have to take in account the border width of the pseudo-element container itself
61
70
  $shift: $hds-button-border-width + $hds-button-focus-border-width;
62
71
  border-radius: $hds-button-border-radius + $hds-button-focus-border-width;
63
72
  border: $hds-button-focus-border-width solid transparent;
@@ -68,15 +77,18 @@ $hds-button-sizes: ( 'small', 'medium', 'large' );
68
77
  position: absolute;
69
78
  right: -$shift;
70
79
  top: -$shift;
80
+ z-index: -1;
71
81
  }
72
82
  }
73
83
  }
74
84
 
75
85
  .hds-button__text {
76
86
  flex: 1 0 0;
87
+
77
88
  .hds-button__icon + & {
78
89
  margin-left: 0.375rem;
79
90
  }
91
+
80
92
  & +.hds-button__icon {
81
93
  margin-left: 0.375rem;
82
94
  }
@@ -112,15 +124,18 @@ $size-props: (
112
124
 
113
125
  @each $size in $hds-button-sizes {
114
126
  .hds-button--size-#{$size} {
115
- font-size: map-get($size-props, $size, "font-size");
116
127
  min-height: map-get($size-props, $size, "min-height");
117
- line-height: map-get($size-props, $size, "line-height");
118
128
  padding: map-get($size-props, $size, "padding");
119
129
 
120
130
  .hds-button__icon {
121
131
  height: map-get($size-props, $size, "icon-size");
122
132
  width: map-get($size-props, $size, "icon-size");
123
133
  }
134
+
135
+ .hds-button__text {
136
+ font-size: map-get($size-props, $size, "font-size");
137
+ line-height: map-get($size-props, $size, "line-height");
138
+ }
124
139
  }
125
140
  }
126
141
 
@@ -140,7 +155,8 @@ $size-props: (
140
155
  border-color: var(--token-color-action-border-on-primary);
141
156
  color: var(--token-color-palette-neutral-0);
142
157
  &::before {
143
- // the position absolute is computed from the inside of the border, so we have to take in account the border width
158
+ // the position absolute of an element is computed from the inside of the border of the container
159
+ // so we have to take in account the border width of the pseudo-element container itself
144
160
  // plus for the primary button we want to have a 2px gap between the button and the focus
145
161
  $shift: $hds-button-border-width + $hds-button-focus-border-width + 2px;
146
162
  border-radius: $hds-button-border-radius + $hds-button-focus-border-width + 2px;
@@ -193,7 +209,7 @@ $size-props: (
193
209
  color: var(--token-color-palette-neutral-600);
194
210
  cursor: pointer;
195
211
  }
196
- &:active,
212
+ &:active,
197
213
  &.is-active {
198
214
  background-color: var(--token-color-palette-neutral-200);
199
215
  border-color: var(--token-color-palette-alpha-300);
@@ -228,7 +244,7 @@ $size-props: (
228
244
  color: var(--token-color-palette-neutral-0);
229
245
  cursor: pointer;
230
246
  }
231
-
247
+
232
248
  &:active,
233
249
  &.is-active {
234
250
  background-color: var(--token-color-critical-background-active);
@@ -1,36 +1,90 @@
1
- $hds-link-standalone-border-radius: 5px;
1
+ //
2
+ // LINK > STANDALONE COMPONENT
3
+ //
4
+ // properties within each class are sorted alphabetically
5
+ // notice: pseudo-classes for the states *must* follow the order link > visited > focus > hover > active
6
+ // see https://github.com/hashicorp/design-system-components/issues/132
7
+ //
8
+ //
9
+
10
+ @use '../../mixins/generic-focus-state.scss' as *;
11
+
2
12
  $hds-link-standalone-sizes: ( 'small', 'medium', 'large' );
3
- $hds-link-standalone-border-width: 1px;
4
- $hds-link-standalone-focus-border-width: 3px + $hds-link-standalone-border-width;
5
13
 
14
+ $hds-link-standalone-focus-border-radius: 5px;
15
+ $hds-link-standalone-border-width: 1px;
6
16
 
7
17
  .hds-link-standalone {
8
18
  align-items: center;
9
- background-color: transparent;
19
+ background-color: transparent; // needs to exist for a11y
10
20
  border: $hds-link-standalone-border-width solid transparent; // needs to exist AND be transparent for a11y
11
- border-radius: $hds-link-standalone-border-radius;
12
21
  color: var(--token-color-action-foreground-on-faint);
13
22
  display: flex;
14
23
  font-family: var(--token-typography-body-base-font-family);
15
24
  justify-content: center;
16
25
  outline-color: transparent;
17
- padding: 0.25rem; // should be 4px; iconPosition will override it on one side
18
26
  position: relative;
19
- text-decoration: none;
27
+ text-decoration: underline;
28
+ text-decoration-color: transparent;
20
29
  width: fit-content;
30
+
31
+ // this is how much the focus is visually "shifted" from the bounding box of the
32
+ // notice: you have to take in account also the inset shadow of the focus (see Figma file and also "generic-focus-state" mixin)
33
+ $hds-link-standalone-focus-shift: 4px;
34
+ // the position absolute of an element is computed from the inside of the border of the container
35
+ // so we have to take in account the border width of the pseudo-element container itself
36
+ $shift: $hds-link-standalone-focus-shift + $hds-link-standalone-border-width;
37
+ // for visual/optical balance we add an extra 2px to the "shift" near the text (opposite the icon)
38
+ $shift-extra: $shift + 2px;
39
+
40
+ // this is used not only for the focus, but also to increase the clickable area
41
+ &::before {
42
+ border-radius: $hds-link-standalone-focus-border-radius;
43
+ bottom: -$shift;
44
+ box-sizing: border-box;
45
+ content: '';
46
+ left: -$shift;
47
+ position: absolute;
48
+ right: -$shift;
49
+ top: -$shift;
50
+ z-index: -1;
51
+ }
52
+
53
+ &.hds-link-standalone--icon-position-leading::before {
54
+ right: -$shift-extra;
55
+ }
56
+
57
+ &.hds-link-standalone--icon-position-trailing::before {
58
+ left: -$shift-extra;
59
+ }
60
+ }
61
+
62
+ .hds-link-standalone__text {
63
+ flex: 1 0 0;
64
+
65
+ .hds-link-standalone__icon + & {
66
+ margin-left: 0.375rem;
67
+ }
68
+
69
+ & +.hds-link-standalone__icon {
70
+ margin-left: 0.375rem;
71
+ }
21
72
  }
22
73
 
74
+
75
+ // SIZE
76
+
23
77
  // these values later may come from the design tokens
24
78
  $size-props: (
25
79
  "small": (
26
80
  "font-size": 0.8125rem, // 13px;
27
- "icon-size": 0.75rem, // 12px
28
- "line-height": 0.75,
81
+ "icon-size": 1rem, // 16px
82
+ "line-height": 1.231, // ~16px
29
83
  ),
30
84
  "medium": (
31
85
  "font-size": 0.875rem, // 14px
32
86
  "icon-size": 1rem, // 16px
33
- "line-height": 1, // 16px
87
+ "line-height": 1.143, // ~16px
34
88
  ),
35
89
  "large": (
36
90
  "font-size": 1rem, // 16px
@@ -51,76 +105,63 @@ $size-props: (
51
105
  font-size: map-get($size-props, $size, "font-size");
52
106
  line-height: map-get($size-props, $size, "line-height");
53
107
  }
54
-
55
- }
56
- }
57
-
58
- .hds-link-standalone__text {
59
- flex: 1 0 0;
60
- .hds-link-standalone__icon + & {
61
- margin-left: 0.375rem;
62
- }
63
- & +.hds-link-standalone__icon {
64
- margin-left: 0.375rem;
65
108
  }
66
109
  }
67
110
 
68
111
  // COLORS & STATES
112
+ // The "primary" and "secondary" variants share a lot of styles for the interactive states
69
113
  // Note: the order of the pseuo-selectors need to stay the way they are
70
114
 
71
- .hds-link-standalone--color-primary {
72
- color: var(--token-color-action-foreground-on-faint);
73
-
74
- &:visited {
75
- color: var(--token-color-action-foreground-on-faint);
115
+ .hds-link-standalone {
116
+ &:focus,
117
+ &:focus-visible,
118
+ &.is-focus {
119
+ &::before {
120
+ @include hds-generic-focus-state();
121
+ }
76
122
  }
77
123
  &:hover,
78
124
  &.is-hover {
79
- text-decoration-color: #4E81E8;
80
125
  text-decoration: underline;
81
126
  transition: text-decoration-color 0.25s ease-in;
82
- }
83
- &:focus,
84
- &:focus-visible,
85
- &.is-focus {
86
- outline: 2px solid transparent;
87
- box-shadow:
88
- 0 0 0 $hds-link-standalone-border-width var(--token-color-action-border-on-primary),
89
- 0 0 0 $hds-link-standalone-focus-border-width #5990FF;
127
+ // TODO!
128
+ // discuss with Heather if she wants that we add calculation for text-decoration offset
90
129
  }
91
130
  &:active,
92
131
  &.is-active {
93
- color: var(--token-color-action-foreground-high-contrast);
94
132
  text-decoration: underline;
95
- text-decoration-color: #596987;
133
+
134
+ // remove the focus ring on "active + focused" state (by design)
96
135
  &::before {
97
- border-color: transparent;
136
+ content: none;
98
137
  }
99
138
  }
100
139
  }
101
140
 
141
+ .hds-link-standalone--color-primary {
142
+ color: var(--token-color-action-foreground-on-faint);
143
+
144
+ &:hover,
145
+ &.is-hover {
146
+ text-decoration-color: #4E81E8; // custom color by design
147
+ }
148
+ &:active,
149
+ &.is-active {
150
+ color: var(--token-color-action-foreground-high-contrast);
151
+ text-decoration-color: #596987; // custom color by design
152
+ }
153
+ }
154
+
102
155
  .hds-link-standalone--color-secondary {
103
- background-color: transparent;
104
156
  color: var(--token-color-neutral-foreground-primary);
105
157
 
106
- &:focus,
107
- &:focus-visible,
108
- &.is-focus {
109
- outline: 2px solid transparent;
110
- box-shadow:
111
- 0 0 0 $hds-link-standalone-border-width var(--token-color-action-border-on-primary),
112
- 0 0 0 $hds-link-standalone-focus-border-width #5990FF;
113
- }
114
158
  &:hover,
115
159
  &.is-hover {
116
- text-decoration: underline;
117
- text-decoration-color: var(--token-color-neutral-foreground-primary);
160
+ text-decoration-color: #4D4D4F; // custom color by design
118
161
  }
119
- &:active,
162
+ &:active,
120
163
  &.is-active {
121
164
  color: var(--token-color-neutral-foreground-secondary);
122
- text-decoration: underline;
123
- text-decoration-color: var(--token-color-neutral-foreground-primary);
124
-
165
+ text-decoration-color: #6E7075; // custom color by design
125
166
  }
126
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashicorp/design-system-components",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "HashiCorp Design System Components",
5
5
  "keywords": [
6
6
  "hashicorp",
@@ -92,6 +92,7 @@
92
92
  "ember-load-initializers": "^2.1.2",
93
93
  "ember-maybe-import-regenerator": "^0.1.6",
94
94
  "ember-page-title": "^6.2.2",
95
+ "ember-prism": "^0.12.0",
95
96
  "ember-qunit": "^5.1.4",
96
97
  "ember-resolver": "^8.0.2",
97
98
  "ember-source": "~3.28.0",