|
8 | 8 | @use '../internal/styles' as styles; |
9 | 9 | @use '../internal/styles/tokens' as awsui; |
10 | 10 | @use '../internal/styles/utils/theming' as theming; |
| 11 | +@use '../internal/styles/style-api' as style-api; |
11 | 12 | @use '@cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible; |
12 | 13 | @use './constants' as constants; |
13 | 14 | @use './mixins' as mixins; |
14 | 15 | @use './motion'; |
15 | 16 |
|
| 17 | +$tokens: mixins.$tokens; |
| 18 | +@include style-api.register($tokens); |
| 19 | +@include style-api.docs( |
| 20 | + 'root', |
| 21 | + $tokens, |
| 22 | + $properties: (background), |
| 23 | + $descriptions: ( |
| 24 | + slot: |
| 25 | + 'This is NOT a semantic button element. Use `:has(:hover)` or `:has(:active)` to target semantic button states. `disabled` is set by you: pass a different class when it is true.', |
| 26 | + tokens: ( |
| 27 | + border-color: 'The border is drawn over the card edges and takes no space.', |
| 28 | + border-width: 'The border is drawn over the card edges and takes no space.', |
| 29 | + border-radius: 'Also rounds the header corners.', |
| 30 | + ) |
| 31 | + ) |
| 32 | +); |
| 33 | +@include style-api.docs( |
| 34 | + 'header', |
| 35 | + $properties: (background, border), |
| 36 | + $descriptions: ( |
| 37 | + slot: |
| 38 | + 'Rendered when `header` or `description` is set. The block-end border is the divider between the header and the content.' |
| 39 | + ) |
| 40 | +); |
| 41 | + |
16 | 42 | .header { |
| 43 | + // Only the block-end side has a style: a consumer border colour and width draw the divider to the content. |
| 44 | + border-block-end: 0 solid transparent; |
17 | 45 | &-inner { |
18 | 46 | @include styles.font-heading-s; |
19 | 47 | &.disabled { |
|
111 | 139 | min-inline-size: 0; |
112 | 140 | text-align: start; |
113 | 141 | display: flex; |
| 142 | + @include style-api.carriers($tokens); |
114 | 143 | $default-state: map.get(constants.$states, 'default'); |
115 | 144 | background: map.get($default-state, 'background'); |
116 | 145 | box-shadow: map.get($default-state, 'box-shadow'); |
|
124 | 153 | @include styles.base-pseudo-element; |
125 | 154 |
|
126 | 155 | box-shadow: none; |
127 | | - border-block: solid map.get($default-state, 'border-width') map.get($default-state, 'border-color'); |
128 | | - border-inline: solid map.get($default-state, 'border-width') map.get($default-state, 'border-color'); |
| 156 | + $border-width: style-api.value($tokens, border-width, map.get($default-state, 'border-width')); |
| 157 | + $border-color: style-api.value($tokens, border-color, map.get($default-state, 'border-color')); |
| 158 | + border-block: solid $border-width $border-color; |
| 159 | + border-inline: solid $border-width $border-color; |
129 | 160 | } |
130 | 161 |
|
131 | 162 | &.variant-default, |
|
175 | 206 |
|
176 | 207 | &:has(.header-button:focus-visible), |
177 | 208 | &:has(.overlay-button:focus-visible) { |
178 | | - @include styles.focus-highlight( |
179 | | - 2px, |
180 | | - awsui.$border-radius-control-default-focus-ring, |
181 | | - 0 0 0 2px awsui.$color-border-item-focused |
182 | | - ); |
183 | | - |
184 | | - @each $variant in ('embedded', 'default') { |
185 | | - &.variant-#{$variant}::before { |
186 | | - @include mixins.border-radius-all(awsui.$border-radius-control-default-focus-ring); |
187 | | - } |
188 | | - } |
| 209 | + @include style-api.focus-highlight($gutter-block: 2px, $gutter-inline: 2px); |
189 | 210 | } |
190 | 211 |
|
191 | 212 | @each $variant in ('embedded', 'default') { |
|
195 | 216 | @include mixins.state-border-radius($variant); |
196 | 217 | } |
197 | 218 |
|
| 219 | + // The header corners that meet the card corners follow the card radius. |
| 220 | + $border-radius: style-api.value($tokens, border-radius, map.get(mixins.$variant-border-radius, $variant)); |
| 221 | + > .inner-card > .header, |
| 222 | + > .inner-card > .header-row > .header { |
| 223 | + border-start-start-radius: $border-radius; |
| 224 | + } |
| 225 | + > .inner-card > .header:not(:has(+ .body)), |
| 226 | + > .inner-card > .header-row:not(:has(+ .body)) > .header { |
| 227 | + border-end-start-radius: $border-radius; |
| 228 | + } |
| 229 | + &:not(.has-icon) > .inner-card > .header { |
| 230 | + border-start-end-radius: $border-radius; |
| 231 | + &:not(:has(+ .body)) { |
| 232 | + border-end-end-radius: $border-radius; |
| 233 | + } |
| 234 | + } |
| 235 | + |
198 | 236 | $padding-block: map.get(mixins.$variant-padding-block, $variant); |
199 | 237 | $padding-inline: map.get(mixins.$variant-padding-inline, $variant); |
200 | 238 |
|
|
0 commit comments