Skip to content

Commit 49c5b75

Browse files
authored
Merge pull request #1840 from chanzuckerberg/release-v13.10.0
## [13.10.0](v13.9.0...v13.10.0) (2024-02-01) [Storybook](https://61313967cde49b003ae2a860-xjckjitaia.chromatic.com/) ### Features * **Select:** add ability to handle click and change event handlers ([#1839](#1839)) ([54a3de8](54a3de8)) * **Select:** add support for label prop ([#1837](#1837)) ([c032ff2](c032ff2))
2 parents 607a995 + 26885cd commit 49c5b75

13 files changed

+1106
-1047
lines changed

.storybook/components/Docs/GettingStarted.stories.mdx

+17
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,20 @@ Storybook offers several facilities to demonstrate how components behave. Some c
3030
- **Storybook View Options** allow for controlling the viewport, background color, and other details to help understand the component layout. Visually test how the component responds to different layouts
3131

3232
Storybook provides a lot of functionality, including [keyboard navigation](https://storybook.js.org/docs/react/get-started/browse-stories#sidebar-and-canvas). Explore [the docs](https://storybook.js.org/docs/react/get-started/introduction) to learn more.
33+
34+
### IDE Integrations
35+
36+
Since EDS provides many color tokens, it may prove useful to add some integrations to the IDE to show visual references for the colors in use.
37+
38+
- Install the [CSS Var Complete - VS Code Plugin](https://marketplace.visualstudio.com/items?itemName=phoenisx.cssvar) which provides better Intellisense while writing CSS and referencing CSS variables.
39+
- Add the following settings in your workspace settings file:
40+
41+
```jsonc
42+
{
43+
// ...rest of the settings here
44+
"cssvar.files": [
45+
"node_modules/@chanzuckerberg/eds/lib/index.css"
46+
]
47+
}
48+
```
49+
- Restart VSCode

.storybook/components/Docs/Guidelines/CodeGuidelines.stories.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,15 @@ You can continue to use the `Icon` components' `color` prop with JavaScript vari
301301

302302
## Tailwind utility classes <a name="tailwind-utility-classes"></a>
303303

304-
EDS uses [tailwind utility classes](https://tailwindcss.com/docs/padding) (e.g. `mb-0` and `p-0`) inline in `*.stories.tsx` files to quickly add small styling tweaks, like spacing (e.g. `<Table.Cell className="p-0">`). This reduces the need for CSS module files made specifically for stories. Use the `!` modifier to override default component styles (e.g. `<Table.Cell className="!p-0">`).
304+
EDS uses [tailwind utility classes](https://tailwindcss.com/docs/), (e.g., `mb-0` and `p-0`) inline in `*.stories.tsx` files to demonstrate allowed compositions and example implementations.
305305

306306
Consider installing the VSCode extension [Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss) for autocomplete, linting, and hover previews.
307307

308308
## Theming conventions <a name="theming-conventions"></a>
309309

310-
EDS is a [themeable design system](https://bradfrost.com/blog/post/creating-themeable-design-systems/) that incorporates some high-level UI application variables to make easy systematic changes to the UI.
310+
EDS is a [Headless design system](https://bradfrost.com/blog/post/creating-themeable-design-systems/) that incorporates some high-level UI application variables to make easy systematic changes to the UI.
311311

312-
This is a "lightly" themed system, meaning that only a few variables (such as key UI colors and other properties like border radius) are available for theming.
312+
Learn more about EDS Theming [here](./?path=?path=/docs/documentation-theming--docs).
313313

314314
### Design Tokens <a name="design-tokens"></a>
315315

.storybook/components/Docs/Guidelines/Theming.stories.mdx

+78-89
Original file line numberDiff line numberDiff line change
@@ -2,131 +2,120 @@ import { Canvas, Meta } from '@storybook/blocks';
22

33
<Meta title="Documentation/Theming" />
44

5-
# Theming overview
5+
# Theming
66

7-
"Theming", in the context of EDS, is the process of overriding the default styles of EDS components to match a different brand (or "theme"). We include useful examples under "Pages":
7+
Below are instructions on how to use the tooling, configs, and tokens to define custom theme values for a project.
88

9-
- A [wireframe theme](./?path=/story/pages-theming-wireframedemo--default) (an unbranded theme that can be used for prototyping a product before it has an official visual style).
9+
## Using Tailwind with the Default Theme
1010

11-
Below are instructions on how to use the tooling and tokens to define custom theme values for a project.
11+
Out of the box, EDS provides a basic tailwind configuration to use in any project. The provided EDS tailwind config hooks up EDS tokens to useful utility classes and some screen sizes. To import the tailwind config into the app's tailwind config, supply the [theme](https://tailwindcss.com/docs/theme) property for use:
1212

13-
## How to apply a theme in another product
13+
```ts
14+
// in your tailwind.config.ts
15+
import edsConfig from '@chanzuckerberg/eds/tailwind.config';
1416

15-
EDS comes with some tooling to allow easy transfer of theme data from Figma (or some style-dictionary compatible format) into code.
17+
module.exports = {
18+
content: ['./app/**/*.{ts,tsx,jsx,js}'],
19+
theme: edsConfig.theme,
20+
// ... any other tailwind config
21+
};
22+
```
1623

17-
* `eds-init-theme` - This command sets up the initial file(s) for theming your application
18-
* `eds-apply-theme` - This command parses the style dictionary files to generate the tokens used by EDS (and tailwind, or other tools)
24+
If you only want part of the provided settings, you can review the [Tailwind Theme Customization][tailwind-theme] documentation, and the contents of the [provided config][eds-tailwind-config], and apply the parts you want to use.
1925

20-
Each of these tools reads config to figure out where to read/write files. This can be defined in several ways, e.g., a top-level file `.edsrc.json`, or as a key-value set in package.json. Example:
26+
[tailwind-theme]: https://tailwindcss.com/docs/theme
27+
[eds-tailwind-config]: https://github.com/chanzuckerberg/edu-design-system/blob/main/tailwind.config.ts
2128

22-
`package.json`
29+
<hr />
2330

24-
```json
25-
"eds": {
26-
"src": "src/components/",
27-
"dest": "src/components/"
28-
},
29-
```
31+
## Setting up and using the theming tooling
32+
33+
EDS comes with some optional tooling to allow easy transfer of theme data from Figma (or some style-dictionary compatible format) into code.
3034

31-
`.edsrc.json`
35+
- `eds-init-theme` - This command creates the initial file(s) for theming your application
36+
- `eds-apply-theme` - This command parses the local config file to generate the tokens used by EDS components and tools
37+
38+
Each of these tools reads config to figure out where to read/write files.
39+
40+
First, create a configuration file to determine the source and destination directories. This can be defined in a new file `.edsrc.json` in your project root. Example:
3241

3342
```json
43+
// in a new file .edsrc.json
3444
{
3545
"src": "src/components/",
3646
"dest": "src/components/"
3747
}
3848
```
3949

40-
`src` determines where the core theme file will be copied to (upon init) OR read from (upon apply), and `dest` determines where the processed files will be written to.
50+
`src` determines where the core theme file will be copied to (upon running `eds-init-theme`) OR read from (upon running `eds-apply-theme`), and `dest` determines where the generated project files will be written to. Once created, you can use the provided commands.
4151

4252
### eds-init-theme
4353

44-
This will create an initial JSON file `app-theme.json` that defines ALL the available tokens for EDS that you can edit.
54+
Command to run: `npx eds-init-theme`
4555

46-
EDS comes pre-packaged with many tokens that define the base style and character of the system. Users of EDS can theme certain aspects of all components, or details on specific components.
56+
This will create a new JSON file `app-theme.json` that defines ALL the available tokens for EDS that you can edit. It will copy the template file to configured `src` path in your project.
4757

48-
```json
49-
{
50-
"eds": {
51-
"anim": {
52-
"fade": {
53-
"quick": {
54-
"value": "0.15s"
55-
},
56-
"long": {
57-
"value": "0.4s"
58-
}
59-
},
60-
"move": {
61-
"quick": {
62-
"value": "0.15s"
63-
},
64-
"medium": {
65-
"value": "0.3s"
66-
},
67-
"long": {
68-
"value": "0.4s"
69-
}
70-
},
71-
"ease": {
72-
"value": "ease"
73-
}
74-
},
75-
// ...other token values
76-
},
77-
}
78-
```
58+
This file is a baseline config to be used later in the process.
7959

8060
### eds-apply-theme
8161

82-
After making changes to the `app-theme.json` to reflect what has been defined by design, update the project's theme files by running `npx eds-apply-theme`.
83-
84-
Once run, you will have a CSS file `app-theme.css` that includes a set of token values as CSS variables, which can be used in the app as appropriate.
85-
86-
```css
87-
/**
88-
* Do not edit directly
89-
* Generated on Sunday, 01 Jan 2023 12:34:56 GMT
90-
* To update, edit app-theme.json, then run `npx eds-apply-theme`
91-
*/
92-
93-
:root {
94-
--eds-anim-fade-quick: 0.15s;
95-
--eds-anim-fade-long: 0.4s;
96-
--eds-anim-move-quick: 0.15s;
97-
--eds-anim-move-medium: 0.3s;
98-
--eds-anim-move-long: 0.4s;
99-
--eds-anim-ease: ease;
100-
/* ...other token values... */
101-
}
102-
```
62+
Command to run: `npx eds-apply-theme`
10363

104-
Add this file to your core app root file.
64+
Using `eds-apply-theme` will read in the newly-created `app-theme.json` file, and create the tokens to use in your project.
10565

106-
This also generates an additional file `app-tailwind-theme.config.json` which contains [useful tailwind configuration](https://github.com/chanzuckerberg/edu-design-system?tab=readme-ov-file#tailwind-setup) for EDS-specific utility classes
107-
This will also show a preview of the tokens in your IDE of choice. To use this config, replace the import from the package with a link to this files location:
66+
Once run, you will have a set of theme files written to the configured `dest` path:
10867

109-
```diff
110-
-const edsConfig = require('@chanzuckerberg/eds/tailwind.config');
111-
+const edsConfig = require('./src/components/app-tailwind-theme.config');
112-
```
68+
- `app-theme.css` (CSS file containing custom CSS variables with the theme values for the application)
69+
- `app-tailwind-theme.config.json` (Configuration file for advanced tailwind configuration in the application)
11370

114-
That's it! Now, the theme will be applied to the tokens used by EDS components. To make other changes, edit `app-theme.json`, then re-run `npx eds-apply-theme`.
71+
To use, add this file to your core app root file **after** where the imported EDS's `@chanzuckerberg/eds/index.css` file is inserted.
11572

116-
**NOTE**: do not edit this file directly. Instead, follow the instructions at the top of the file!
73+
## Custom Theming and Tailwind
11774

118-
## How to manually apply a theme in another product
75+
When you have your own custom theme, you can use the tokens provided in `app-tailwind-theme.config.json` to do advanced tailwind configuration. This file contains all the tokens in JSON format, mapped to the literal values in your local theme.
11976

120-
You can also manage the creation of theme token definitions manually. In EDS, theming is implemented by overriding the values of the CSS variables representing tokens, which the EDS components use in their styles. This should update the style of the components to match the branding of a different product with minimum manual CSS styling overrides. (Some manual styling overrides will be necessary though because we don't have tokens for every little detail. In those cases, we could create a new token to make those overrides easier if it looks like something that could very well be useful for other products as well.)
77+
You can use similar import values to what is in `@chanzuckerberg/eds/tailwind.config.ts` in your local tailwind configuration file:
12178

122-
These CSS variables overrides lives in the products using EDS components. This allows product teams to quickly iterate on their theme without making changes to EDS itself.
79+
```ts
80+
// in your tailwind.config.ts file
81+
import type { Config } from 'tailwindcss';
82+
import baseConfig from '@chanzuckerberg/eds/tailwind.config';
83+
import {eds as customTokens} from "<edsrc.json:dest>/app-tailwind-theme.config"; // where <edsrc.json:test> is the path configured in .edsrc.json
12384

124-
You can find the full list of CSS variables in [src/tokens-dist/css/variables.css](https://github.com/chanzuckerberg/edu-design-system/blob/main/src/tokens-dist/css/variables.css), and you can see examples of overriding them in [.storybook/pages/WireframeDemo/GlobalStyles.module.css](https://github.com/chanzuckerberg/edu-design-system/blob/main/.storybook/pages/WireframeDemo/GlobalStyles.module.css).
85+
const {
86+
background: backgroundColorTokens,
87+
border: borderColorTokens,
88+
text: textColorTokens,
89+
...colorTokens
90+
} = customTokens.theme.color;
12591

126-
If you're looking to set up a prototype using the [wireframe theme](./?path=/story/pages-theming-wireframedemo--default), you can copy and paste the variables defined in [.storybook/pages/WireframeDemo/GlobalStyles.module.css](https://github.com/chanzuckerberg/edu-design-system/blob/main/.storybook/pages/WireframeDemo/GlobalStyles.module.css). (The placeholder images will need to be added separately.)
92+
// export the following
93+
export default {
94+
... // your local content export
95+
theme: {
96+
colors: {
97+
...colorTokens,
98+
},
99+
extend: {
100+
backgroundColor: {
101+
...backgroundColorTokens,
102+
},
103+
borderColor: {
104+
...borderColorTokens,
105+
},
106+
textColor: {
107+
...textColorTokens,
108+
},
109+
},
110+
screens: {
111+
...baseConfig.theme.screens, // you can mix in any base config values into the local theme
112+
}
113+
... // any local theme settings
114+
}
115+
} satisfies Config
127116

128-
If you are trying to customize the styling of a component but find that the style you want to override does not yet have a token for you to redefine, you can reach out to us to discuss whether a new token should be added.
117+
```
129118

130-
## How to support theming in EDS
119+
<hr />
131120

132-
Since other products rely on CSS variable tokens to theme EDS components, it's very important that, when working with color, components in the EDS package only use CSS variables representing tier 2 and tier 3 tokens for styling. EDS component styling should never use tier 1 tokens, JavaScript variables representing tokens, or raw hex codes. Non-color styling can use tokens from any tier. (This is only relevant to the EDS components themselves; examples in storybook or in other products do not need to follow this rule.)
121+
If there are any future updates to the theme, edit the contents of `app-theme.json`, then re-run `npx eds-apply-theme`. Then commit the changes, and that's it!

.storybook/components/Docs/Guidelines/Tokens.stories.mdx

+3-27
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ EDS is a [themeable design system](https://bradfrost.com/blog/post/creating-them
2323
- [Color](#tier-2-colors)
2424
- [Form](#tier-2-forms)
2525
- [Tier 3 Component Tokens](#tier-3-component-tokens)
26-
- [Tailwind Class Tokens](#tailwind-class-tokens)
2726

2827
## Style Dictionary
2928

@@ -33,7 +32,9 @@ Tokens are defined as a collection of JSON files, which then get converted by St
3332

3433
## Design token architecture
3534

36-
Design tokens live at `src/design-tokens`, and follows this directory structure:
35+
Design tokens live at `src/design-tokens`. Primitive (tier-1) tokens live in `primitives.json`, and theme (tier-2/tier-3) tokens live in `themes.json`.
36+
37+
For typography tokens, thes directory structure is stored in the following tree:
3738

3839
```css
3940
design-tokens
@@ -150,28 +151,3 @@ With the rest matching a corresponding use for the given component. For example,
150151
The suffix here is arbitrary, but uses similar naming to tier two tokens. When possible, any new tier 3 tokens should be a more specifically named tier 2 token, to keep the naming consistent.
151152

152153
See the current set of tier 3 tokens [in storybook](/story/design-tokens-tier-3-component--colors).
153-
154-
155-
## Tailwind Class Tokens
156-
157-
If the EDS tailwind config theme is being used, Tier 2 and tier 3 color tokens are available as a part of tailwind utility classes, and can be used to apply to specific attributes to a component. Background(prefix: bg-), border(prefix: border-), and text(prefix: text-) colors will only be available for themselves specifically. e.g.:
158-
159-
### These will not work
160-
161-
```html
162-
<!-- will NOT work since tier 1 colors are not available -->
163-
<div className="bg-brand-grape-100"></div>
164-
<!-- will NOT work since background utility classes don't have border colors -->
165-
<div className="bg-link-neutral"></div>
166-
```
167-
168-
### These will work
169-
```html
170-
<!-- will work since button colors are available across all color utility classes -->
171-
<div className="bg-button-icon-brand"></div>
172-
<!-- will work since border colors are available for border color utility classes -->
173-
<div className="border-link-neutral"></div>
174-
<!-- will reflect respective color utility tokens
175-
(background-brand-primary-strong and border-brand-primary-strong) -->
176-
<div className="bg-brand-primary-strong border-brand-primary-strong"></div>
177-
```

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [13.10.0](https://github.com/chanzuckerberg/edu-design-system/compare/v13.9.0...v13.10.0) (2024-02-01)
6+
7+
8+
### Features
9+
10+
* **Select:** add ability to handle click and change event handlers ([#1839](https://github.com/chanzuckerberg/edu-design-system/issues/1839)) ([54a3de8](https://github.com/chanzuckerberg/edu-design-system/commit/54a3de8e5d1e9416b1ff24a18499ee5f02db3888))
11+
* **Select:** add support for label prop ([#1837](https://github.com/chanzuckerberg/edu-design-system/issues/1837)) ([c032ff2](https://github.com/chanzuckerberg/edu-design-system/commit/c032ff2b35f074076237aab0786325cc7237fa3a))
12+
513
## [13.9.0](https://github.com/chanzuckerberg/edu-design-system/compare/v13.8.1...v13.9.0) (2024-01-19)
614

715

0 commit comments

Comments
 (0)