Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ds): fix (negative) elevations #17616

Merged
merged 1 commit into from
Mar 12, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ const mapElevationToButtonBackground = ({
const capitalizedState = capitalizeFirstLetter(state);

const map: Record<Elevation, Color> = {
'-1': `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation3`, // For example left menu is negative elevation

// Button lies always on elevation so for example Button that lies has elevation 0, lies on elevation -1.
// This is why the values here a shifted by 1.
'-1': `interactionBackgroundTertiaryDefault${capitalizedState}OnElevationNegative`, // For example left menu is negative elevation
0: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation0`,
1: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation1`,
2: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation2`,
Expand Down
52 changes: 36 additions & 16 deletions packages/theme/src/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,49 +31,59 @@ const light = {
// Figma Colors
backgroundAlertBlueBold: palette.lightAccentBlue600,
backgroundAlertBlueBoldAlt: palette.lightAccentBlue700,
backgroundAlertBlueSubtleOnElevationNegative: palette.lightAccentBlue400,
backgroundAlertBlueSubtleOnElevation0: palette.lightAccentBlue300,
backgroundAlertBlueSubtleOnElevation1: palette.lightAccentBlue200,
backgroundAlertBlueSubtleOnElevation2: palette.lightAccentBlue300,
backgroundAlertPurpleBold: palette.lightAccentPurple600,
backgroundAlertPurpleBoldAlt: palette.lightAccentPurple700,
backgroundAlertPurpleSubtleOnElevationNegative: palette.lightAccentPurple400,
backgroundAlertPurpleSubtleOnElevation0: palette.lightAccentPurple300,
backgroundAlertPurpleSubtleOnElevation1: palette.lightAccentPurple200,
backgroundAlertPurpleSubtleOnElevation2: palette.lightAccentPurple300,
backgroundAlertRedBold: palette.lightAccentRed600,
backgroundAlertRedBoldAlt: palette.lightAccentRed700,
backgroundAlertRedSubtleOnElevationNegative: palette.lightAccentRed400,
backgroundAlertRedSubtleOnElevation0: palette.lightAccentRed300,
backgroundAlertRedSubtleOnElevation1: palette.lightAccentRed200,
backgroundAlertRedSubtleOnElevation2: palette.lightAccentRed300,
backgroundAlertYellowBold: palette.lightAccentYellow600,
backgroundAlertYellowBoldAlt: palette.lightAccentYellow700,
backgroundAlertYellowSubtleOnElevationNegative: palette.lightAccentYellow400,
backgroundAlertYellowSubtleOnElevation0: palette.lightAccentYellow300,
backgroundAlertYellowSubtleOnElevation1: palette.lightAccentYellow200,
backgroundAlertYellowSubtleOnElevation2: palette.lightAccentYellow300,
backgroundNeutralBold: palette.lightGray1000,
backgroundNeutralBoldInverted: palette.lightWhiteAlpha1000,
backgroundNeutralDisabled: palette.lightGray200,
backgroundNeutralSubdued: palette.lightGray500,
backgroundNeutralSubtleOnElevationNegative: palette.lightGray400,
backgroundNeutralSubtleOnElevation0: palette.lightGray300,
backgroundNeutralSubtleOnElevation1: palette.lightGray200,
backgroundPrimaryDefault: palette.lightPrimaryForest800,
backgroundPrimaryPressed: palette.lightPrimaryForest900,
backgroundPrimarySubtleOnElevationNegative: palette.lightPrimaryForest400,
backgroundPrimarySubtleOnElevation0: palette.lightPrimaryForest300,
backgroundPrimarySubtleOnElevation1: palette.lightPrimaryForest200,
backgroundSecondaryDefault: palette.lightSecondaryEmerald800,
backgroundSecondaryPressed: palette.lightSecondaryEmerald900,
backgroundSurfaceElevationNegative: palette.lightGray200,
backgroundSurfaceElevation0: palette.lightGray100,
backgroundSurfaceElevation1: palette.lightWhiteAlpha1000,
backgroundSurfaceElevation2: palette.lightGray100,
backgroundSurfaceElevation3: palette.lightWhiteAlpha1000,
backgroundTertiaryDefaultOnElevationNegative: palette.lightGray400,
backgroundTertiaryDefaultOnElevation0: palette.lightGray300,
backgroundTertiaryDefaultOnElevation1: palette.lightGray200,
backgroundTertiaryPressedOnElevationNegative: palette.lightGray300,
backgroundTertiaryPressedOnElevation0: palette.lightGray400,
backgroundTertiaryPressedOnElevation1: palette.lightGray300,
borderAlertRed: palette.lightAccentRed600,
borderDashed: palette.lightGray400,
borderFocus: palette.lightGray500,
borderInputDefault: palette.lightGray400,
borderInverted: palette.lightWhiteAlpha1000,
borderOnElevationNegative: palette.lightGray400,
borderOnElevation0: palette.lightGray300,
borderOnElevation1: palette.lightGray200,
borderSecondary: palette.lightSecondaryEmerald800,
Expand All @@ -95,34 +105,42 @@ const light = {
iconPrimaryDefault: palette.lightPrimaryForest800,
iconPrimaryPressed: palette.lightPrimaryForest900,
iconSubdued: palette.lightGray700,
interactionBackgroundDestructiveDefaultHoverOnElevationNegative: palette.lightAccentRed300,
interactionBackgroundDestructiveDefaultHoverOnElevation0: palette.lightAccentRed400,
interactionBackgroundDestructiveDefaultHoverOnElevation1: palette.lightAccentRed300,
interactionBackgroundDestructiveDefaultHoverOnElevation2: palette.lightAccentRed400,
interactionBackgroundDestructiveDefaultHoverOnElevation3: palette.lightAccentRed300,
interactionBackgroundDestructiveDefaultNormalOnElevationNegative: palette.lightAccentRed400,
interactionBackgroundDestructiveDefaultNormalOnElevation0: palette.lightAccentRed300,
interactionBackgroundDestructiveDefaultNormalOnElevation1: palette.lightAccentRed200,
interactionBackgroundDestructiveDefaultNormalOnElevation2: palette.lightAccentRed300,
interactionBackgroundDestructiveDefaultNormalOnElevation3: palette.lightAccentRed200,
interactionBackgroundInfoDefaultHoverOnElevationNegative: palette.lightAccentBlue300,
interactionBackgroundInfoDefaultHoverOnElevation0: palette.lightAccentBlue400,
interactionBackgroundInfoDefaultHoverOnElevation1: palette.lightAccentBlue300,
interactionBackgroundInfoDefaultHoverOnElevation2: palette.lightAccentBlue400,
interactionBackgroundInfoDefaultHoverOnElevation3: palette.lightAccentBlue300,
interactionBackgroundInfoDefaultNormalOnElevationNegative: palette.lightAccentBlue400,
interactionBackgroundInfoDefaultNormalOnElevation0: palette.lightAccentBlue300,
interactionBackgroundInfoDefaultNormalOnElevation1: palette.lightAccentBlue200,
interactionBackgroundInfoDefaultNormalOnElevation2: palette.lightAccentBlue300,
interactionBackgroundInfoDefaultNormalOnElevation3: palette.lightAccentBlue200,
interactionBackgroundTertiaryDefaultHoverOnElevationNegative: palette.lightGray300,
interactionBackgroundTertiaryDefaultHoverOnElevation0: palette.lightGray400,
interactionBackgroundTertiaryDefaultHoverOnElevation1: palette.lightGray300,
interactionBackgroundTertiaryDefaultHoverOnElevation2: palette.lightGray400,
interactionBackgroundTertiaryDefaultHoverOnElevation3: palette.lightGray300,
interactionBackgroundTertiaryDefaultNormalOnElevationNegative: palette.lightGray400,
interactionBackgroundTertiaryDefaultNormalOnElevation0: palette.lightGray300,
interactionBackgroundTertiaryDefaultNormalOnElevation1: palette.lightGray200,
interactionBackgroundTertiaryDefaultNormalOnElevation2: palette.lightGray300,
interactionBackgroundTertiaryDefaultNormalOnElevation3: palette.lightGray200,
interactionBackgroundWarningDefaultHoverOnElevationNegative: palette.lightAccentYellow300,
interactionBackgroundWarningDefaultHoverOnElevation0: palette.lightAccentYellow400,
interactionBackgroundWarningDefaultHoverOnElevation1: palette.lightAccentYellow300,
interactionBackgroundWarningDefaultHoverOnElevation2: palette.lightAccentYellow400,
interactionBackgroundWarningDefaultHoverOnElevation3: palette.lightAccentYellow300,
interactionBackgroundWarningDefaultNormalOnElevationNegative: palette.lightAccentYellow400,
interactionBackgroundWarningDefaultNormalOnElevation0: palette.lightAccentYellow300,
interactionBackgroundWarningDefaultNormalOnElevation1: palette.lightAccentYellow200,
interactionBackgroundWarningDefaultNormalOnElevation2: palette.lightAccentYellow300,
Expand All @@ -147,15 +165,7 @@ const light = {
textSubdued: palette.lightGray700,

// non-valid tokens (should be removed)
backgroundAlertBlueSubtleOnElevationNegative: palette.lightAccentBlue400,
backgroundAlertPurpleSubtleOnElevationNegative: palette.lightAccentPurple400,
backgroundAlertRedSubtleOnElevationNegative: palette.lightAccentRed400,
backgroundAlertYellowSubtleOnElevationNegative: palette.lightAccentYellow400,
backgroundNeutralSubtleOnElevationNegative: palette.lightGray300,
backgroundPrimarySubtleOnElevation2: palette.lightPrimaryForest100,
backgroundPrimarySubtleOnElevationNegative: palette.lightPrimaryForest400,
backgroundSurfaceElevationNegative: palette.lightGray200,
backgroundTertiaryDefaultOnElevationNegative: palette.lightGray300,
borderElevation0: palette.lightGray300,
borderElevation1: palette.lightGray200,
borderElevation2: palette.lightGray200,
Expand Down Expand Up @@ -195,49 +205,59 @@ export const colorVariants: Record<ThemeColorVariant, Colors> = {
// Figma Colors
backgroundAlertBlueBold: palette.darkAccentBlue600,
backgroundAlertBlueBoldAlt: palette.darkAccentBlue700,
backgroundAlertBlueSubtleOnElevationNegative: palette.darkAccentBlue100,
backgroundAlertBlueSubtleOnElevation0: palette.darkAccentBlue200,
backgroundAlertBlueSubtleOnElevation1: palette.darkAccentBlue300,
backgroundAlertBlueSubtleOnElevation2: palette.darkAccentBlue400,
backgroundAlertPurpleBold: palette.darkAccentPurple600,
backgroundAlertPurpleBoldAlt: palette.darkAccentPurple700,
backgroundAlertPurpleSubtleOnElevationNegative: palette.darkAccentPurple100,
backgroundAlertPurpleSubtleOnElevation0: palette.darkAccentPurple200,
backgroundAlertPurpleSubtleOnElevation1: palette.darkAccentPurple300,
backgroundAlertPurpleSubtleOnElevation2: palette.darkAccentPurple400,
backgroundAlertRedBold: palette.darkAccentRed600,
backgroundAlertRedBoldAlt: palette.darkAccentRed700,
backgroundAlertRedSubtleOnElevationNegative: palette.darkAccentRed100,
backgroundAlertRedSubtleOnElevation0: palette.darkAccentRed200,
backgroundAlertRedSubtleOnElevation1: palette.darkAccentRed300,
backgroundAlertRedSubtleOnElevation2: palette.darkAccentRed400,
backgroundAlertYellowBold: palette.darkAccentYellow600,
backgroundAlertYellowBoldAlt: palette.darkAccentYellow700,
backgroundAlertYellowSubtleOnElevationNegative: palette.darkAccentYellow100,
backgroundAlertYellowSubtleOnElevation0: palette.darkAccentYellow200,
backgroundAlertYellowSubtleOnElevation1: palette.darkAccentYellow300,
backgroundAlertYellowSubtleOnElevation2: palette.darkAccentYellow400,
backgroundNeutralBold: palette.darkGray1000,
backgroundNeutralBoldInverted: palette.darkGray000,
backgroundNeutralDisabled: palette.darkGray200,
backgroundNeutralSubdued: palette.darkGray500,
backgroundNeutralSubtleOnElevationNegative: palette.darkGray100,
backgroundNeutralSubtleOnElevation0: palette.darkGray200,
backgroundNeutralSubtleOnElevation1: palette.darkGray300,
backgroundPrimaryDefault: palette.darkPrimaryForest800,
backgroundPrimaryPressed: palette.darkPrimaryForest900,
backgroundPrimarySubtleOnElevationNegative: palette.darkPrimaryForest100,
backgroundPrimarySubtleOnElevation0: palette.darkPrimaryForest200,
backgroundPrimarySubtleOnElevation1: palette.darkPrimaryForest300,
backgroundSecondaryDefault: palette.darkSecondaryGreen800,
backgroundSecondaryPressed: palette.darkSecondaryGreen900,
backgroundSurfaceElevationNegative: palette.darkGray000,
backgroundSurfaceElevation0: palette.darkGray50,
backgroundSurfaceElevation1: palette.darkGray100,
backgroundSurfaceElevation2: palette.darkGray200,
backgroundSurfaceElevation3: palette.darkGray300,
backgroundTertiaryDefaultOnElevationNegative: palette.darkGray100,
backgroundTertiaryDefaultOnElevation0: palette.darkGray200,
backgroundTertiaryDefaultOnElevation1: palette.darkGray300,
backgroundTertiaryPressedOnElevationNegative: palette.darkGray200,
backgroundTertiaryPressedOnElevation0: palette.darkGray300,
backgroundTertiaryPressedOnElevation1: palette.darkGray400,
borderAlertRed: palette.darkAccentRed600,
borderDashed: palette.darkGray300,
borderFocus: palette.darkGray500,
borderInputDefault: palette.darkGray400,
borderInverted: palette.darkGray000,
borderOnElevationNegative: palette.darkGray200,
borderOnElevation0: palette.darkGray300,
borderOnElevation1: palette.darkGray400,
borderSecondary: palette.darkSecondaryGreen800,
Expand All @@ -259,34 +279,42 @@ export const colorVariants: Record<ThemeColorVariant, Colors> = {
iconPrimaryDefault: palette.darkPrimaryForest800,
iconPrimaryPressed: palette.darkPrimaryForest900,
iconSubdued: palette.darkGray700,
interactionBackgroundDestructiveDefaultHoverOnElevationNegative: palette.darkAccentRed200,
interactionBackgroundDestructiveDefaultHoverOnElevation0: palette.darkAccentRed300,
interactionBackgroundDestructiveDefaultHoverOnElevation1: palette.darkAccentRed400,
interactionBackgroundDestructiveDefaultHoverOnElevation2: palette.darkAccentRed500,
interactionBackgroundDestructiveDefaultHoverOnElevation3: palette.darkAccentRed400,
interactionBackgroundDestructiveDefaultNormalOnElevationNegative: palette.darkAccentRed100,
interactionBackgroundDestructiveDefaultNormalOnElevation0: palette.darkAccentRed200,
interactionBackgroundDestructiveDefaultNormalOnElevation1: palette.darkAccentRed300,
interactionBackgroundDestructiveDefaultNormalOnElevation2: palette.darkAccentRed400,
interactionBackgroundDestructiveDefaultNormalOnElevation3: palette.darkAccentRed500,
interactionBackgroundInfoDefaultHoverOnElevationNegative: palette.darkAccentBlue200,
interactionBackgroundInfoDefaultHoverOnElevation0: palette.darkAccentBlue300,
interactionBackgroundInfoDefaultHoverOnElevation1: palette.darkAccentBlue400,
interactionBackgroundInfoDefaultHoverOnElevation2: palette.darkAccentBlue500,
interactionBackgroundInfoDefaultHoverOnElevation3: palette.darkAccentBlue400,
interactionBackgroundInfoDefaultNormalOnElevationNegative: palette.darkAccentBlue100,
interactionBackgroundInfoDefaultNormalOnElevation0: palette.darkAccentBlue200,
interactionBackgroundInfoDefaultNormalOnElevation1: palette.darkAccentBlue300,
interactionBackgroundInfoDefaultNormalOnElevation2: palette.darkAccentBlue400,
interactionBackgroundInfoDefaultNormalOnElevation3: palette.darkAccentBlue500,
interactionBackgroundTertiaryDefaultHoverOnElevationNegative: palette.darkGray200,
interactionBackgroundTertiaryDefaultHoverOnElevation0: palette.darkGray300,
interactionBackgroundTertiaryDefaultHoverOnElevation1: palette.darkGray400,
interactionBackgroundTertiaryDefaultHoverOnElevation2: palette.darkGray500,
interactionBackgroundTertiaryDefaultHoverOnElevation3: palette.darkGray400,
interactionBackgroundTertiaryDefaultNormalOnElevationNegative: palette.darkGray100,
interactionBackgroundTertiaryDefaultNormalOnElevation0: palette.darkGray200,
interactionBackgroundTertiaryDefaultNormalOnElevation1: palette.darkGray300,
interactionBackgroundTertiaryDefaultNormalOnElevation2: palette.darkGray400,
interactionBackgroundTertiaryDefaultNormalOnElevation3: palette.darkGray500,
interactionBackgroundWarningDefaultHoverOnElevationNegative: palette.darkAccentYellow200,
interactionBackgroundWarningDefaultHoverOnElevation0: palette.darkAccentYellow300,
interactionBackgroundWarningDefaultHoverOnElevation1: palette.darkAccentYellow400,
interactionBackgroundWarningDefaultHoverOnElevation2: palette.darkAccentYellow500,
interactionBackgroundWarningDefaultHoverOnElevation3: palette.darkAccentYellow400,
interactionBackgroundWarningDefaultNormalOnElevationNegative: palette.darkAccentYellow100,
interactionBackgroundWarningDefaultNormalOnElevation0: palette.darkAccentYellow200,
interactionBackgroundWarningDefaultNormalOnElevation1: palette.darkAccentYellow300,
interactionBackgroundWarningDefaultNormalOnElevation2: palette.darkAccentYellow400,
Expand All @@ -311,15 +339,7 @@ export const colorVariants: Record<ThemeColorVariant, Colors> = {
textSubdued: palette.darkGray700,

// non-valid tokens (should be removed)
backgroundAlertBlueSubtleOnElevationNegative: palette.darkAccentBlue100,
backgroundAlertPurpleSubtleOnElevationNegative: palette.darkAccentPurple400,
backgroundAlertRedSubtleOnElevationNegative: palette.darkAccentRed100,
backgroundAlertYellowSubtleOnElevationNegative: palette.darkAccentYellow100,
backgroundNeutralSubtleOnElevationNegative: palette.darkGray50,
backgroundPrimarySubtleOnElevation2: palette.darkPrimaryForest400,
backgroundPrimarySubtleOnElevationNegative: palette.darkPrimaryForest100,
backgroundSurfaceElevationNegative: palette.darkGray000,
backgroundTertiaryDefaultOnElevationNegative: palette.darkGray50,
borderElevation0: palette.darkGray100,
borderElevation1: palette.darkGray200,
borderElevation2: palette.darkGray300,
Expand Down
1 change: 1 addition & 0 deletions scripts/convertFigmaPalette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { hideBin } from 'yargs/helpers';

const normalizeName = (name: string) =>
name
.replace(/(-1)/g, 'Negative')
Copy link
Contributor Author

@jvaclavik jvaclavik Mar 12, 2025

Choose a reason for hiding this comment

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

This caused bug that I forgot to add these "negative" colors 😅

(-1 was converted to 1 and it was replaced with next 1 token)

.replace(/-/g, ' ')
.replace(/\//g, ' ')
.replace(/[^a-zA-Z0-9 ]/g, '')
Expand Down