@carbon/element-styles 0.3.15 → 0.3.16-rc.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 (79) hide show
  1. package/README.md +21 -0
  2. package/css/prebuilt/editorial.css +1 -1
  3. package/css/prebuilt/expressive.css +1 -1
  4. package/css/prebuilt/productive.css +1 -1
  5. package/package.json +2 -2
  6. package/scss/_config.scss +9 -0
  7. package/scss/elements/_heading/index.scss +7 -4
  8. package/scss/elements/_input/index.scss +50 -47
  9. package/scss/elements/_labelled-input/index.scss +44 -41
  10. package/scss/elements/_layer/index.scss +17 -14
  11. package/scss/elements/abbreviation/index.scss +7 -4
  12. package/scss/elements/address/index.scss +7 -4
  13. package/scss/elements/anchor/index.scss +33 -30
  14. package/scss/elements/block-quotation/index.scss +30 -27
  15. package/scss/elements/body/index.scss +7 -4
  16. package/scss/elements/bold-text/index.scss +5 -2
  17. package/scss/elements/button/index.scss +183 -180
  18. package/scss/elements/checkbox/index.scss +40 -37
  19. package/scss/elements/code/index.scss +9 -6
  20. package/scss/elements/color-input/index.scss +70 -67
  21. package/scss/elements/combo-box/index.scss +35 -32
  22. package/scss/elements/date-input/index.scss +24 -21
  23. package/scss/elements/date-time-input/index.scss +24 -21
  24. package/scss/elements/deleted-text/index.scss +8 -5
  25. package/scss/elements/description-list/index.scss +17 -14
  26. package/scss/elements/details/index.scss +53 -48
  27. package/scss/elements/dialog/index.scss +173 -170
  28. package/scss/elements/email-input/index.scss +16 -13
  29. package/scss/elements/fieldset/index.scss +15 -12
  30. package/scss/elements/file-input/index.scss +53 -50
  31. package/scss/elements/footer/index.scss +9 -6
  32. package/scss/elements/header-navigation/index.scss +101 -98
  33. package/scss/elements/heading-level-1/index.scss +6 -3
  34. package/scss/elements/heading-level-2/index.scss +6 -3
  35. package/scss/elements/heading-level-3/index.scss +6 -3
  36. package/scss/elements/heading-level-4/index.scss +6 -3
  37. package/scss/elements/heading-level-5/index.scss +6 -3
  38. package/scss/elements/heading-level-6/index.scss +6 -3
  39. package/scss/elements/horizontal-rule/index.scss +12 -9
  40. package/scss/elements/image/index.scss +6 -2
  41. package/scss/elements/inline-loading/index.scss +34 -31
  42. package/scss/elements/inline-quotation/index.scss +6 -3
  43. package/scss/elements/inserted-text/index.scss +9 -6
  44. package/scss/elements/italic-text/index.scss +5 -2
  45. package/scss/elements/keyboard-input/index.scss +9 -6
  46. package/scss/elements/label/index.scss +22 -19
  47. package/scss/elements/main/index.scss +7 -4
  48. package/scss/elements/marked-text/index.scss +7 -4
  49. package/scss/elements/menu/index.scss +71 -64
  50. package/scss/elements/meter/index.scss +45 -42
  51. package/scss/elements/number-input/index.scss +16 -12
  52. package/scss/elements/ordered-list/index.scss +25 -22
  53. package/scss/elements/paragraph/index.scss +8 -5
  54. package/scss/elements/password-input/index.scss +17 -13
  55. package/scss/elements/popover/index.scss +75 -72
  56. package/scss/elements/preformatted/index.scss +18 -15
  57. package/scss/elements/progress-bar/index.scss +71 -68
  58. package/scss/elements/radio-button/index.scss +35 -32
  59. package/scss/elements/range-input/index.scss +42 -39
  60. package/scss/elements/search-input/index.scss +21 -18
  61. package/scss/elements/select/index.scss +36 -33
  62. package/scss/elements/side-navigation/index.scss +141 -137
  63. package/scss/elements/small-text/index.scss +7 -4
  64. package/scss/elements/table/index.scss +93 -90
  65. package/scss/elements/tabs/index.scss +155 -152
  66. package/scss/elements/telephone-number-input/index.scss +16 -13
  67. package/scss/elements/text-area/index.scss +21 -18
  68. package/scss/elements/text-input/index.scss +16 -13
  69. package/scss/elements/tile/index.scss +49 -45
  70. package/scss/elements/time-input/index.scss +24 -21
  71. package/scss/elements/toggle/index.scss +71 -68
  72. package/scss/elements/tooltip/index.scss +16 -13
  73. package/scss/elements/tree-view/index.scss +86 -82
  74. package/scss/elements/unordered-list/index.scss +21 -18
  75. package/scss/elements/url-input/index.scss +16 -13
  76. package/scss/prebuilt/editorial/_elements.scss +37 -33
  77. package/scss/prebuilt/expressive/_elements.scss +75 -71
  78. package/scss/prebuilt/productive/_elements.scss +71 -67
  79. package/scss/utilities/_cascade-layer.scss +33 -0
@@ -12,6 +12,7 @@
12
12
  @use "@carbon/styles/scss/utilities/focus-outline";
13
13
 
14
14
  @use "../../layout";
15
+ @use "../../utilities/cascade-layer";
15
16
  @use "../../utilities/icons";
16
17
  @use "../../utilities/guards";
17
18
  @use "../../utilities/active-indicator";
@@ -29,170 +30,173 @@ $-default-config: (
29
30
  @mixin styles($config: $config) {
30
31
  $props: map.deep-merge($-default-config, $config);
31
32
 
32
- #{map.get($props, "selector")} {
33
- padding-block: layout.$density--padding;
34
- inline-size: 16rem;
35
- background-color: theme.$layer-background;
36
- border-inline-end: 0.0625rem solid theme.$border-subtle;
37
- position: fixed;
38
- inset-inline-start: 0;
39
- inset-block: 0;
40
- overflow-y: auto;
41
- box-sizing: border-box;
42
-
43
- & section + section {
44
- padding-block-start: layout.$density--padding;
45
- }
46
-
47
- & header {
48
- @include layout.mode--helper-text;
49
- color: theme.$text-helper;
50
- padding-block-start: layout.$size--padding-block-start;
51
- padding-block-end: spacing.$spacing-03;
52
- padding-inline: layout.$density--padding;
53
- }
54
-
55
- & ul {
56
- margin: 0;
57
- padding: 0;
58
- list-style: none;
59
- }
33
+ @include cascade-layer.wrap {
34
+ #{map.get($props, "selector")} {
35
+ padding-block: layout.$density--padding;
36
+ inline-size: 16rem;
37
+ background-color: theme.$layer-background;
38
+ border-inline-end: 0.0625rem solid theme.$border-subtle;
39
+ position: fixed;
40
+ inset-inline-start: 0;
41
+ inset-block: 0;
42
+ overflow-y: auto;
43
+ box-sizing: border-box;
60
44
 
61
- @for $i from 1 through 8 {
62
- $nesting-selector: "& ul";
45
+ & section + section {
46
+ padding-block-start: layout.$density--padding;
47
+ }
63
48
 
64
- @for $_ from 1 to $i {
65
- $nesting-selector: "#{$nesting-selector} ul";
49
+ & header {
50
+ @include layout.mode--helper-text;
51
+ color: theme.$text-helper;
52
+ padding-block-start: layout.$size--padding-block-start;
53
+ padding-block-end: spacing.$spacing-03;
54
+ padding-inline: layout.$density--padding;
66
55
  }
67
56
 
68
- #{$nesting-selector} {
69
- @include tokens.set("side-navigation--level", $i);
57
+ & ul {
58
+ margin: 0;
59
+ padding: 0;
60
+ list-style: none;
70
61
  }
71
- }
72
62
 
73
- & li {
74
- margin: 0;
75
- padding: 0;
76
- }
63
+ @for $i from 1 through 8 {
64
+ $nesting-selector: "& ul";
77
65
 
78
- & li > button[aria-expanded],
79
- & li > a {
80
- @include layout.mode--heading-compact;
81
- position: relative;
82
- appearance: none;
83
- border: none;
84
- box-shadow: none;
85
- border-radius: 0;
86
- inline-size: 100%;
87
- text-align: start;
88
- display: block;
89
- box-sizing: border-box;
90
- color: theme.$text-secondary;
91
- background-color: transparent;
92
- text-decoration: none;
93
- block-size: layout.$size--block-size;
94
- padding-block-start: layout.$size--padding-block-start;
95
- padding-block-end: layout.$size--padding-block-end;
96
- padding-inline-start: calc(
97
- layout.$density--padding * tokens.get("side-navigation--level", 1)
98
- );
99
- padding-inline-end: layout.$density--padding;
100
- cursor: pointer;
101
- white-space: nowrap;
102
- text-overflow: ellipsis;
103
- overflow: hidden;
104
- transition-property: color, background-color;
105
- transition-duration: layout.$mode--transition-duration;
106
- transition-timing-function: layout.$mode--transition-timing-function;
107
-
108
- @include guards.hover {
109
- &:hover {
110
- background-color: theme.$layer-hover;
111
- color: theme.$text-primary;
66
+ @for $_ from 1 to $i {
67
+ $nesting-selector: "#{$nesting-selector} ul";
68
+ }
69
+
70
+ #{$nesting-selector} {
71
+ @include tokens.set("side-navigation--level", $i);
112
72
  }
113
73
  }
114
74
 
115
- &:active {
116
- background-color: theme.$layer-active;
75
+ & li {
76
+ margin: 0;
77
+ padding: 0;
117
78
  }
118
79
 
119
- &:focus {
120
- @include focus-outline.focus-outline("outline");
80
+ & li > button[aria-expanded],
81
+ & li > a {
82
+ @include layout.mode--heading-compact;
83
+ position: relative;
84
+ appearance: none;
85
+ border: none;
86
+ box-shadow: none;
87
+ border-radius: 0;
88
+ inline-size: 100%;
89
+ text-align: start;
90
+ display: block;
91
+ box-sizing: border-box;
92
+ color: theme.$text-secondary;
93
+ background-color: transparent;
94
+ text-decoration: none;
95
+ block-size: layout.$size--block-size;
96
+ padding-block-start: layout.$size--padding-block-start;
97
+ padding-block-end: layout.$size--padding-block-end;
98
+ padding-inline-start: calc(
99
+ layout.$density--padding * tokens.get("side-navigation--level", 1)
100
+ );
101
+ padding-inline-end: layout.$density--padding;
102
+ cursor: pointer;
103
+ white-space: nowrap;
104
+ text-overflow: ellipsis;
105
+ overflow: hidden;
106
+ transition-property: color, background-color;
107
+ transition-duration: layout.$mode--transition-duration;
108
+ transition-timing-function: layout.$mode--transition-timing-function;
109
+
110
+ @include guards.hover {
111
+ &:hover {
112
+ background-color: theme.$layer-hover;
113
+ color: theme.$text-primary;
114
+ }
115
+ }
116
+
117
+ &:active {
118
+ background-color: theme.$layer-active;
119
+ }
120
+
121
+ &:focus {
122
+ @include focus-outline.focus-outline("outline");
123
+ }
121
124
  }
122
- }
123
125
 
124
- & li > button[aria-expanded] {
125
- padding-inline-end: calc(layout.$density--padding + 1rem + layout.$density--padding);
126
- }
126
+ & li > button[aria-expanded] {
127
+ padding-inline-end: calc(layout.$density--padding + 1rem + layout.$density--padding);
128
+ }
127
129
 
128
- & li > button[aria-expanded]::after {
129
- content: "";
130
- @include icons.chevron--down;
131
- display: block;
132
- position: absolute;
133
- inset-inline-end: layout.$density--padding;
134
- inset-block-start: layout.$size--padding-block-start;
135
- transition: rotate layout.$mode--transition-duration layout.$mode--transition-timing-function;
136
- }
130
+ & li > button[aria-expanded]::after {
131
+ content: "";
132
+ @include icons.chevron--down;
133
+ display: block;
134
+ position: absolute;
135
+ inset-inline-end: layout.$density--padding;
136
+ inset-block-start: layout.$size--padding-block-start;
137
+ transition: rotate layout.$mode--transition-duration
138
+ layout.$mode--transition-timing-function;
139
+ }
137
140
 
138
- & li > button[aria-expanded="true"]::after {
139
- rotate: 180deg;
140
- }
141
+ & li > button[aria-expanded="true"]::after {
142
+ rotate: 180deg;
143
+ }
141
144
 
142
- & li > button[aria-expanded] + ul a {
143
- @include layout.mode--body-compact;
144
- }
145
+ & li > button[aria-expanded] + ul a {
146
+ @include layout.mode--body-compact;
147
+ }
145
148
 
146
- & li > button[aria-expanded]:has(+ ul a[aria-current="page"]) {
147
- color: theme.$text-primary;
148
- }
149
+ & li > button[aria-expanded]:has(+ ul a[aria-current="page"]) {
150
+ color: theme.$text-primary;
151
+ }
149
152
 
150
- & li > button[aria-expanded="false"]:has(+ ul a[aria-current="page"]),
151
- & li > button[aria-expanded] + ul a[aria-current="page"],
152
- & li > a[aria-current="page"] {
153
- @include layout.mode--heading-compact;
154
- background-color: theme.$layer-selected;
155
- box-shadow: active-indicator.left();
156
- color: theme.$text-primary;
157
-
158
- @include guards.hover {
159
- &:hover {
160
- background-color: theme.$layer-selected-hover;
153
+ & li > button[aria-expanded="false"]:has(+ ul a[aria-current="page"]),
154
+ & li > button[aria-expanded] + ul a[aria-current="page"],
155
+ & li > a[aria-current="page"] {
156
+ @include layout.mode--heading-compact;
157
+ background-color: theme.$layer-selected;
158
+ box-shadow: active-indicator.left();
159
+ color: theme.$text-primary;
160
+
161
+ @include guards.hover {
162
+ &:hover {
163
+ background-color: theme.$layer-selected-hover;
164
+ }
161
165
  }
162
166
  }
163
- }
164
167
 
165
- & li > button[aria-expanded="false"] + ul {
166
- display: none;
167
- }
168
+ & li > button[aria-expanded="false"] + ul {
169
+ display: none;
170
+ }
168
171
 
169
- & li[role="separator"] {
170
- block-size: 0.0625rem;
171
- background-color: theme.$border-subtle;
172
- margin-block: spacing.$spacing-03;
173
- margin-inline: layout.$density--padding;
174
- }
172
+ & li[role="separator"] {
173
+ block-size: 0.0625rem;
174
+ background-color: theme.$border-subtle;
175
+ margin-block: spacing.$spacing-03;
176
+ margin-inline: layout.$density--padding;
177
+ }
175
178
 
176
- & ul > li a:has(svg) {
177
- padding-inline-end: calc(layout.$density--padding + 1rem + layout.$density--padding);
178
- }
179
+ & ul > li a:has(svg) {
180
+ padding-inline-end: calc(layout.$density--padding + 1rem + layout.$density--padding);
181
+ }
179
182
 
180
- & ul > li a svg {
181
- fill: currentColor;
182
- block-size: 1rem;
183
- inline-size: 1rem;
184
- position: absolute;
185
- inset-inline-end: layout.$density--padding;
186
- inset-block-start: layout.$size--padding-block-start;
187
- }
183
+ & ul > li a svg {
184
+ fill: currentColor;
185
+ block-size: 1rem;
186
+ inline-size: 1rem;
187
+ position: absolute;
188
+ inset-inline-end: layout.$density--padding;
189
+ inset-block-start: layout.$size--padding-block-start;
190
+ }
188
191
 
189
- & ul ul button[aria-expanded] {
190
- @include layout.mode--body-compact;
191
- }
192
+ & ul ul button[aria-expanded] {
193
+ @include layout.mode--body-compact;
194
+ }
192
195
 
193
- & + main,
194
- & + main + footer {
195
- margin-inline-start: 16rem;
196
+ & + main,
197
+ & + main + footer {
198
+ margin-inline-start: 16rem;
199
+ }
196
200
  }
197
201
  }
198
202
  }
@@ -10,6 +10,7 @@
10
10
  @use "@carbon/styles/scss/theme";
11
11
 
12
12
  @use "../../layout";
13
+ @use "../../utilities/cascade-layer";
13
14
 
14
15
  $config: () !default;
15
16
 
@@ -23,9 +24,11 @@ $-default-config: (
23
24
  @mixin styles($config: $config) {
24
25
  $props: map.deep-merge($-default-config, $config);
25
26
 
26
- #{map.get($props, "selector")} {
27
- @include layout.mode--helper-text;
28
- display: inline-block;
29
- color: theme.$text-helper;
27
+ @include cascade-layer.wrap {
28
+ #{map.get($props, "selector")} {
29
+ @include layout.mode--helper-text;
30
+ display: inline-block;
31
+ color: theme.$text-helper;
32
+ }
30
33
  }
31
34
  }
@@ -13,6 +13,7 @@
13
13
  @use "../_layer";
14
14
 
15
15
  @use "../../layout";
16
+ @use "../../utilities/cascade-layer";
16
17
  @use "../../utilities/guards";
17
18
 
18
19
  $config: () !default;
@@ -29,119 +30,121 @@ $-default-config: (
29
30
  @mixin styles($config: $config) {
30
31
  $props: map.deep-merge($-default-config, $config);
31
32
 
32
- #{map.get($props, "selector")} {
33
- border-spacing: 0;
34
- inline-size: 100%;
35
- margin-block: layout.$mode--margin-block;
33
+ @include cascade-layer.wrap {
34
+ #{map.get($props, "selector")} {
35
+ border-spacing: 0;
36
+ inline-size: 100%;
37
+ margin-block: layout.$mode--margin-block;
36
38
 
37
- & th {
38
- @include layout.mode--heading-compact;
39
- text-align: start;
40
- color: theme.$text-primary;
41
- }
42
-
43
- & td {
44
- @include layout.mode--body-compact;
45
- color: theme.$text-secondary;
46
- vertical-align: top;
47
- }
48
-
49
- & th,
50
- & td {
51
- block-size: layout.$size--block-size;
52
- box-sizing: border-box;
53
- border-block-end: 0.0625rem solid theme.$border-subtle;
54
- padding-block-start: layout.$size--padding-block-start;
55
- padding-block-end: layout.$size--padding-block-end;
56
- padding-inline: layout.$density--padding;
57
- }
58
-
59
- & th p,
60
- & td p {
61
- font: inherit;
62
- margin: 0;
63
- }
64
-
65
- & td p + p {
66
- margin-block-start: layout.$mode--margin-block;
67
- }
68
-
69
- & tbody:has(+ tfoot) tr:last-child th,
70
- & tbody:has(+ tfoot) tr:last-child td,
71
- & tfoot th,
72
- & tfoot td {
73
- border-block-end: 0;
74
- }
75
-
76
- & tfoot td {
77
- color: theme.$text-primary;
78
- }
79
-
80
- & caption {
81
- text-align: start;
82
- @include layout.mode--helper-text;
83
- padding: layout.$density--padding;
84
- }
39
+ & th {
40
+ @include layout.mode--heading-compact;
41
+ text-align: start;
42
+ color: theme.$text-primary;
43
+ }
85
44
 
86
- @if map.get($props, "kind") == "data-table" {
87
- background-color: theme.$layer;
45
+ & td {
46
+ @include layout.mode--body-compact;
47
+ color: theme.$text-secondary;
48
+ vertical-align: top;
49
+ }
88
50
 
89
- & tbody tr,
90
- & tfoot tr {
91
- @include layer.styles;
51
+ & th,
52
+ & td {
53
+ block-size: layout.$size--block-size;
54
+ box-sizing: border-box;
55
+ border-block-end: 0.0625rem solid theme.$border-subtle;
56
+ padding-block-start: layout.$size--padding-block-start;
57
+ padding-block-end: layout.$size--padding-block-end;
58
+ padding-inline: layout.$density--padding;
92
59
  }
93
60
 
94
- & th {
95
- background-color: theme.$layer-accent;
61
+ & th p,
62
+ & td p {
63
+ font: inherit;
64
+ margin: 0;
96
65
  }
97
66
 
98
- @include guards.hover {
99
- & tr:hover {
100
- @include layer.layer-background-hover;
101
- }
67
+ & td p + p {
68
+ margin-block-start: layout.$mode--margin-block;
102
69
  }
103
70
 
71
+ & tbody:has(+ tfoot) tr:last-child th,
72
+ & tbody:has(+ tfoot) tr:last-child td,
104
73
  & tfoot th,
105
74
  & tfoot td {
106
- border-block-start: 0.0625rem solid theme.$border-strong;
75
+ border-block-end: 0;
107
76
  }
108
77
 
109
- & caption {
110
- background-color: theme.$layer;
111
- color: theme.$text-secondary;
112
- }
113
- }
114
-
115
- @if map.get($props, "kind") ==
116
- "structured-list" or
117
- map.get($props, "kind") ==
118
- "structured-list--flush"
119
- {
120
- & tfoot th,
121
78
  & tfoot td {
122
- border-block-start: 0.0625rem solid theme.$border-subtle;
79
+ color: theme.$text-primary;
123
80
  }
124
81
 
125
82
  & caption {
126
- caption-side: bottom;
127
- color: theme.$text-helper;
128
- max-inline-size: layout.$mode--max-inline-size;
83
+ text-align: start;
84
+ @include layout.mode--helper-text;
85
+ padding: layout.$density--padding;
129
86
  }
130
- }
131
87
 
132
- @if map.get($props, "kind") == "structured-list--flush" {
133
- & th:first-child,
134
- & td:first-child {
135
- padding-inline-start: 0;
88
+ @if map.get($props, "kind") == "data-table" {
89
+ background-color: theme.$layer;
90
+
91
+ & tbody tr,
92
+ & tfoot tr {
93
+ @include layer.styles;
94
+ }
95
+
96
+ & th {
97
+ background-color: theme.$layer-accent;
98
+ }
99
+
100
+ @include guards.hover {
101
+ & tr:hover {
102
+ @include layer.layer-background-hover;
103
+ }
104
+ }
105
+
106
+ & tfoot th,
107
+ & tfoot td {
108
+ border-block-start: 0.0625rem solid theme.$border-strong;
109
+ }
110
+
111
+ & caption {
112
+ background-color: theme.$layer;
113
+ color: theme.$text-secondary;
114
+ }
136
115
  }
137
116
 
138
- & th:last-child,
139
- & td:last-child {
140
- padding-inline-end: 0;
117
+ @if map.get($props, "kind") ==
118
+ "structured-list" or
119
+ map.get($props, "kind") ==
120
+ "structured-list--flush"
121
+ {
122
+ & tfoot th,
123
+ & tfoot td {
124
+ border-block-start: 0.0625rem solid theme.$border-subtle;
125
+ }
126
+
127
+ & caption {
128
+ caption-side: bottom;
129
+ color: theme.$text-helper;
130
+ max-inline-size: layout.$mode--max-inline-size;
131
+ }
141
132
  }
142
133
 
143
- & caption {
144
- padding-inline: 0;
134
+ @if map.get($props, "kind") == "structured-list--flush" {
135
+ & th:first-child,
136
+ & td:first-child {
137
+ padding-inline-start: 0;
138
+ }
139
+
140
+ & th:last-child,
141
+ & td:last-child {
142
+ padding-inline-end: 0;
143
+ }
144
+
145
+ & caption {
146
+ padding-inline: 0;
147
+ }
145
148
  }
146
149
  }
147
150
  }