Skip to content

Commit

Permalink
Add W11 button press state colors && W11 switch hover state colors
Browse files Browse the repository at this point in the history
add all button appearnce variants

Fix mistake on transparent variant color

Remove testing

Fix error

Add Selected Button Semantic Tokens

Forgot to add the files

Add Switch Indicator semantic tokens

Add Semantic tokens for Switch Border Color

Add Switch BorderColor semantic tokens

Add combobox semantic tokens

Finish semantic tokens for Combobox Colors
  • Loading branch information
EdDaWord committed May 9, 2024
1 parent 18790f1 commit 6cd9ff5
Show file tree
Hide file tree
Showing 14 changed files with 644 additions and 220 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,109 @@
import { tokens } from '@fluentui/react-theme';

export const buttonGroupTokens = {
// colors
buttonBackgroundColorRest: `var(--buttonBackgroundColorRest,${tokens.colorNeutralBackground1})`,
buttonBackgroundColorHover: `var(--buttonBackgroundColorHover,${tokens.colorNeutralBackground1Hover})`,
buttonBackgroundColorPressed: `var(--buttonBackgroundColorPressed,${tokens.colorNeutralBackground1Pressed})`,
// Default
buttonBorderRadius: `var(--buttonBorderRadius, ${tokens.borderRadiusMedium})`,
buttonFontFamily: `var(--buttonFontFamily,${tokens.fontFamilyBase})`,

buttonForegroundColorRest: `var(--buttonForegroundColorRest,${tokens.colorNeutralForeground1})`,
buttonForegroundColorHover: `var(--buttonForegroundColorHover,${tokens.colorNeutralForeground1Hover})`,
buttonForegroundColorPressed: `var(--buttonForegroundColorPressed,${tokens.colorNeutralForeground1Pressed})`,
// Secondary
buttonSecondaryBackgroundColorRest: `var(--buttonBackgroundColorRest,${tokens.colorNeutralBackground1})`,
buttonSecondaryBorderColorRest: `var(--buttonBorderColorRest,${tokens.colorNeutralStroke1})`,
buttonSecondaryForegroundColorRest: `var(--buttonForegroundColorRest,${tokens.colorNeutralForeground1})`,

buttonBorderColorRest: `var(--buttonBorderColorRest,${tokens.colorNeutralStroke1})`,
buttonBorderColorHover: `var(--buttonBorderColorHover,${tokens.colorNeutralStroke1Hover})`,
buttonBorderColorPressed: `var(--buttonBorderColorPressed,${tokens.colorNeutralStroke1Pressed})`,
buttonSecondaryBackgroundColorHover: `var(--buttonBackgroundColorHover,${tokens.colorNeutralBackground1Hover})`,
buttonSecondaryBorderColorHover: `var(--buttonBorderColorHover,${tokens.colorNeutralStroke1Hover})`,
buttonSecondaryForegroundColorHover: `var(--buttonForegroundColorHover,${tokens.colorNeutralForeground1Hover})`,

// typography
buttonFontFamily: `var(--buttonFontFamily,${tokens.fontFamilyBase})`,
buttonSecondaryBackgroundColorPressed: `var(--buttonBackgroundColorPressed,${tokens.colorNeutralBackground1Pressed})`,
buttonSecondaryBorderColorPressed: `var(--buttonBorderColorPressed,${tokens.colorNeutralStroke1Pressed})`,
buttonSecondaryForegroundColorPressed: `var(--buttonForegroundColorPressed,${tokens.colorNeutralForeground1Pressed})`,

// Primary
buttonPrimaryBackgroundColorRest: `var(--buttonPrimaryBackgroundColorRest,${tokens.colorBrandBackground})`,
buttonPrimaryForegroundColorRest: `var(--buttonPrimaryForegroundColorRest,${tokens.colorNeutralForegroundOnBrand})`,

buttonPrimaryBackgroundColorHover: `var(--buttonPrimaryBackgroundColorHover,${tokens.colorBrandBackgroundHover})`,
buttonPrimaryForegroundColorHover: `var(--buttonPrimaryForegroundColorHover,${tokens.colorNeutralForegroundOnBrand})`,

buttonPrimaryBackgroundColorPressed: `var(--buttonPrimaryBackgroundColorPressed,${tokens.colorBrandBackgroundPressed})`,
buttonPrimaryForegroundColorPressed: `var(--buttonPrimaryForegroundColorPressed,${tokens.colorNeutralForegroundOnBrand})`,

// Outline
buttonOutlineBackgroundColorRest: `var(--buttonOutlineBackgroundColorRest,${tokens.colorTransparentBackgroundRest})`,
buttonOutlineBackgroundColorHover: `var(--buttonOutlineBackgroundColorHover,${tokens.colorTransparentBackgroundRest})`,
buttonOutlineBackgroundColorPressed: `var(--buttonOutlineBackgroundColorPressed,${tokens.colorTransparentBackgroundRest})`,

// Subtle
buttonSubtleBackgroundColorRest: `var(--buttonSubtleBackgroundColorRest,${tokens.colorSubtleBackground})`,
buttonSubtleForegroundColorRest: `var(--buttonSubtleForegroundColorRest,${tokens.colorNeutralForeground2})`,

buttonSubtleBackgroundColorHover: `var(--buttonSubtleBackgroundColorHover,${tokens.colorSubtleBackgroundHover})`,
buttonSubtleForegroundColorHover: `var(--buttonSubtleForegroundColorHover,${tokens.colorNeutralForeground2Hover})`,

buttonSubtleBackgroundColorPressed: `var(--buttonSubtleBackgroundColorPressed,${tokens.colorSubtleBackgroundPressed})`,
buttonSubtleForegroundColorPressed: `var(--buttonSubtleForegroundColorPressed,${tokens.colorNeutralForeground2Pressed})`,

// Transparent
buttonTransparentBackgroundColorRest: `var(--buttonTransparentBackgroundColorRest,${tokens.colorTransparentBackground})`,
buttonTransparentForegroundColorRest: `var(--buttonTransparentForegroundColorRest,${tokens.colorNeutralForeground2})`,

buttonTransparentBackgroundColorHover: `var(--buttonTransparentBackgroundColorHover,${tokens.colorTransparentBackgroundHover})`,
buttonTransparentForegroundColorHover: `var(--buttonTransparentForegroundColorHover,${tokens.colorNeutralForeground2BrandHover})`,

buttonTransparentBackgroundColorPressed: `var(--buttonTransparentBackgroundColorPressed,${tokens.colorTransparentBackgroundPressed})`,
buttonTransparentForegroundColorPressed: `var(--buttonTransparentForegroundColorPressed,${tokens.colorNeutralForeground2BrandPressed})`,
};

export const buttonTokens = {
// colors
ctrlButtonBackgroundColorRest: `var(--ctrlButtonBackgroundColorRest,${buttonGroupTokens.buttonBackgroundColorRest})`,
ctrlButtonBackgroundColorHover: `var(--ctrlButtonBackgroundColorHover,${buttonGroupTokens.buttonBackgroundColorHover})`,
ctrlButtonBackgroundColorPressed: `var(--ctrlButtonBackgroundColorPressed,${buttonGroupTokens.buttonBackgroundColorPressed})`,
// Default
ctrlButtonBorderRadius: `var(--ctrlButtonBorderRadius, ${buttonGroupTokens.buttonBorderRadius})`,
ctrlButtonFontFamily: `var(--ctrlButtonFontFamily,${buttonGroupTokens.buttonFontFamily})`,

ctrlButtonForegroundColorRest: `var(--ctrlButtonForegroundColorRest,${buttonGroupTokens.buttonForegroundColorRest})`,
ctrlButtonForegroundColorHover: `var(--ctrlButtonForegroundColorHover,${buttonGroupTokens.buttonForegroundColorHover})`,
ctrlButtonForegroundColorPressed: `var(--ctrlButtonForegroundColorPressed,${buttonGroupTokens.buttonForegroundColorPressed})`,
// Secondary
ctrlButtonSecondaryBackgroundColorRest: `var(--ctrlButtonSecondaryBackgroundColorRest,${buttonGroupTokens.buttonSecondaryBackgroundColorRest})`,
ctrlButtonSecondaryBorderColorRest: `var(--ctrlButtonSecondaryBorderColorRest,${buttonGroupTokens.buttonSecondaryBorderColorRest})`,
ctrlButtonSecondaryForegroundColorRest: `var(--ctrlButtonSecondaryForegroundColorRest,${buttonGroupTokens.buttonSecondaryForegroundColorRest})`,

ctrlButtonBorderColorRest: `var(--ctrlButtonBorderColorRest,${buttonGroupTokens.buttonBorderColorRest})`,
ctrlButtonBorderColorHover: `var(--ctrlButtonBorderColorHover,${buttonGroupTokens.buttonBorderColorHover})`,
ctrlButtonBorderColorPressed: `var(--ctrlButtonBorderColorPressed,${buttonGroupTokens.buttonBorderColorPressed})`,
ctrlButtonSecondaryBackgroundColorHover: `var(--ctrlButtonSecondaryBackgroundColorHover,${buttonGroupTokens.buttonSecondaryBackgroundColorHover})`,
ctrlButtonSecondaryBorderColorHover: `var(--ctrlButtonSecondaryBorderColorHover,${buttonGroupTokens.buttonSecondaryBorderColorHover})`,
ctrlButtonSecondaryForegroundColorHover: `var(--ctrlButtonSecondaryForegroundColorHover,${buttonGroupTokens.buttonSecondaryForegroundColorHover})`,

// typography
ctrlButtonFontFamily: `var(--ctrlButtonFontFamily,${buttonGroupTokens.buttonFontFamily})`,
ctrlButtonSecondaryBackgroundColorPressed: `var(--ctrlButtonSecondaryBackgroundColorPressed,${buttonGroupTokens.buttonSecondaryBackgroundColorPressed})`,
ctrlButtonSecondaryBorderColorPressed: `var(--ctrlButtonSecondaryBorderColorPressed,${buttonGroupTokens.buttonSecondaryBorderColorPressed})`,
ctrlButtonSecondaryForegroundColorPressed: `var(--ctrlButtonSecondaryForegroundColorPressed,${buttonGroupTokens.buttonSecondaryForegroundColorPressed})`,

// Primary
ctrlButtonPrimaryBackgroundColorRest: `var(--ctrlButtonPrimaryBackgroundColorRest,${buttonGroupTokens.buttonPrimaryBackgroundColorRest})`,
ctrlButtonPrimaryForegroundColorRest: `var(--ctrlButtonPrimaryForegroundColorRest,${buttonGroupTokens.buttonPrimaryForegroundColorRest})`,

ctrlButtonPrimaryBackgroundColorHover: `var(--ctrlButtonPrimaryBackgroundColorHover,${buttonGroupTokens.buttonPrimaryBackgroundColorHover})`,
ctrlButtonPrimaryForegroundColorHover: `var(--ctrlButtonPrimaryForegroundColorHover,${buttonGroupTokens.buttonPrimaryForegroundColorHover})`,

ctrlButtonPrimaryBackgroundColorPressed: `var(--ctrlButtonPrimaryBackgroundColorPressed,${buttonGroupTokens.buttonPrimaryBackgroundColorPressed})`,
ctrlButtonPrimaryForegroundColorPressed: `var(--ctrlButtonPrimaryForegroundColorPressed,${buttonGroupTokens.buttonPrimaryForegroundColorPressed})`,

// Outline
ctrlButtonOutlineBackgroundColorRest: `var(--ctrlButtonOutlineBackgroundColorRest,${buttonGroupTokens.buttonOutlineBackgroundColorRest})`,
ctrlButtonOutlineBackgroundColorHover: `var(--ctrlButtonOutlineBackgroundColorHover,${buttonGroupTokens.buttonOutlineBackgroundColorHover})`,
ctrlButtonOutlineBackgroundColorPressed: `var(--ctrlButtonOutlineBackgroundColorPressed,${buttonGroupTokens.buttonOutlineBackgroundColorPressed})`,

// Subtle
ctrlButtonSubtleBackgroundColorRest: `var(--ctrlButtonSubtleBackgroundColorRest,${buttonGroupTokens.buttonSubtleBackgroundColorRest})`,
ctrlButtonSubtleForegroundColorRest: `var(--ctrlButtonSubtleForegroundColorRest,${buttonGroupTokens.buttonSubtleForegroundColorRest})`,

ctrlButtonSubtleBackgroundColorHover: `var(--ctrlButtonSubtleBackgroundColorHover,${buttonGroupTokens.buttonSubtleBackgroundColorHover})`,
ctrlButtonSubtleForegroundColorHover: `var(--ctrlButtonSubtleForegroundColorHover,${buttonGroupTokens.buttonSubtleForegroundColorHover})`,

ctrlButtonSubtleBackgroundColorPressed: `var(--ctrlButtonSubtleBackgroundColorPressed,${buttonGroupTokens.buttonSubtleBackgroundColorPressed})`,
ctrlButtonSubtleForegroundColorPressed: `var(--ctrlButtonSubtleForegroundColorPressed,${buttonGroupTokens.buttonSubtleForegroundColorPressed})`,

// Transparent
ctrlButtonTransparentBackgroundColorRest: `var(--ctrlButtonTransparentBackgroundColorRest,${buttonGroupTokens.buttonTransparentBackgroundColorRest})`,
ctrlButtonTransparentForegroundColorRest: `var(--ctrlButtonTransparentForegroundColorRest,${buttonGroupTokens.buttonTransparentForegroundColorRest})`,

ctrlButtonTransparentBackgroundColorHover: `var(--ctrlButtonTransparentBackgroundColorHover,${buttonGroupTokens.buttonTransparentBackgroundColorHover})`,
ctrlButtonTransparentForegroundColorHover: `var(--ctrlButtonTransparentForegroundColorHover,${buttonGroupTokens.buttonTransparentForegroundColorHover})`,

ctrlButtonTransparentBackgroundColorPressed: `var(--ctrlButtonTransparentBackgroundColorPressed,${buttonGroupTokens.buttonTransparentBackgroundColorPressed})`,
ctrlButtonTransparentForegroundColorPressed: `var(--ctrlButtonTransparentForegroundColorPressed,${buttonGroupTokens.buttonTransparentForegroundColorPressed})`,
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,32 @@ const useRootBaseClassName = makeResetStyles({
margin: 0,
overflow: 'hidden',

backgroundColor: buttonTokens.ctrlButtonBackgroundColorRest,
color: buttonTokens.ctrlButtonForegroundColorRest,
border: `${tokens.strokeWidthThin} solid ${buttonTokens.ctrlButtonBorderColorRest}`,
backgroundColor: buttonTokens.ctrlButtonSecondaryBackgroundColorRest,
color: buttonTokens.ctrlButtonSecondaryForegroundColorRest,
border: `${tokens.strokeWidthThin} solid ${buttonTokens.ctrlButtonSecondaryBorderColorRest}`,

fontFamily: buttonTokens.ctrlButtonFontFamily,
outlineStyle: 'none',

':hover': {
backgroundColor: buttonTokens.ctrlButtonBackgroundColorHover,
borderColor: buttonTokens.ctrlButtonBorderColorHover,
color: buttonTokens.ctrlButtonForegroundColorHover,
backgroundColor: buttonTokens.ctrlButtonSecondaryBackgroundColorHover,
borderColor: buttonTokens.ctrlButtonSecondaryBorderColorHover,
color: buttonTokens.ctrlButtonSecondaryForegroundColorHover,

cursor: 'pointer',
},

':hover:active': {
backgroundColor: buttonTokens.ctrlButtonBackgroundColorPressed,
borderColor: buttonTokens.ctrlButtonBorderColorPressed,
color: buttonTokens.ctrlButtonForegroundColorPressed,
backgroundColor: buttonTokens.ctrlButtonSecondaryBackgroundColorPressed,
borderColor: buttonTokens.ctrlButtonSecondaryBorderColorPressed,
color: buttonTokens.ctrlButtonSecondaryForegroundColorPressed,

outlineStyle: 'none',
},

padding: `${buttonSpacingMedium} ${tokens.spacingHorizontalM}`,
minWidth: '96px',
borderRadius: tokens.borderRadiusMedium,
borderRadius: buttonTokens.ctrlButtonBorderRadius,

fontSize: tokens.fontSizeBase300,
fontWeight: tokens.fontWeightSemibold,
Expand Down Expand Up @@ -103,7 +103,7 @@ const useRootBaseClassName = makeResetStyles({

...createCustomFocusIndicatorStyle({
borderColor: tokens.colorStrokeFocus2,
borderRadius: tokens.borderRadiusMedium,
borderRadius: buttonTokens.ctrlButtonBorderRadius,
borderWidth: '1px',
outline: `${tokens.strokeWidthThick} solid ${tokens.colorTransparentStroke}`,
boxShadow: `0 0 0 ${tokens.strokeWidthThin} ${tokens.colorStrokeFocus2}
Expand Down Expand Up @@ -137,31 +137,31 @@ const useIconBaseClassName = makeResetStyles({
const useRootStyles = makeStyles({
// Appearance variations
outline: {
backgroundColor: tokens.colorTransparentBackground,
backgroundColor: buttonTokens.ctrlButtonOutlineBackgroundColorRest,

':hover': {
backgroundColor: tokens.colorTransparentBackgroundHover,
backgroundColor: buttonTokens.ctrlButtonOutlineBackgroundColorHover,
},

':hover:active': {
backgroundColor: tokens.colorTransparentBackgroundPressed,
backgroundColor: buttonTokens.ctrlButtonOutlineBackgroundColorPressed,
},
},
primary: {
backgroundColor: tokens.colorBrandBackground,
backgroundColor: buttonTokens.ctrlButtonPrimaryBackgroundColorRest,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForegroundOnBrand,
color: buttonTokens.ctrlButtonPrimaryForegroundColorRest,

':hover': {
backgroundColor: tokens.colorBrandBackgroundHover,
backgroundColor: buttonTokens.ctrlButtonPrimaryBackgroundColorHover,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForegroundOnBrand,
color: buttonTokens.ctrlButtonPrimaryForegroundColorHover,
},

':hover:active': {
backgroundColor: tokens.colorBrandBackgroundPressed,
backgroundColor: buttonTokens.ctrlButtonPrimaryBackgroundColorPressed,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForegroundOnBrand,
color: buttonTokens.ctrlButtonPrimaryForegroundColorPressed,
},

'@media (forced-colors: active)': {
Expand All @@ -187,14 +187,14 @@ const useRootStyles = makeStyles({
/* The secondary styles are exactly the same as the base styles. */
},
subtle: {
backgroundColor: tokens.colorSubtleBackground,
backgroundColor: buttonTokens.ctrlButtonSubtleBackgroundColorRest,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2,
color: buttonTokens.ctrlButtonSubtleForegroundColorRest,

':hover': {
backgroundColor: tokens.colorSubtleBackgroundHover,
backgroundColor: buttonTokens.ctrlButtonSubtleBackgroundColorHover,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2Hover,
color: buttonTokens.ctrlButtonSubtleForegroundColorHover,
[`& .${iconFilledClassName}`]: {
display: 'inline',
},
Expand All @@ -207,9 +207,9 @@ const useRootStyles = makeStyles({
},

':hover:active': {
backgroundColor: tokens.colorSubtleBackgroundPressed,
backgroundColor: buttonTokens.ctrlButtonSubtleBackgroundColorPressed,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2Pressed,
color: buttonTokens.ctrlButtonSubtleForegroundColorPressed,
[`& .${iconFilledClassName}`]: {
display: 'inline',
},
Expand Down Expand Up @@ -239,14 +239,14 @@ const useRootStyles = makeStyles({
},
},
transparent: {
backgroundColor: tokens.colorTransparentBackground,
backgroundColor: buttonTokens.ctrlButtonTransparentBackgroundColorRest,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2,
color: buttonTokens.ctrlButtonTransparentForegroundColorRest,

':hover': {
backgroundColor: tokens.colorTransparentBackgroundHover,
backgroundColor: buttonTokens.ctrlButtonTransparentBackgroundColorHover,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2BrandHover,
color: buttonTokens.ctrlButtonTransparentForegroundColorHover,
[`& .${iconFilledClassName}`]: {
display: 'inline',
},
Expand All @@ -256,9 +256,9 @@ const useRootStyles = makeStyles({
},

':hover:active': {
backgroundColor: tokens.colorTransparentBackgroundPressed,
backgroundColor: buttonTokens.ctrlButtonTransparentBackgroundColorPressed,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2BrandPressed,
color: buttonTokens.ctrlButtonTransparentForegroundColorPressed,
[`& .${iconFilledClassName}`]: {
display: 'inline',
},
Expand Down Expand Up @@ -295,7 +295,7 @@ const useRootStyles = makeStyles({
minWidth: '64px',
...shorthands.padding(buttonSpacingSmall, tokens.spacingHorizontalS),

...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.borderRadius(buttonTokens.ctrlButtonBorderRadius),

fontSize: tokens.fontSizeBase200,
fontWeight: tokens.fontWeightRegular,
Expand All @@ -312,7 +312,7 @@ const useRootStyles = makeStyles({
minWidth: '96px',
...shorthands.padding(buttonSpacingLarge, tokens.spacingHorizontalL),

...shorthands.borderRadius(tokens.borderRadiusMedium),
...shorthands.borderRadius(buttonTokens.ctrlButtonBorderRadius),

fontSize: tokens.fontSizeBase400,
fontWeight: tokens.fontWeightSemibold,
Expand Down
Loading

0 comments on commit 6cd9ff5

Please sign in to comment.