88@use ' ../internal/styles/foundation' as foundation ;
99@use ' ../internal/generated/custom-css-properties/index.scss' as custom-props ;
1010@use ' ../internal/styles/utils/theming' as theming ;
11+ @use ' ../internal/styles/style-api' as style-api ;
1112@use ' @cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible ;
1213
14+ // Style API v2. The root radius is a carrier so the segments can derive their own radius from it; the segment
15+ // focus ring and the divider (the ::after of the segment) read carriers re-anchored on the segment.
16+ $root-tokens : style-api .resolve ((border-radius ), carrier );
17+ $segment-tokens : style-api .resolve (style-api .$focus-ring , carrier );
18+ $divider-tokens : style-api .resolve ((color , width ), carrier );
19+ @include style-api .register ($segment-tokens , $divider-tokens );
20+
1321$default-background : var (#{custom-props .$styleBackgroundDefault } , awsui .$color-background-segment-default );
1422$default-color : var (#{custom-props .$styleColorDefault } , awsui .$color-text-segment-default );
1523$hover-background : var (#{custom-props .$styleBackgroundHover } , awsui .$color-background-segment-hover );
@@ -23,9 +31,12 @@ $segment-border-width: var(#{$segment-border-width-prop}, 0);
2331$segment-gap : awsui .$space-static-xxs ;
2432$segment-divider-width : 1px ;
2533$one-theme-segment-gap : calc (#{$segment-gap } - #{$segment-divider-width } );
26- $segment-radius : calc (awsui .$border-radius-button - (#{awsui .$border-width-field } + #{awsui .$border-width-button } ));
34+ $root-radius : style-api .value ($root-tokens , border-radius , awsui .$border-radius-button );
35+ $segment-radius : calc ($root-radius - (#{awsui .$border-width-field } + #{awsui .$border-width-button } ));
2736
2837.segment {
38+ @include style-api .carriers ($segment-tokens );
39+ @include style-api .carriers ($divider-tokens );
2940 @include styles .font-body-m ;
3041 @include styles .text-flex-wrapping ;
3142 @include styles .font-button ;
@@ -69,13 +80,25 @@ $segment-radius: calc(awsui.$border-radius-button - (#{awsui.$border-width-field
6980 }
7081
7182 #{custom-props .$styleFocusRingBoxShadow } : 0 0 0
72- var (#{custom-props .$styleFocusRingBorderWidth } , foundation .$box-shadow-focused-width )
73- var (#{custom-props .$styleFocusRingBorderColor } , awsui .$color-border-item-focused );
83+ style-api .value (
84+ $segment-tokens ,
85+ focus-ring-width ,
86+ var (#{custom-props .$styleFocusRingBorderWidth } , foundation .$box-shadow-focused-width )
87+ )
88+ style-api .value (
89+ $segment-tokens ,
90+ focus-ring-color ,
91+ var (#{custom-props .$styleFocusRingBorderColor } , awsui .$color-border-item-focused )
92+ );
7493
7594 @include focus-visible .when-visible {
7695 @include styles .focus-highlight (
7796 $gutter : awsui .$space-segmented-control-focus-outline-gutter ,
78- $border-radius : var (#{custom-props .$styleFocusRingBorderRadius } , awsui .$border-radius-control-default-focus-ring ),
97+ $border-radius : style-api .value (
98+ $segment-tokens ,
99+ focus-ring-radius ,
100+ var (#{custom-props .$styleFocusRingBorderRadius } , awsui .$border-radius-control-default-focus-ring )
101+ ),
79102 $box-shadow : var (#{custom-props .$styleFocusRingBoxShadow } ),
80103 $z-index : 1 // Prevents adjacent segments from overlapping the focus ring
81104 );
@@ -87,8 +110,8 @@ $segment-radius: calc(awsui.$border-radius-button - (#{awsui.$border-width-field
87110 inset-inline-end : calc (-1 * ($segment-gap + $segment-divider-width ));
88111 block-size : calc (100% - (($segment-gap + awsui .$space-static-xxxs ) * 2 ));
89112 min-block-size : calc (awsui .$line-height-body-m - $segment-gap * 2 );
90- inline-size : $ segment-divider-width ;
91- background : awsui .$color-border-segment-divider ;
113+ inline-size : style-api . value ( $divider-tokens , width , $ segment-divider-width) ;
114+ background : style-api . value ( $divider-tokens , color , awsui .$color-border-segment-divider ) ;
92115 z-index : 1 ;
93116 }
94117 & :not (.refresh ):not (:last-child )::after {
0 commit comments