Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/segmented-control/segment.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@use '../internal/styles/tokens' as awsui;
@use '../internal/styles/foundation' as foundation;
@use '../internal/generated/custom-css-properties/index.scss' as custom-props;
@use '../internal/styles/utils/theming' as theming;
@use '@cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible;

$default-background: var(#{custom-props.$styleBackgroundDefault}, awsui.$color-background-segment-default);
Expand All @@ -17,8 +18,11 @@ $disabled-background: var(#{custom-props.$styleBackgroundDisabled}, awsui.$color
$disabled-color: var(#{custom-props.$styleColorDisabled}, awsui.$color-text-interactive-disabled);
$selected-background: var(#{custom-props.$styleBackgroundActive}, awsui.$color-background-segment-active);
$selected-color: var(#{custom-props.$styleColorActive}, awsui.$color-text-segment-active);
$selected-border-width-prop: --awsui-internal-style-segment-selected-border-width;
$selected-border-width: var(#{$selected-border-width-prop}, 0);
$segment-gap: awsui.$space-static-xxs;
$segment-divider-width: 1px;
$one-theme-segment-gap: calc(#{$segment-gap} - #{$segment-divider-width});
$segment-radius: calc(awsui.$border-radius-button - (#{awsui.$border-width-field} + #{awsui.$border-width-button}));

.segment {
Expand Down Expand Up @@ -90,6 +94,13 @@ $segment-radius: calc(awsui.$border-radius-button - (#{awsui.$border-width-field
&:not(.refresh):not(:last-child)::after {
inset-inline-end: calc(-1 * $segment-gap);
}
@include theming.one-theme-only {
#{$selected-border-width-prop}: #{awsui.$border-width-field};

&:not(:last-child)::after {
content: none;
}
}

@for $i from 1 through 6 {
&:nth-child(#{$i}) {
Expand All @@ -100,6 +111,7 @@ $segment-radius: calc(awsui.$border-radius-button - (#{awsui.$border-width-field
&.selected {
background: $selected-background;
color: $selected-color;
box-shadow: inset 0 0 0 $selected-border-width awsui.$color-border-segment-active;
}

&:hover:not(.selected):not(.disabled):not(:focus) {
Expand All @@ -117,6 +129,9 @@ $segment-radius: calc(awsui.$border-radius-button - (#{awsui.$border-width-field
position: relative;
inset-inline-start: calc(-1 * #{awsui.$space-xxs});
margin-inline-end: awsui.$space-xxs;
@include theming.one-theme-only {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What changed for this to be xxxs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many icons have inner padding within the 16×16 area. When these icons are placed in a segment with equal inline spacing, the spacing can appear uneven because the icon itself contains additional space.
A negative inset-inline-start is especially useful in VR, where segments have larger inline spacing, but the current value appears too large for One Theme.

inset-inline-start: calc(-1 * #{awsui.$space-xxxs});
}
}

.with-no-text {
Expand Down
5 changes: 5 additions & 0 deletions src/segmented-control/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@use 'segment' as seg;
@use 'sass:list' as list;
@use '../internal/styles/tokens' as awsui;
@use '../internal/styles/utils/theming' as theming;

@function repeatValue($value, $times) {
$result: ();
Expand Down Expand Up @@ -43,6 +44,10 @@
gap: calc(#{seg.$segment-gap} * 2 - #{seg.$segment-divider-width});
}

@include theming.one-theme-only {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this could be merged with the above gap: definition. We can use a variable that gets set depending on whether one theme is active or not which would make it a bit more maintainable than repeating this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've quickly looked into that, but I'm not sure if that works actually.

gap: #{seg.$one-theme-segment-gap};
}

&:not(.grouped),
&.grouped-only {
@include styles.media-breakpoint-down(styles.$breakpoint-x-small) {
Expand Down
10 changes: 7 additions & 3 deletions style-dictionary/one-theme/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,14 @@ const tokens: StyleDictionary.ColorsDictionary = {
colorItemSelected: { light: '{colorPrimary600}', dark: '{colorPrimary400}' },

// ── Segmented control ─────────────────────────────────────────────────────
colorBackgroundSegmentActive: { light: '{colorNeutral800}', dark: '{colorNeutral300}' },
colorBackgroundSegmentActive: '{colorBackgroundToggleButtonNormalPressed}',
colorBackgroundSegmentDefault: { light: 'transparent', dark: 'transparent' },
colorTextSegmentActive: { light: '{colorNeutral200}', dark: '{colorNeutral950}' },
colorTextSegmentDefault: { light: '{colorNeutral600}', dark: '{colorNeutral300}' },
colorBackgroundSegmentHover: { light: '{colorWhite}', dark: '{colorNeutral850}' },
colorBackgroundSegmentDisabled: { light: 'transparent', dark: 'transparent' },
colorBackgroundSegmentWrapper: { light: '{colorNeutral100}', dark: '{colorNeutral1000}' },
colorBorderSegmentActive: '{colorBorderToggleButtonNormalPressed}',
colorTextSegmentActive: '{colorTextToggleButtonNormalPressed}',
colorTextSegmentDefault: '{colorTextButtonNormalDefault}',
colorTextSegmentHover: '{colorTextButtonNormalHover}',

// ── Slider / progress ─────────────────────────────────────────────────────
Expand Down
Loading