-
Notifications
You must be signed in to change notification settings - Fork 15
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
Adding CSS and JS token display in storybook #594
Conversation
@@ -17,7 +17,7 @@ _The majority of our brand color progressions were generated using the [0to255]( | |||
|
|||
## Brand colors | |||
|
|||
<Canvas of={BrandColorStories.DefaultStory} /> | |||
<Canvas of={BrandColorStories.Figma} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating reference to brand color story in MDX docs so it still renders
@@ -18,7 +21,26 @@ export default meta; | |||
|
|||
type Story = StoryObj<typeof ColorSwatchGroup>; | |||
|
|||
export const DefaultStory: Story = { | |||
export const Figma: Story = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming stories to align with their format Figma
, CSS
, JS
@@ -16,13 +16,13 @@ For most use cases, these function-based color tokens should be your first choic | |||
|
|||
The light theme colors are designed to be used in the styles for MetaMask UI when the light theme is active | |||
|
|||
<Canvas of={ThemeColorStories.LightThemeColors} /> | |||
<Canvas of={ThemeColorStories.FigmaLightTheme} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating story name references in MDX so they still render as intended
// CSS | ||
import lightThemeCss from './data/lightTheme.json'; | ||
import darkThemeCss from './data/darkTheme.json'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imports all the different token data for each format
name="Primary Default" | ||
/> | ||
), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -49,6 +49,7 @@ export const ColorSwatch: FunctionComponent<ColorSwatchProps> = ({ | |||
backgroundColor: textBackgroundColor, | |||
padding: 8, | |||
borderRadius: '0 0 8px 8px', | |||
color: textColor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
including text color so we can adjust the display of swatches for dark mode
name="Color Swatch Group" | ||
/> | ||
), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
02dbb29
to
6798d5b
Compare
6798d5b
to
76df8db
Compare
@@ -3,7 +3,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react'; | |||
import { Text } from '.'; | |||
|
|||
export default { | |||
title: 'Doc components/Text', | |||
title: 'Documentation Components/Text', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just updating "Doc" to "Documentation" as it's bumped to 2 lines anyway
@@ -5,7 +5,7 @@ interface Props<C extends React.ElementType> { | |||
/** | |||
* The children or content of the Text component | |||
*/ | |||
children?: React.ReactChild; | |||
children?: React.ReactNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | ||
* The color prop of the Text component | ||
*/ | ||
color?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding color prop and setting the default to text/default to fix bug with shadows with this inclusion of CSS variable stories
Before
before.text.mov
After
after.text.mov
…d and theme tokens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just need to fix that merge conflict
@@ -37,7 +37,7 @@ export const brandColor: BrandColor = { | |||
orange300: '#faa66c', | |||
orange400: '#f8883b', | |||
orange500: '#f66a0a', | |||
orange600: '#c65507', | |||
orange600: '#bf5208', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank goodness for tests. This fixes some wrong color values after #586 got merged and fixes failing test on main https://github.com/MetaMask/design-tokens/actions/runs/7644751686/job/20829744608
Description
Previously, we didn't have a way to visualize the changes in CSS, and JavaScript color tokens. The current storybook renders the Figma token json. So we had to manually ensure that the hex values were the same across all these platforms. This process was prone to errors and inconsistencies.
This PR introduces a rudimentary visualization of the CSS and JS color tokens along with the Figma token json. Now, we can visually check that any token updates are correctly reflected across all token formats. This will help us maintain consistency and catch any discrepancies early.
How it works
lightTheme
anddarkTheme
objects. Brand colors will be added in the near futureFixes: #595
Screenshots/Screencasts
Before
before720.mov
After
after720.mov
Manual Testing
To manually test the changes, check the Storybook build in this PR. You can also pull the branch and run the following command to run the script and generate the JSON data:
This will create a JSON file in the
docs/data
directory. You can then use this data in your Storybook stories to visualize the color tokens.This PR helps us maintain consistency across our color tokens and makes it easier to update and verify these tokens.