diff --git a/.changeset/lucky-queens-draw.md b/.changeset/lucky-queens-draw.md new file mode 100644 index 00000000..711532be --- /dev/null +++ b/.changeset/lucky-queens-draw.md @@ -0,0 +1,5 @@ +--- +"@cambly/syntax-core": minor +--- + +Button/Badge: various Cambio updates diff --git a/packages/syntax-core/src/Badge/Badge.stories.tsx b/packages/syntax-core/src/Badge/Badge.stories.tsx index 2c755864..5512aad0 100644 --- a/packages/syntax-core/src/Badge/Badge.stories.tsx +++ b/packages/syntax-core/src/Badge/Badge.stories.tsx @@ -14,6 +14,7 @@ export default { argTypes: { color: { options: [ + // Classic "gray200", "gray900", "destructive700", @@ -22,6 +23,17 @@ export default { "success700", "primary700", "purple700", + // Cambio + "sky", + "success300", + "destructive300", + "orange", + "tan", + "gray370", + "gray870", + "lilac", + "thistle", + "pink", ], control: { type: "radio" }, }, diff --git a/packages/syntax-core/src/Badge/Badge.tsx b/packages/syntax-core/src/Badge/Badge.tsx index a5993b14..78ed1333 100644 --- a/packages/syntax-core/src/Badge/Badge.tsx +++ b/packages/syntax-core/src/Badge/Badge.tsx @@ -3,7 +3,7 @@ import Box from "../Box/Box"; import styles from "./Badge.module.css"; import { useTheme } from "../ThemeProvider/ThemeProvider"; -const BadgeColor = [ +const badgeColorClassic = [ "gray200", "gray900", "destructive700", @@ -14,13 +14,57 @@ const BadgeColor = [ "purple700", ] as const; +const badgeColorCambio = [ + "sky", + "success300", + "destructive300", + "orange", + "tan", + "gray370", + "gray870", + "lilac", + "thistle", + "pink", +] as const; + +const badgeColorClassicToCambio = { + gray200: "gray370", + gray900: "gray870", + destructive700: "destructive300", + orange700: "orange", + yellow700: "tan", + success700: "success300", + primary700: "sky", + purple700: "lilac", + sky: "sky", + success300: "success300", + destructive300: "destructive300", + orange: "orange", + tan: "tan", + gray370: "gray370", + gray870: "gray870", + lilac: "lilac", + thistle: "thistle", + pink: "pink", +} as const; + const textColorForBackgroundColor = ( - color: (typeof BadgeColor)[number], + color: (typeof badgeColorClassic)[number] | (typeof badgeColorCambio)[number], ): "gray900" | "white" => { switch (color) { case "gray200": case "yellow700": return "gray900"; + case "gray370": + case "destructive300": + case "orange": + case "tan": + case "success300": + case "sky": + case "thistle": + case "pink": + case "lilac": + return "gray900"; default: return "white"; } @@ -45,28 +89,55 @@ const Badge = ({ /** * The color of the badge * + * Classic colors: + * * `gray200` => maps to neutralLight in Cambio + * * `gray900` => maps to neutralDark in Cambio + * * `destructive700` => maps to destructive in Cambio + * * `orange700` => maps to orange in Cambio + * * `yellow700` => maps to tan in Cambio + * * `success700` => maps to success in Cambio + * * `primary700` => maps to sky in Cambio + * * `purple700` => maps to lilac in Cambio + * + * Cambio colors: + * * `sky` + * * `success300` + * * `destructive300` + * * `orange` + * * `tan` + * * `gray370` + * * `gray870` + * * `lilac` + * * `thistle` + * * `pink` + * * @defaultValue "primary700" */ - color?: (typeof BadgeColor)[number]; + color?: + | (typeof badgeColorClassic)[number] + | (typeof badgeColorCambio)[number]; }): JSX.Element => { const { themeName } = useTheme(); + const mappedColor = + themeName === "cambio" ? badgeColorClassicToCambio[color] : color; + return ( - + {Icon && } diff --git a/packages/syntax-core/src/Box/Box.stories.tsx b/packages/syntax-core/src/Box/Box.stories.tsx index e53a31cb..730c6623 100644 --- a/packages/syntax-core/src/Box/Box.stories.tsx +++ b/packages/syntax-core/src/Box/Box.stories.tsx @@ -288,7 +288,7 @@ export const Margin: StoryObj = { alignItems="center" justifyContent="center" > - + margin="{margin}" diff --git a/packages/syntax-core/src/Button/Button.module.css b/packages/syntax-core/src/Button/Button.module.css index 2ae0cd6a..0bac827b 100644 --- a/packages/syntax-core/src/Button/Button.module.css +++ b/packages/syntax-core/src/Button/Button.module.css @@ -47,6 +47,10 @@ cursor: auto; } +.disabledCambioPrimary { + opacity: 0.5; +} + .fullWidth { width: 100%; } diff --git a/packages/syntax-core/src/Button/Button.tsx b/packages/syntax-core/src/Button/Button.tsx index 3f0ceb47..131887ab 100644 --- a/packages/syntax-core/src/Button/Button.tsx +++ b/packages/syntax-core/src/Button/Button.tsx @@ -162,6 +162,9 @@ const Button = forwardRef( ? classicBackgroundColor(classicColor(color)) : cambioBackgroundColor(cambioColor(color), on); + const disabledCambioPrimary = + themeName === "cambio" && color === "primary" && disabled; + return (