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

UI lib - new theme colors #7375

Merged
merged 6 commits into from
Aug 14, 2022
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
31 changes: 30 additions & 1 deletion src/@chakra-ui/gatsby-plugin/foundations/colors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
export type Colors = typeof colors

const colors = {}
const colors = {
grey: {
100: "#f7f7f7",
300: "#d4d4d4",
500: "#646464",
700: "#222222",
900: "#141414",
},
blue: {
100: "#e8e8ff",
300: "#8d8dff",
500: "#1c1cff",
700: "#0b0b66",
},
orange: {
100: "#ffe3d3",
300: "#ffb991",
500: "#ff7324",
800: "#451900",
},
red: {
600: "#b80000",
},
green: {
500: "#109e62",
},
yellow: {
200: "#fff8df",
},
}

export default colors
47 changes: 47 additions & 0 deletions src/@chakra-ui/gatsby-plugin/semanticTokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {
lightTheme as oldLightTheme,
darkTheme as oldDarkTheme,
} from "../../theme"

const oldLightThemeColors = oldLightTheme.colors
const oldDarkThemeColors = oldDarkTheme.colors

// define each of the old colors as a `semanticToken`:
// `name: { _light: lightColor, _dark: darkColor }`
const oldColors = Object.keys(oldLightThemeColors).reduce((colors, color) => {
const lightColor = oldLightThemeColors[color]
const darkColor = oldDarkThemeColors[color]

if (typeof lightColor !== "string" || typeof darkColor !== "string") {
return colors
}

return {
...colors,
[color]: { _light: lightColor, _dark: darkColor },
}
}, {})

const semanticTokens = {
colors: {
// define old colors from the old theme as semanticTokens to transition
// from emotion components to chakra
// TODO: remove these colors as we migrate away from them
...oldColors,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is to do the migration as seamless as possible. Detailed in the migration guide under the ## Theme colors header. #7368
The idea is that we keep using the same color variable names.


// Design System colors
primary: { _light: "blue.500", _dark: "orange.500" },
primaryDark: { _light: "blue.700", _dark: "orange.800" },
primaryHover: { _light: "blue.300", _dark: "orange.300" },
pettinarip marked this conversation as resolved.
Show resolved Hide resolved
primaryLight: { _light: "blue.100", _dark: "orange.100"},
body: { _light: "grey.700", _dark: "grey.100" },
bodyLight: { _light: "grey.500", _dark: "grey.100" },
disabled: { _light: "grey.300", _dark: "grey.500" },
background: { _light: "white", _dark: "grey.700" },
success: "green.500",
error: "red.600",
attention: "yellow.200",
},
}

export default semanticTokens
3 changes: 3 additions & 0 deletions src/@chakra-ui/gatsby-plugin/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import styles from "./styles"
// Foundational style overrides
import foundations from "./foundations"

import semanticTokens from "./semanticTokens"

const config: ThemeConfig = {
cssVarPrefix: "eth",
initialColorMode: "light",
Expand All @@ -20,6 +22,7 @@ const theme: ThemeOverride = {
config,
styles,
...foundations,
semanticTokens,
}

export default extendTheme(theme)