@carbon/element-styles 0.3.4 → 0.3.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/element-styles",
3
3
  "description": "An experimental styling system for native HTML elements, relying on semantic, attribute-focused selectors instead of class names.",
4
- "version": "0.3.4",
4
+ "version": "0.3.5",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "sass": "index.scss",
@@ -41,12 +41,12 @@
41
41
  "@carbon/styles": "^1.102.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@carbon/icons": "^11.77.0",
44
+ "@carbon/icons": "^11.84.0",
45
45
  "@types/node": "^26.1.1",
46
46
  "highlight.js": "^11.11.1",
47
47
  "marked": "^18.0.6",
48
48
  "marked-highlight": "^2.2.4",
49
- "sass": "^1.98.0",
50
- "vite": "^8.0.3"
49
+ "sass": "^1.101.0",
50
+ "vite": "^8.1.5"
51
51
  }
52
52
  }
@@ -12,6 +12,7 @@
12
12
  @use '@carbon/styles/scss/utilities/focus-outline';
13
13
 
14
14
  @use '../../layout';
15
+ @use '../../utilities/guards';
15
16
 
16
17
  $config: () !default;
17
18
 
@@ -43,8 +44,10 @@ $-default-config: (
43
44
  }
44
45
  }
45
46
 
46
- &:hover {
47
- color: theme.$link-primary-hover;
47
+ @include guards.hover {
48
+ &:hover {
49
+ color: theme.$link-primary-hover;
50
+ }
48
51
  }
49
52
 
50
53
  @if $emit-visited {
@@ -13,6 +13,7 @@
13
13
  @use '@carbon/styles/scss/components/button/tokens' as carbon-button;
14
14
 
15
15
  @use '../../layout';
16
+ @use '../../utilities/guards';
16
17
 
17
18
  $config: () !default;
18
19
 
@@ -86,8 +87,10 @@ $-default-config: (
86
87
  background-color: carbon-button.$button-primary;
87
88
  color: theme.$text-on-color;
88
89
 
89
- &:hover {
90
- background-color: carbon-button.$button-primary-hover;
90
+ @include guards.hover {
91
+ &:enabled:hover {
92
+ background-color: carbon-button.$button-primary-hover;
93
+ }
91
94
  }
92
95
 
93
96
  &:active {
@@ -104,8 +107,10 @@ $-default-config: (
104
107
  background-color: carbon-button.$button-secondary;
105
108
  color: theme.$text-on-color;
106
109
 
107
- &:enabled:hover {
108
- background-color: carbon-button.$button-secondary-hover;
110
+ @include guards.hover {
111
+ &:enabled:hover {
112
+ background-color: carbon-button.$button-secondary-hover;
113
+ }
109
114
  }
110
115
 
111
116
  &:enabled:active {
@@ -124,14 +129,16 @@ $-default-config: (
124
129
  outline: 0.0625rem solid carbon-button.$button-tertiary;
125
130
  outline-offset: -0.0625rem;
126
131
 
127
- &:focus {
128
- color: theme.$text-inverse;
129
- background-color: carbon-button.$button-tertiary;
132
+ @include guards.hover {
133
+ &:enabled:hover {
134
+ color: theme.$text-inverse;
135
+ background-color: carbon-button.$button-tertiary-hover;
136
+ }
130
137
  }
131
138
 
132
- &:enabled:hover {
139
+ &:focus {
133
140
  color: theme.$text-inverse;
134
- background-color: carbon-button.$button-tertiary-hover;
141
+ background-color: carbon-button.$button-tertiary;
135
142
  }
136
143
 
137
144
  &:enabled:active {
@@ -149,9 +156,11 @@ $-default-config: (
149
156
  color: theme.$link-primary;
150
157
  padding-inline-end: layout.$density--padding;
151
158
 
152
- &:enabled:hover {
153
- color: theme.$link-primary-hover;
154
- background-color: theme.$layer-hover;
159
+ @include guards.hover {
160
+ &:enabled:hover {
161
+ color: theme.$link-primary-hover;
162
+ background-color: theme.$layer-hover;
163
+ }
155
164
  }
156
165
 
157
166
  &:enabled:active {
@@ -181,8 +190,10 @@ $-default-config: (
181
190
  background-color: carbon-button.$button-danger-primary;
182
191
  color: theme.$text-on-color;
183
192
 
184
- &:enabled:hover {
185
- background-color: carbon-button.$button-danger-hover;
193
+ @include guards.hover {
194
+ &:enabled:hover {
195
+ background-color: carbon-button.$button-danger-hover;
196
+ }
186
197
  }
187
198
 
188
199
  &:enabled:active {
@@ -201,15 +212,17 @@ $-default-config: (
201
212
  outline: 0.0625rem solid carbon-button.$button-danger-secondary;
202
213
  outline-offset: -0.0625rem;
203
214
 
204
- &:focus {
205
- color: theme.$text-on-color;
206
- background-color: carbon-button.$button-danger-primary;
215
+ @include guards.hover {
216
+ &:enabled:hover {
217
+ color: theme.$text-on-color;
218
+ background-color: carbon-button.$button-danger-hover;
219
+ outline-color: carbon-button.$button-danger-hover;
220
+ }
207
221
  }
208
222
 
209
- &:enabled:hover {
223
+ &:focus {
210
224
  color: theme.$text-on-color;
211
- background-color: carbon-button.$button-danger-hover;
212
- outline-color: carbon-button.$button-danger-hover;
225
+ background-color: carbon-button.$button-danger-primary;
213
226
  }
214
227
 
215
228
  &:enabled:active {
@@ -228,10 +241,12 @@ $-default-config: (
228
241
  color: carbon-button.$button-danger-secondary;
229
242
  padding-inline-end: layout.$density--padding;
230
243
 
231
- &:enabled:hover {
232
- color: theme.$text-on-color;
233
- background-color: carbon-button.$button-danger-hover;
234
- outline-color: carbon-button.$button-danger-hover;
244
+ @include guards.hover {
245
+ &:enabled:hover {
246
+ color: theme.$text-on-color;
247
+ background-color: carbon-button.$button-danger-hover;
248
+ outline-color: carbon-button.$button-danger-hover;
249
+ }
235
250
  }
236
251
 
237
252
  &:enabled:active {
@@ -12,6 +12,7 @@
12
12
  @use '../_labelled-input';
13
13
 
14
14
  @use '../../utilities/icons';
15
+ @use '../../utilities/guards';
15
16
 
16
17
  $config: () !default;
17
18
 
@@ -48,8 +49,10 @@ $-default-config: (
48
49
  }
49
50
 
50
51
  & input[type="text"][list] {
51
- &:enabled:hover {
52
- background-color: theme.$field-hover;
52
+ @include guards.hover {
53
+ &:enabled:hover {
54
+ background-color: theme.$field-hover;
55
+ }
53
56
  }
54
57
 
55
58
  &:enabled:active {
@@ -12,6 +12,7 @@
12
12
 
13
13
  @use '../../layout';
14
14
  @use '../../utilities/icons';
15
+ @use '../../utilities/guards';
15
16
 
16
17
  $config: () !default;
17
18
 
@@ -48,8 +49,10 @@ $-default-config: (
48
49
  margin-inline-end: calc(layout.$density--padding * -1);
49
50
  padding-inline-end: layout.$density--padding;
50
51
 
51
- &:hover {
52
- background-color: theme.$layer-hover;
52
+ @include guards.hover {
53
+ &:hover {
54
+ background-color: theme.$layer-hover;
55
+ }
53
56
  }
54
57
 
55
58
  &:active {
@@ -67,7 +70,10 @@ $-default-config: (
67
70
  translate: 0 calc((1lh - 1rem) * 0.5);
68
71
  display: inline-block;
69
72
  margin-inline-end: layout.$density--padding;
70
- transition: rotate layout.$mode--transition-duration layout.$mode--transition-timing-function;
73
+
74
+ @include guards.motion {
75
+ transition: rotate layout.$mode--transition-duration layout.$mode--transition-timing-function;
76
+ }
71
77
  }
72
78
 
73
79
  &[open] {
@@ -20,6 +20,7 @@
20
20
 
21
21
  @use '../../layout';
22
22
  @use '../../utilities/icons';
23
+ @use '../../utilities/guards';
23
24
 
24
25
  $config: () !default;
25
26
 
@@ -167,8 +168,10 @@ $-default-config: (
167
168
  cursor: pointer;
168
169
  transition: background-color layout.$mode--transition-duration layout.$mode--transition-timing-function;
169
170
 
170
- &:hover {
171
- background-color: theme.$layer-hover;
171
+ @include guards.hover {
172
+ &:hover {
173
+ background-color: theme.$layer-hover;
174
+ }
172
175
  }
173
176
 
174
177
  &:active {
@@ -191,13 +194,21 @@ $-default-config: (
191
194
  &[open]:modal {
192
195
  translate: 0 0;
193
196
  opacity: 1;
194
- transition-property: opacity, translate;
197
+ transition-property: opacity;
195
198
  transition-duration: motion.$duration-moderate-02;
196
199
  transition-timing-function: layout.$mode--transition-timing-function;
197
200
 
201
+ @include guards.motion {
202
+ transition-property: opacity, translate;
203
+
204
+ @starting-style {
205
+ opacity: 0;
206
+ translate: 0 -1.5rem;
207
+ }
208
+ }
209
+
198
210
  @starting-style {
199
211
  opacity: 0;
200
- translate: 0 -1.5rem;
201
212
  }
202
213
  }
203
214
 
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '../_labelled-input';
11
+
12
+ @use '../../layout';
13
+
14
+ $config: () !default;
15
+
16
+ $-default-config: (
17
+ selector: 'label:has(input[type="email"])',
18
+ axis: 'block',
19
+ );
20
+
21
+ /// @group email-input
22
+ /// @param {Map} config [()]
23
+ /// @param {Selector} config.selector ['label:has(input[type="email"])']
24
+ /// @param {'block' | 'axis'} config.axis ['block']
25
+ @mixin styles($config: $config) {
26
+ $props: map.deep-merge($-default-config, $config);
27
+
28
+ #{map.get($props, 'selector')} {
29
+ @include labelled-input.styles((
30
+ label: (
31
+ selector: '&',
32
+ axis: map.get($props, 'axis'),
33
+ ),
34
+ input: (
35
+ selector: 'input[type="email"]',
36
+ ),
37
+ input-invalid-slot: 'after',
38
+ ));
39
+ }
40
+ }
@@ -13,6 +13,7 @@
13
13
  @use '@carbon/styles/scss/components/button/tokens' as carbon-button;
14
14
 
15
15
  @use '../../layout';
16
+ @use '../../utilities/guards';
16
17
 
17
18
  $config: () !default;
18
19
 
@@ -60,8 +61,10 @@ $-default-config: (
60
61
  cursor: pointer;
61
62
  transition: background-color layout.$mode--transition-duration layout.$mode--transition-timing-function;
62
63
 
63
- &:hover {
64
- background-color: carbon-button.$button-primary-hover;
64
+ @include guards.hover {
65
+ &:hover {
66
+ background-color: carbon-button.$button-primary-hover;
67
+ }
65
68
  }
66
69
 
67
70
  &:active {
@@ -74,11 +77,18 @@ $-default-config: (
74
77
  }
75
78
 
76
79
  & input[type="file"]:disabled::file-selector-button,
77
- & input[type="file"]:disabled::file-selector-button:hover,
78
80
  & input[type="file"]:disabled::file-selector-button:active {
79
81
  cursor: not-allowed;
80
82
  background-color: carbon-button.$button-disabled;
81
83
  color: theme.$text-on-color-disabled;
82
84
  }
85
+
86
+ @include guards.hover {
87
+ & input[type="file"]:disabled::file-selector-button:hover {
88
+ cursor: not-allowed;
89
+ background-color: carbon-button.$button-disabled;
90
+ color: theme.$text-on-color-disabled;
91
+ }
92
+ }
83
93
  }
84
94
  }
@@ -12,6 +12,7 @@
12
12
  @use '@carbon/styles/scss/utilities/focus-outline';
13
13
 
14
14
  @use '../../layout';
15
+ @use '../../utilities/guards';
15
16
 
16
17
  $config: () !default;
17
18
 
@@ -74,9 +75,11 @@ $-default-config: (
74
75
  transition-duration: layout.$mode--transition-duration;
75
76
  transition-timing-function: layout.$mode--transition-timing-function;
76
77
 
77
- &:hover {
78
- background-color: theme.$layer-hover;
79
- color: theme.$text-primary;
78
+ @include guards.hover {
79
+ &:hover {
80
+ background-color: theme.$layer-hover;
81
+ color: theme.$text-primary;
82
+ }
80
83
  }
81
84
 
82
85
  &:active {
@@ -14,6 +14,7 @@
14
14
 
15
15
  @use '../../config';
16
16
  @use '../../layout';
17
+ @use '../../utilities/guards';
17
18
 
18
19
  $config: () !default;
19
20
 
@@ -46,9 +47,13 @@ $-stroke-width: 0.125rem;
46
47
  border-block-end-color: theme.$border-interactive;
47
48
  border-inline-end-color: theme.$border-interactive;
48
49
  animation-name: #{carbon-config.$prefix}--#{config.$prefix}--inline-loading--spinner;
49
- animation-duration: motion.$duration-slow-02;
50
+ animation-duration: calc(motion.$duration-slow-02 * 3);
50
51
  animation-timing-function: linear;
51
52
  animation-iteration-count: infinite;
53
+
54
+ @include guards.motion {
55
+ animation-duration: motion.$duration-slow-02;
56
+ }
52
57
  }
53
58
 
54
59
  &::after {
@@ -14,6 +14,7 @@
14
14
 
15
15
  @use '../../layout';
16
16
  @use '../../utilities/icons';
17
+ @use '../../utilities/guards';
17
18
 
18
19
  $config: () !default;
19
20
 
@@ -50,9 +51,11 @@ $-default-config: (
50
51
  box-sizing: border-box;
51
52
  cursor: pointer;
52
53
 
53
- &:hover {
54
- background-color: theme.$layer-hover;
55
- color: theme.$text-primary;
54
+ @include guards.hover {
55
+ &:hover {
56
+ background-color: theme.$layer-hover;
57
+ color: theme.$text-primary;
58
+ }
56
59
  }
57
60
 
58
61
  &:active {
@@ -15,6 +15,7 @@
15
15
 
16
16
  @use '../../config';
17
17
  @use '../../layout';
18
+ @use '../../utilities/guards';
18
19
 
19
20
  $config: () !default;
20
21
 
@@ -68,9 +69,13 @@ $-indeterminate-ratio: 0.25;
68
69
  & progress:not([value])::-webkit-progress-value {
69
70
  inline-size: calc(100% * $-indeterminate-ratio);
70
71
  animation-name: #{carbon-config.$prefix}--#{config.$prefix}--progress-bar--indeterminate;
71
- animation-duration: calc(motion.$duration-slow-02 * 2);
72
+ animation-duration: calc(motion.$duration-slow-02 * 5);
72
73
  animation-timing-function: linear;
73
74
  animation-iteration-count: infinite;
75
+
76
+ @include guards.motion {
77
+ animation-duration: calc(motion.$duration-slow-02 * 2);
78
+ }
74
79
  }
75
80
 
76
81
  @keyframes #{carbon-config.$prefix}--#{config.$prefix}--progress-bar--indeterminate {
@@ -13,6 +13,7 @@
13
13
 
14
14
  @use '../../layout';
15
15
  @use '../../utilities/icons';
16
+ @use '../../utilities/guards';
16
17
 
17
18
  $config: () !default;
18
19
 
@@ -51,8 +52,10 @@ $-default-config: (
51
52
  & select {
52
53
  cursor: pointer;
53
54
 
54
- &:enabled:hover {
55
- background-color: theme.$field-hover;
55
+ @include guards.hover {
56
+ &:enabled:hover {
57
+ background-color: theme.$field-hover;
58
+ }
56
59
  }
57
60
 
58
61
  &:enabled:active {
@@ -13,6 +13,7 @@
13
13
 
14
14
  @use '../../layout';
15
15
  @use '../../utilities/icons';
16
+ @use '../../utilities/guards';
16
17
 
17
18
  $config: () !default;
18
19
 
@@ -75,9 +76,11 @@ $-default-config: (
75
76
  transition-duration: layout.$mode--transition-duration;
76
77
  transition-timing-function: layout.$mode--transition-timing-function;
77
78
 
78
- &:hover {
79
- background-color: theme.$layer-hover;
80
- color: theme.$text-primary;
79
+ @include guards.hover {
80
+ &:hover {
81
+ background-color: theme.$layer-hover;
82
+ color: theme.$text-primary;
83
+ }
81
84
  }
82
85
 
83
86
  &:active {
@@ -124,8 +127,10 @@ $-default-config: (
124
127
  box-shadow: inset 0.25rem 0 0 0 theme.$border-interactive;
125
128
  color: theme.$text-primary;
126
129
 
127
- &:hover {
128
- background-color: theme.$layer-selected-hover;
130
+ @include guards.hover {
131
+ &:hover {
132
+ background-color: theme.$layer-selected-hover;
133
+ }
129
134
  }
130
135
  }
131
136
 
@@ -13,6 +13,7 @@
13
13
  @use '../_layer';
14
14
 
15
15
  @use '../../layout';
16
+ @use '../../utilities/guards';
16
17
 
17
18
  $config: () !default;
18
19
 
@@ -84,8 +85,10 @@ $-default-config: (
84
85
  background-color: theme.$layer-accent;
85
86
  }
86
87
 
87
- & tr:hover {
88
- @include layer.layer-background-hover;
88
+ @include guards.hover {
89
+ & tr:hover {
90
+ @include layer.layer-background-hover;
91
+ }
89
92
  }
90
93
 
91
94
  & tfoot th,
@@ -14,6 +14,7 @@
14
14
  @use '@carbon/styles/scss/components/content-switcher/tokens' as carbon-content-switcher;
15
15
 
16
16
  @use '../../layout';
17
+ @use '../../utilities/guards';
17
18
 
18
19
  $config: () !default;
19
20
 
@@ -49,8 +50,10 @@ $-default-config: (
49
50
  transition-duration: layout.$mode--transition-duration;
50
51
  transition-timing-function: layout.$mode--transition-timing-function;
51
52
 
52
- &:enabled:hover:not([aria-selected="true"]) {
53
- color: theme.$text-primary;
53
+ @include guards.hover {
54
+ &:enabled:hover:not([aria-selected="true"]) {
55
+ color: theme.$text-primary;
56
+ }
54
57
  }
55
58
 
56
59
  &:focus {
@@ -72,8 +75,10 @@ $-default-config: (
72
75
  border-block-end: 0.125rem solid theme.$border-subtle;
73
76
  margin-inline-end: 0.0625rem;
74
77
 
75
- &:enabled:hover:not([aria-selected="true"]) {
76
- border-block-end-color: theme.$border-strong;
78
+ @include guards.hover {
79
+ &:enabled:hover:not([aria-selected="true"]) {
80
+ border-block-end-color: theme.$border-strong;
81
+ }
77
82
  }
78
83
 
79
84
  &[aria-selected="true"] {
@@ -97,8 +102,10 @@ $-default-config: (
97
102
  border-inline-end: 0.0625rem solid theme.$border-strong;
98
103
  }
99
104
 
100
- &:enabled:hover:not([aria-selected="true"]) {
101
- background-color: theme.$layer-accent-hover;
105
+ @include guards.hover {
106
+ &:enabled:hover:not([aria-selected="true"]) {
107
+ background-color: theme.$layer-accent-hover;
108
+ }
102
109
  }
103
110
 
104
111
  &[aria-selected="true"] {
@@ -141,8 +148,10 @@ $-default-config: (
141
148
  border-end-end-radius: inherit;
142
149
  }
143
150
 
144
- &:enabled:hover:not([aria-selected="true"]) {
145
- background-color: theme.$layer-hover;
151
+ @include guards.hover {
152
+ &:enabled:hover:not([aria-selected="true"]) {
153
+ background-color: theme.$layer-hover;
154
+ }
146
155
  }
147
156
 
148
157
  &:enabled:active:not([aria-selected="true"]) {
@@ -178,11 +187,16 @@ $-default-config: (
178
187
  &[aria-selected="true"]::after,
179
188
  &:last-child::after,
180
189
  &:has(+ [aria-selected="true"])::after,
181
- &:hover::after,
182
- &:has(+ :hover)::after,
183
190
  &:focus::after {
184
191
  visibility: hidden;
185
192
  }
193
+
194
+ @include guards.hover {
195
+ &:hover::after,
196
+ &:has(+ :hover)::after {
197
+ visibility: hidden;
198
+ }
199
+ }
186
200
  }
187
201
  }
188
202
 
@@ -193,11 +207,16 @@ $-default-config: (
193
207
  }
194
208
 
195
209
  & button[role="tab"] {
196
- &:enabled:hover:not([aria-selected="true"]),
197
210
  &:enabled:active:not([aria-selected="true"]) {
198
211
  background-color: carbon-content-switcher.$content-switcher-background-hover;
199
212
  }
200
213
 
214
+ @include guards.hover {
215
+ &:enabled:hover:not([aria-selected="true"]) {
216
+ background-color: carbon-content-switcher.$content-switcher-background-hover;
217
+ }
218
+ }
219
+
201
220
  &[aria-selected="true"] {
202
221
  @include layout.mode--heading-compact;
203
222
  background-color: carbon-content-switcher.$content-switcher-selected;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '../_labelled-input';
11
+
12
+ @use '../../layout';
13
+
14
+ $config: () !default;
15
+
16
+ $-default-config: (
17
+ selector: 'label:has(input[type="tel"])',
18
+ axis: 'block',
19
+ );
20
+
21
+ /// @group telephone-number-input
22
+ /// @param {Map} config [()]
23
+ /// @param {Selector} config.selector ['label:has(input[type="tel"])']
24
+ /// @param {'block' | 'axis'} config.axis ['block']
25
+ @mixin styles($config: $config) {
26
+ $props: map.deep-merge($-default-config, $config);
27
+
28
+ #{map.get($props, 'selector')} {
29
+ @include labelled-input.styles((
30
+ label: (
31
+ selector: '&',
32
+ axis: map.get($props, 'axis'),
33
+ ),
34
+ input: (
35
+ selector: 'input[type="tel"]',
36
+ ),
37
+ input-invalid-slot: 'after',
38
+ ));
39
+ }
40
+ }