Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit 28944fe

Browse files
refactor: updating deprecated components and updating docs
1 parent 6e74c59 commit 28944fe

File tree

9 files changed

+182
-106
lines changed

9 files changed

+182
-106
lines changed

docs/BrandColors.mdx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import { Meta, Canvas, Story } from '@storybook/addon-docs';
2-
import LinkTo from '@storybook/addon-links/react';
1+
import { Canvas, Meta } from '@storybook/blocks';
2+
import * as BrandColorStories from './BrandColors.stories';
33

4-
<Meta title="Design Tokens/Brand Colors" />
4+
<Meta of={BrandColorStories} />
55

6-
# Brand Colors (first tier)
6+
# Brand Colors (First Tier)
77

8-
Brand specific colors used in the first tier of design token abstraction. They **should not** be used in the code directly but referenced by [**Theme Colors**](/docs/colors-themecolors--light-theme-colors) used in second tier tokens. Most brand color progressions were generated using [0to255](https://0to255.com/037dd6)
8+
The first tier of our design token abstraction consists of brand-specific colors. These colors uses literal color names (like red, green, etc.) and a numeric scale (where 000 is light and 900 is dark) by default.They form the foundation of our design system and are essential to maintaining visual consistency across our products.
99

10-
<Canvas>
11-
<Story id="colors-brandcolors--default-story" />
12-
</Canvas>
10+
While these colors are fundamental to our design system, they **should not** be used directly in most cases. The exception is when a color needs to remain the same regardless of the theme (light or dark mode). Instead, these brand colors should be referenced via [**theme colors**](/docs/colors-themecolors--light-theme-colors), which form the second tier of our design tokens.
11+
12+
The majority of our brand color progressions were generated using the [0to255](https://0to255.com/037dd6) tool, which helps ensure smooth and consistent color transitions.
13+
14+
<Canvas of={BrandColorStories.DefaultStory} />
1315

1416
## References
1517

16-
- [Tool used to generate colors](http://www.0to255.com/037DD6)
17-
- [Figma Brand Colors Library](https://www.figma.com/file/cBAUPFMnbv6tHR1J8KvBI2/Brand-Colors?node-id=0%3A1)(internal use only)
18+
- [0to255](http://www.0to255.com/037DD6): The tool we used to generate our color progressions.
19+
- [Figma Brand Colors Library](https://www.figma.com/file/cBAUPFMnbv6tHR1J8KvBI2/Brand-Colors?node-id=0%3A1): Our internal Figma library for brand colors. Please note that this is for internal use only.

docs/BrandColors.stories.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
import { ComponentStory, ComponentMeta } from '@storybook/react';
1+
import React from 'react';
2+
import type { Meta, StoryObj } from '@storybook/react';
23
import tokens from '../src/figma/tokens.json';
3-
44
import { ColorSwatchGroup } from './components';
5-
65
import README from './BrandColors.mdx';
76

8-
export default {
7+
const meta: Meta<typeof ColorSwatchGroup> = {
98
title: 'Colors/BrandColors',
9+
component: ColorSwatchGroup,
1010
parameters: {
1111
docs: {
1212
page: README,
1313
},
1414
},
15-
} as ComponentMeta<typeof ColorSwatchGroup>;
15+
};
1616

17-
const Template: ComponentStory<typeof ColorSwatchGroup> = (args) => (
18-
<ColorSwatchGroup {...args} />
19-
);
17+
export default meta;
2018

21-
export const DefaultStory = Template.bind({});
19+
type Story = StoryObj<typeof ColorSwatchGroup>;
2220

23-
DefaultStory.args = {
24-
swatchData: tokens.global.brandColors,
21+
export const DefaultStory: Story = {
22+
render: () => <ColorSwatchGroup swatchData={tokens.global.brandColors} />,
23+
name: 'Default',
2524
};
26-
27-
DefaultStory.storyName = 'Default';

docs/IntroductionColor.stories.mdx

Lines changed: 95 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import { lightTheme } from '../src/index.ts';
77

88
# Color
99

10-
Color is used to express style and communicate meaning.
11-
12-
## Token Tiers
13-
14-
We follow a 3 tiered system for color design tokens.
10+
Color is a powerful tool in design. It can express style, convey meaning, and establish visual hierarchy. In our design system, we manage colors through a three-tiered system of design tokens.
1511

1612
<div
1713
style={{
@@ -26,26 +22,109 @@ We follow a 3 tiered system for color design tokens.
2622
<br />
2723
<br />
2824

29-
### **Brand colors** (first tier)
25+
## Token tiers
3026

31-
These colors **SHOULD NOT** be used in your component styles directly. They are used as a reference for the [Theme Colors](/docs/colors-themecolors--light-theme-colors). Brand colors are used to keep track of all colors used in our app. See [Brand Colors](/docs/colors-brandcolors--default-story)
27+
### **Brand colors (first tier)**
3228

33-
### **Theme Colors** (second tier)
29+
Brand colors form the foundation of our color system. However, in most cases they **SHOULD NOT** be used directly in component styles. Instead, they serve as a reference for the [Theme Colors](/docs/colors-themecolors--light-theme-colors). You can view our brand colors in the [Brand Colors](/docs/colors-brandcolors--default-story) section.
3430

35-
These colors are color agnostic, semantically neutral and theme compatible design tokens that you can use in your code and styles. Please refer to the description of each token for it's intended purpose. See [Theme Colors](/docs/colors-themecolors--light-theme-colors)
31+
### **Theme colors (second tier)**
3632

37-
### **Component colors** (third tier)
33+
Theme colors are semantically neutral, theme-compatible design tokens that you can use directly in your code and styles. Each token has a specific purpose, which is described in its documentation. You can view our theme colors in the [Theme Colors](/docs/colors-themecolors--light-theme-colors) section.
3834

39-
Another level of abstraction is component colors that you can use at a component specific level. We do not currently provide any component tier colors but that may change in future.
35+
### **Component colors (third tier)**
4036

41-
## Takeaways
37+
Component colors provide another level of abstraction for component-specific colors. We currently do not provide any component tier colors, but this may change in the future.
4238

43-
- Do not use static HEX values in your code. Use the [Theme Colors](/docs/colors-themecolors--light-theme-colors). If one does not exist for your use case [create an issue](https://github.com/MetaMask/design-tokens/issues/new) and tag it with a `color` label.
44-
- Make sure the design token you are using is for it's intended purpose. Please refer to the description of each token.
39+
## Best practices
4540

46-
### Next 👉 [Theme Colors](/docs/colors-themecolors--light-theme-colors)
41+
### **Prioritize theme colors**
4742

48-
<br />
43+
Theme colors should be your go-to choice for 99% of use cases. Using theme tokens ensures that the UI works across all themes and modes. We have built-in accessibility and functionality into the theme colors to ensure this. By using theme colors, you're leveraging these benefits and ensuring a consistent and accessible color scheme across your project.
44+
45+
#### **DO**: Use theme colors in your components
46+
47+
```
48+
background-color: theme.colors.background.default;
49+
background-color: var(--color-background-default);
50+
```
51+
52+
#### **DON'T**: Use static color values or brand colors in your components
53+
54+
```
55+
background-color: #ffffff; // Static color value
56+
background-color: brandColors.white.white000; // Brand color
57+
background-color: var(--brand-colors-white-white000); // Brand color
58+
```
59+
60+
### **Use brand colors for theme-independent colors**
61+
62+
In the rare case where a color should remain the same regardless of the theme (for instance, if white should always be white, regardless of whether light or dark mode is active), use the corresponding brand color. However, always check first to ensure that there isn't an existing theme token that suits your needs.
63+
64+
#### **DO**: Use brand colors when the color should remain the same across all themes
65+
66+
```
67+
fill: brandColors.white.white000;
68+
fill: var(--brand-colors-white-white000);
69+
```
70+
71+
#### **DON'T**: Use brand colors without checking for an existing theme token first
72+
73+
```
74+
background-color: brandColors.blue.blue500; // Brand color instead of theme.color.primary.default
75+
background-color: var(--brand-colors-blue-blue500); // Brand color instead of var(--color-primary-default)
76+
```
77+
78+
### **Avoid static color values**
79+
80+
As a general rule, avoid applying static color values at the component level. This helps maintain consistency and makes it easier to update colors in the future.
81+
82+
#### **DO**: Use theme colors in your components
83+
84+
```
85+
background-color: theme.colors.background.default;
86+
background-color: var(--color-background-default);
87+
```
88+
89+
#### **DON'T**: Use static color values in your components
90+
91+
```jsx
92+
background-color: #ffffff; // Static color value
93+
```
94+
95+
### **Centralize non-token colors**
96+
97+
If you need to use colors that are not included in the design tokens, store these colors in a global file in your project. This makes it easier to keep track of these colors and update them as needed. Always consider this as a last resort, and strive to use design tokens wherever possible.
98+
99+
#### **DO**: Store non-token colors in a global file
100+
101+
```
102+
// colors.js
103+
export const customColors = {
104+
myCustomColor: '#abc123',
105+
};
106+
107+
// colors.css
108+
--custom-colors-my-custom-color: #abc123;
109+
110+
// component.js
111+
import { customColors } from './colors.js';
112+
113+
background-color: customColors.myCustomColor;
114+
background-color: var(--custom-colors-my-custom-color);
115+
```
116+
117+
#### **DON'T**: Use non-token colors directly in your components
118+
119+
```jsx
120+
background-color: #abc123; // Custom color not in design tokens or global file
121+
```
122+
123+
Remember, the goal of these practices is to maintain consistency across your project, make your code easier to maintain, and ensure that your project's colors align with the overall design system and MetaMask brand 🦊
124+
125+
## Next steps
126+
127+
Learn more about our [brand colors](/docs/colors-brandcolors--docs) or [theme colors](/docs/colors-themecolors--light-theme-colors) section
49128

50129
## References
51130

docs/Shadows.mdx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
import { Meta, Canvas, Story } from '@storybook/addon-docs';
2-
import LinkTo from '@storybook/addon-links/react';
2+
import * as ShadowStories from './Shadows.stories';
33

44
<Meta title="Design Tokens/Shadows" />
55

66
# Shadows
77

8-
Shadows convey elevation of elements on a surface
8+
Shadows in design are used to create depth and hierarchy. They can be used to differentiate between different elements, and to highlight interactive elements.
99

10-
<Canvas>
11-
<Story id="shadows-shadows--shadow" />
12-
</Canvas>
10+
<Canvas of={ShadowStories.DefaultStory} />
1311

1412
## Size
1513

16-
There are 4 different sizes of shadow in MetaMask.
14+
Shadows come in four different sizes: XS, SM, MD, and LG. The size of the shadow can be used to indicate the relative importance or prominence of an element.
1715

18-
<Canvas>
19-
<Story id="shadows-shadows--size" />
20-
</Canvas>
16+
<Canvas of={ShadowStories.Size} />
2117

2218
| Size | JS | CSS |
2319
| ------ | ----------------- | ----------------------- |
@@ -28,25 +24,21 @@ There are 4 different sizes of shadow in MetaMask.
2824

2925
## Color
3026

31-
As well as the neutral colors for shadow 2 other colors exist that are used for the primary and error/danger button hover states
27+
Shadows can have three different colors: default (neutral), primary, and error/danger. The color of the shadow can be used to indicate the state or functionality of an element.
3228

33-
<Canvas>
34-
<Story id="shadows-shadows--color" />
35-
</Canvas>
29+
<Canvas of={ShadowStories.Color} />
3630

3731
| Color | JS | CSS |
3832
| ----------- | ----------------------- | ----------------------------- |
3933
| **neutral** | `colors.shadow.default` | `var(--color-shadow-default)` |
4034
| **primary** | `colors.primary.shadow` | `var(--color-primary-shadow)` |
4135
| **danger** | `colors.error.shadow` | `var(--color-error-shadow)` |
4236

43-
## Example usage
37+
## Usage
4438

45-
Using both size and color tokens, different shadows can be applied to components.
39+
Shadows can be applied to various components to create depth and hierarchy. Here are some examples of how shadows can be used in different components:
4640

47-
<Canvas>
48-
<Story id="shadows-shadows--example-usage" />
49-
</Canvas>
41+
<Canvas of={ShadowStories.ExampleUsage} />
5042

5143
| Component | JS | CSS |
5244
| ------------------------ | ------------------------------------------------------------------------------- | ---------------------------------------------------------------- |

docs/Shadows.stories.tsx

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,8 @@
11
import React from 'react';
22
import { lightTheme } from '../src/js';
3-
43
import { Text } from './components';
5-
64
import README from './Shadows.mdx';
75

8-
export default {
9-
title: 'Shadows/Shadows',
10-
parameters: {
11-
docs: {
12-
page: README,
13-
},
14-
},
15-
argTypes: {
16-
size: {
17-
control: 'select',
18-
options: Object.keys(lightTheme.shadows.size),
19-
},
20-
color: {
21-
control: 'select',
22-
options: ['default', 'primary', 'error'],
23-
},
24-
},
25-
args: {
26-
color: 'default',
27-
size: 'xs',
28-
},
29-
};
30-
316
interface ShadowSwatchProps {
327
children: any;
338
style?: object;
@@ -61,8 +36,29 @@ const ShadowSwatch = ({
6136
</div>
6237
);
6338

64-
export const Shadow = (args) => {
65-
return (
39+
export default {
40+
title: 'Shadows/Shadows',
41+
component: ShadowSwatch,
42+
parameters: {
43+
docs: {
44+
page: README,
45+
},
46+
},
47+
argTypes: {
48+
size: {
49+
control: 'select',
50+
options: Object.keys(lightTheme.shadows.size),
51+
},
52+
color: {
53+
control: 'select',
54+
options: ['default', 'primary', 'error'],
55+
},
56+
},
57+
};
58+
59+
export const DefaultStory = {
60+
name: 'Default',
61+
render: (args) => (
6662
<div
6763
style={{
6864
display: 'grid',
@@ -76,11 +72,15 @@ export const Shadow = (args) => {
7672
</Text>
7773
</ShadowSwatch>
7874
</div>
79-
);
75+
),
76+
args: {
77+
color: 'default',
78+
size: 'xs',
79+
},
8080
};
8181

82-
export const Size = (args) => {
83-
return (
82+
export const Size = {
83+
render: (args) => (
8484
<div
8585
style={{
8686
display: 'grid',
@@ -109,11 +109,15 @@ export const Size = (args) => {
109109
</Text>
110110
</ShadowSwatch>
111111
</div>
112-
);
112+
),
113+
args: {
114+
color: 'default',
115+
size: 'xs',
116+
},
113117
};
114118

115-
export const Color = (args) => {
116-
return (
119+
export const Color = {
120+
render: (args) => (
117121
<div
118122
style={{
119123
display: 'grid',
@@ -151,11 +155,15 @@ export const Color = (args) => {
151155
</Text>
152156
</ShadowSwatch>
153157
</div>
154-
);
158+
),
159+
args: {
160+
color: 'default',
161+
size: 'xs',
162+
},
155163
};
156164

157-
export const ExampleUsage = () => {
158-
return (
165+
export const ExampleUsage = {
166+
render: () => (
159167
<div>
160168
<div
161169
style={{
@@ -233,5 +241,5 @@ export const ExampleUsage = () => {
233241
</ShadowSwatch>
234242
</div>
235243
</div>
236-
);
244+
),
237245
};

docs/ThemeColors.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Meta, Canvas, Story } from '@storybook/addon-docs';
22

3-
import tokens from '../src/figma/tokens.json';
4-
53
<Meta title="Design Tokens/Theme Colors" />
64

75
# Theme Colors (second tier)

0 commit comments

Comments
 (0)