@czi-sds/mcp 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/zeroheight-cache.json +5195 -0
- package/data/zeroheight-exports/Accordion.md +675 -0
- package/data/zeroheight-exports/Banner.md +576 -0
- package/data/zeroheight-exports/Borders.md +118 -0
- package/data/zeroheight-exports/Buttons.md +2260 -0
- package/data/zeroheight-exports/Callout.md +756 -0
- package/data/zeroheight-exports/Colors.md +633 -0
- package/data/zeroheight-exports/Content-Card.md +162 -0
- package/data/zeroheight-exports/Contributing-to-SDS.md +99 -0
- package/data/zeroheight-exports/Control-Inputs.md +2066 -0
- package/data/zeroheight-exports/Corners.md +112 -0
- package/data/zeroheight-exports/Cover-page.md +4 -0
- package/data/zeroheight-exports/Dialog.md +1133 -0
- package/data/zeroheight-exports/Downloads.md +121 -0
- package/data/zeroheight-exports/Drop-Shadows.md +80 -0
- package/data/zeroheight-exports/Dropdown-Input.md +1149 -0
- package/data/zeroheight-exports/Dropdown-Menu.md +3787 -0
- package/data/zeroheight-exports/Element-Status-Tracker.md +268 -0
- package/data/zeroheight-exports/Field-Inputs.md +965 -0
- package/data/zeroheight-exports/Filters.md +868 -0
- package/data/zeroheight-exports/Getting-Started.md +1296 -0
- package/data/zeroheight-exports/Hero.md +256 -0
- package/data/zeroheight-exports/Icons.md +432 -0
- package/data/zeroheight-exports/Intent.md +47 -0
- package/data/zeroheight-exports/Introduction-to-Bases.md +36 -0
- package/data/zeroheight-exports/Introduction-to-Cells.md +36 -0
- package/data/zeroheight-exports/Introduction-to-DNA.md +36 -0
- package/data/zeroheight-exports/Introduction-to-Genes.md +36 -0
- package/data/zeroheight-exports/Introduction.md +116 -0
- package/data/zeroheight-exports/Link.md +373 -0
- package/data/zeroheight-exports/Lists.md +617 -0
- package/data/zeroheight-exports/Loading-Indicator.md +38 -0
- package/data/zeroheight-exports/Navigation.md +853 -0
- package/data/zeroheight-exports/Notification.md +858 -0
- package/data/zeroheight-exports/Panel.md +862 -0
- package/data/zeroheight-exports/README.md +124 -0
- package/data/zeroheight-exports/Responsive-Design.md +275 -0
- package/data/zeroheight-exports/Search-Input.md +54 -0
- package/data/zeroheight-exports/Search.md +609 -0
- package/data/zeroheight-exports/Segmented-Control.md +561 -0
- package/data/zeroheight-exports/Spacing.md +298 -0
- package/data/zeroheight-exports/Table.md +4832 -0
- package/data/zeroheight-exports/Tabs.md +773 -0
- package/data/zeroheight-exports/Tags.md +1025 -0
- package/data/zeroheight-exports/Text-Link.md +185 -0
- package/data/zeroheight-exports/Theming.md +313 -0
- package/data/zeroheight-exports/Tooltips.md +1564 -0
- package/data/zeroheight-exports/Typography.md +769 -0
- package/dist/stdio.js +515 -12
- package/package.json +4 -3
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Text Link
|
|
2
|
+
|
|
3
|
+
Text Links are interactive elements that, when clicked, navigate the user away from the page they are currently viewing to another page or screen.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
| | In Figma | | | Meets Accessibility | | | In napari hub + .org Codebases |
|
|
8
|
+
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
9
|
+
|
|
10
|
+
Use Text Links to navigate the user away from the page they are currently viewing to another page or screen. They can be used inline or separate from a paragraph of text. There are four Text Link sizes available—`bodyM`, `bodyS`, `bodyXs`, `bodyXxs`—each corresponding to the four sizes of body copy available in the napari hub and napari.org codebases.
|
|
11
|
+
|
|
12
|
+
Note: Designers, when including an inline Text Link in your design, styles must be manually applied as there is no way to save the Text Link style in Figma as a text style. You may use the Text Link Figma component for links that are not inline.
|
|
13
|
+
|
|
14
|
+
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
15
|
+
|
|
16
|
+
| **bodyM** | **bodyS** | **bodyXs** | **bodyXxs** |
|
|
17
|
+
| --- | --- | --- | --- |
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
### Text Link Spacing
|
|
22
|
+
|
|
23
|
+
These rules establish how much margin should exist between and around elements.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Code
|
|
30
|
+
|
|
31
|
+
## Text Link Component
|
|
32
|
+
|
|
33
|
+
| Below you will find an interactive Storybook iframe for Text Links. Tabs within each iframe provide a different set of tools: The Controls tab allows you to see and adjust all available props. The Actions tab shows you data displayed by event handler arguments. | | **Jump to component:** Link |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
>This component appears as it is in the default SDS codebase. Once imported into the napari hub or napari.org codebases, use a theme file to enable the napari visual appearance customization.
|
|
39
|
+
|
|
40
|
+
### Link
|
|
41
|
+
|
|
42
|
+
Storybook
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
Text Links are interactive elements that, when clicked, navigate the user away from the page they are currently viewing to another page or screen.
|
|
49
|
+
|
|
50
|
+
## Overview
|
|
51
|
+
|
|
52
|
+
## Text Link Variants
|
|
53
|
+
|
|
54
|
+
| There are two Text Link variants available for designers to use depending on the background on top of which they are placed and whether that background provides enough contrast for the Default Text Link to be seen. Text links can be used inline or separate from a paragraph of text. Though visually similar to Minimal Buttons, Text Links navigate the user away from the page they are currently viewing to another page. This is in contrast to Minimal Buttons, which keep the user on the same page and facilitate on-screen actions such as opening Dialogs or indicating less-emphasized actions. Note: Designers, when including an inline Text Link in your design, styles must be manually applied as there is no way to save the Text Link style in Figma as a text style. You may use the Text Link Figma component for links that are not inline. Follow the usage criteria accompanying each variant as a guide for selecting the correct Text Link for any given use case. | | **Jump to variant:** Default Dashed |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Text Link
|
|
60
|
+
|
|
61
|
+
| | In Figma | | | Meets Accessibility | | | In CZ GEN EPI Codebase |
|
|
62
|
+
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
63
|
+
|
|
64
|
+
### Default Text Link
|
|
65
|
+
|
|
66
|
+
Use the Default Text Link when the Text Link is placed on `white`, `gray100`, or `gray200` backgrounds to ensure there is enough contrast to pass visual accessibility standards.
|
|
67
|
+
|
|
68
|
+
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
69
|
+
|
|
70
|
+
| **Default** | **Hover** | **Pressed** |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Dashed Text Link
|
|
76
|
+
|
|
77
|
+
Use the Dashed Text Link when the Text Link is placed on a background where the Default Text Link does not provide enough contrast to pass visual accessibility standards. The color of the link and its underline is inherited from the color used in the paragraph it is part of, see Dashed Text Link Color Examples below.
|
|
78
|
+
|
|
79
|
+
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses. See Borders section for Link Underline details.
|
|
80
|
+
|
|
81
|
+
| **Default** | **Hover** | **Pressed** |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
|
|
84
|
+
### Dashed Text Link Color Examples
|
|
85
|
+
|
|
86
|
+
See below for visual examples of how the Dashed Text Link should be used in different colors depending on the color of the background it is placed upon.
|
|
87
|
+
|
|
88
|
+
| **Black Text** | **Gray500 Text** | **White Text** |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### Text Link Spacing
|
|
94
|
+
|
|
95
|
+
These rules establish how much margin should exist between and around elements.
|
|
96
|
+
|
|
97
|
+
Note: Default Text Links fall in line with the rest of the text in the paragraph it is part of. Dashed Text Links are spaced lower than a default underline text-decoration.
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## Code
|
|
102
|
+
|
|
103
|
+
## Text Link Component
|
|
104
|
+
|
|
105
|
+
| Below you will find an interactive Storybook iframe for Text Links. Tabs within each iframe provide a different set of tools: The Controls tab allows you to see and adjust all available props. The Actions tab shows you data displayed by event handler arguments. | | **Jump to component:** Link |
|
|
106
|
+
| --- | --- | --- |
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
>This component appears as it is in the default SDS codebase. Once imported into the CZ GEN EPI codebase, use a theme file to enable the CZ GEN EPI visual appearance customization.
|
|
111
|
+
|
|
112
|
+
### Link
|
|
113
|
+
|
|
114
|
+
Storybook
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
Text Links are interactive elements that, when clicked, navigate the user away from the page they are currently viewing to another page or screen.
|
|
119
|
+
|
|
120
|
+
## Overview
|
|
121
|
+
|
|
122
|
+
## Text Link Variants
|
|
123
|
+
|
|
124
|
+
| There are two Text Link variants available for designers to use depending on the background on top of which they are placed and whether that background provides enough contrast for the Default Text Link to be seen. Text links can be used inline or separate from a paragraph of text. Though visually similar to Minimal Buttons, Text Links navigate the user away from the page they are currently viewing to another page. This is in contrast to Minimal Buttons, which keep the user on the same page and facilitate on-screen actions such as opening Dialogs or indicating less-emphasized actions. Note: Designers, when including an inline Text Link in your design, styles must be manually applied as there is no way to save the Text Link style in Figma as a text style. You may use the Text Link Figma component for links that are not inline. Follow the usage criteria accompanying each variant as a guide for selecting the correct Text Link for any given use case. | | **Jump to variant:** Default Dashed |
|
|
125
|
+
| --- | --- | --- |
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Text Link
|
|
130
|
+
|
|
131
|
+
| | In Figma | | | Meets Accessibility | | | In CZ ID Codebase |
|
|
132
|
+
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
133
|
+
|
|
134
|
+
### Default Text Link
|
|
135
|
+
|
|
136
|
+
Use the Default Text Link when the Text Link is placed on `white`, `gray100`, or `gray200` backgrounds to ensure there is enough contrast to pass visual accessibility standards.
|
|
137
|
+
|
|
138
|
+
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
139
|
+
|
|
140
|
+
| **Default** | **Hover** | **Pressed** |
|
|
141
|
+
| --- | --- | --- |
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
### Dashed Text Link
|
|
146
|
+
|
|
147
|
+
Use the Dashed Text Link when the Text Link is placed on a background where the Default Text Link does not provide enough contrast to pass visual accessibility standards. The color of the link and its underline is inherited from the color used in the paragraph it is part of, see Dashed Text Link Color Examples below.
|
|
148
|
+
|
|
149
|
+
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses. See Borders section for Link Underline details.
|
|
150
|
+
|
|
151
|
+
| **Default** | **Hover** | **Pressed** |
|
|
152
|
+
| --- | --- | --- |
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
### Dashed Text Link Color Examples
|
|
157
|
+
|
|
158
|
+
See below for visual examples of how the Dashed Text Link should be used in different colors depending on the color of the background it is placed upon.
|
|
159
|
+
|
|
160
|
+
| **Black Text** | **Gray500 Text** | **White Text** |
|
|
161
|
+
| --- | --- | --- |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### Text Link Spacing
|
|
166
|
+
|
|
167
|
+
These rules establish how much margin should exist between and around elements.
|
|
168
|
+
|
|
169
|
+
Note: Default Text Links fall in line with the rest of the text in the paragraph it is part of. Dashed Text Links are spaced lower than a default underline text-decoration.
|
|
170
|
+
|
|
171
|
+
## Code
|
|
172
|
+
|
|
173
|
+
## Text Link Component
|
|
174
|
+
|
|
175
|
+
| Below you will find an interactive Storybook iframe for Text Links. Tabs within each iframe provide a different set of tools: The Controls tab allows you to see and adjust all available props. The Actions tab shows you data displayed by event handler arguments. | | **Jump to component:** Link |
|
|
176
|
+
| --- | --- | --- |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### Link
|
|
181
|
+
|
|
182
|
+
Storybook
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# Theming
|
|
2
|
+
|
|
3
|
+
Themes enable visual changes to be made across the UI, affecting all elements in a consistent way such as in the case of Light and Dark Mode or individual product themes
|
|
4
|
+
|
|
5
|
+
## Guidelines
|
|
6
|
+
|
|
7
|
+
## Dark Mode
|
|
8
|
+
|
|
9
|
+
SDS supports both Light and Dark Mode and they can be implemented to allow users to toggle between them or set either as the application's primary color mode. Every primitive color variable has a Dark Mode equivalent and each semantic color variable has a Dark Mode primitive mapped to it; for specific hex codes and primitive color mappings, see the Semantic Colors and Primitive Colors documentation.
|
|
10
|
+
|
|
11
|
+
>**Note:** the semantic color variable mappings in the Bases color set are not always one-to-one between Light and Dark Modes, see Differences in Light Mode vs Dark Mode for more details.
|
|
12
|
+
|
|
13
|
+
### Color Indexes
|
|
14
|
+
|
|
15
|
+
The color indexes used in SDS primitive color names (e.g., `gray100`, `gray200`, etc.) refer to the level of contrast of that color against the background it is viewed upon. As a result, primitive colors have a different appearance between Light and Dark Mode, but they have a consistent *functional* appearance relative to their backgrounds. This is why `gray100` in Light Mode is a light gray color, whereas `gray100` in Dark Mode is a dark gray color—both have low contrasts when viewed in relation to their corresponding background colors.
|
|
16
|
+
|
|
17
|
+
| Light Mode | Dark Mode |
|
|
18
|
+
| :---: | :---: |
|
|
19
|
+
|
|
20
|
+
In most cases, each semantic variable will have the same primitive value mapped to it regardless of the mode of that primitive value. For example, the semantic variable `Base.text-primary` has `gray900` mapped to it; in Light Mode `gray900` = `#000000`(black), but in Dark Mode `gray900` = `#ffffff` (white). This means that in both modes primary text is highly visible against the background it is placed on top of, whether a light background in Light Mode or a dark background in Dark Mode.
|
|
21
|
+
|
|
22
|
+
| Light Mode | Dark Mode |
|
|
23
|
+
| :---: | :---: |
|
|
24
|
+
|
|
25
|
+
### Differences in Light Mode vs Dark Mode
|
|
26
|
+
|
|
27
|
+
The only instances where the primitive variables mapped to semantic variables differ between modes is `background-primary`, `surface`, and `fill-primary`. Where Light Mode uses `gray50` (white) for all of these, Dark Mode has to use two separate shades of dark gray to adhere to visual accessibility best practices.
|
|
28
|
+
|
|
29
|
+
In Dark Mode, `background-primary` is `gray75` (not quite pure black which has poor visual accessibility when used across large areas) and `surface` and `fill-primary` are both `gray100` (shades of dark gray that are visible when viewed on top of `gray75` backgrounds). One of the main reasons for this is that drop shadows can't be leveraged in Dark Mode to separate layers in the same way that they can be in Light Mode since shadows are not nearly as visible when viewed on dark backgrounds.
|
|
30
|
+
|
|
31
|
+
| Light Mode | Dark Mode |
|
|
32
|
+
| :---: | :---: |
|
|
33
|
+
|
|
34
|
+
### Inverted Style
|
|
35
|
+
|
|
36
|
+
There are a few components (Header Navigation, Footer Navigation, Tooltip, and Condensed Tooltip) that can be displayed with light or dark backgrounds regardless of which color mode the user's application is set to. Enable this using the prop `hasInvertedStyle` which by default is set to `false`. In Light Mode the component will have a light background and in Dark Mode the component will have a dark background. When set to `true`, the colors will be inverted and in Light Mode the component will have a dark background and in Dark Mode the component will have a light background.
|
|
37
|
+
|
|
38
|
+
See the individual component pages for more details and visual examples.
|
|
39
|
+
|
|
40
|
+
| Default (Light Mode) | Inverted (Light Mode) |
|
|
41
|
+
| :---: | :---: |
|
|
42
|
+
|
|
43
|
+
## Code
|
|
44
|
+
|
|
45
|
+
## Dark Mode
|
|
46
|
+
|
|
47
|
+
SDS supports both Light and Dark Mode and they can be implemented to allow users to toggle between them or set either as the application's primary color mode. Every primitive color variable has a Dark Mode equivalent and each semantic color variable has a Dark Mode primitive mapped to it; for specific hex codes and primitive color mappings, see the Semantic Colors and Primitive Colors documentation.
|
|
48
|
+
|
|
49
|
+
>**Note:** the semantic color variable mappings in the Bases color set are not always one-to-one between Light and Dark Modes, see Differences in Light Mode vs Dark Mode for more details.
|
|
50
|
+
|
|
51
|
+
### Dark Mode by Default
|
|
52
|
+
|
|
53
|
+
You can make your application use Dark Mode as the default theme—regardless of the user's preference—by passing `'dark'` to the `Theme` helper.
|
|
54
|
+
|
|
55
|
+
Adding `<CssBaseline />` inside of the `<ThemeProvider>` component will also enable dark mode for the app's background.
|
|
56
|
+
|
|
57
|
+
**/styles.css**
|
|
58
|
+
|
|
59
|
+
```css
|
|
60
|
+
body {
|
|
61
|
+
font-size: 13px;
|
|
62
|
+
font-weight: 400;
|
|
63
|
+
letter-spacing: 0.08px;
|
|
64
|
+
line-height: 20px;
|
|
65
|
+
text-transform: none;
|
|
66
|
+
font-family: "Inter", sans-serif;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
h1 {
|
|
70
|
+
font-size: 1.5rem;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.app {
|
|
74
|
+
padding: 20px;
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**tsconfig.json**
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"include": [
|
|
83
|
+
"./**/*"
|
|
84
|
+
],
|
|
85
|
+
"compilerOptions": {
|
|
86
|
+
"strict": true,
|
|
87
|
+
"esModuleInterop": true,
|
|
88
|
+
"lib": [ "dom", "es2015" ],
|
|
89
|
+
"jsx": "react-jsx"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**/App.tsx**
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { Button } from "@czi-sds/components";
|
|
98
|
+
import "./styles.css";
|
|
99
|
+
|
|
100
|
+
function App() {
|
|
101
|
+
return (
|
|
102
|
+
<div className="app">
|
|
103
|
+
<Button sdsType="primary" sdsStyle="square">Label</Button>
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default App;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**/index.tsx**
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import React from "react";
|
|
115
|
+
import { createRoot } from "react-dom/client";
|
|
116
|
+
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
|
|
117
|
+
import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
|
|
118
|
+
import { Theme } from "@czi-sds/components";
|
|
119
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
120
|
+
|
|
121
|
+
import App from "./App";
|
|
122
|
+
|
|
123
|
+
const container = document.getElementById("root");
|
|
124
|
+
const root = createRoot(container!);
|
|
125
|
+
|
|
126
|
+
root.render(
|
|
127
|
+
<React.StrictMode>
|
|
128
|
+
<StyledEngineProvider injectFirst>
|
|
129
|
+
<ThemeProvider theme={Theme('dark')}>
|
|
130
|
+
<EmotionThemeProvider theme={Theme('dark')}>
|
|
131
|
+
<CssBaseline />
|
|
132
|
+
<App />
|
|
133
|
+
</EmotionThemeProvider>
|
|
134
|
+
</ThemeProvider>
|
|
135
|
+
</StyledEngineProvider>
|
|
136
|
+
</React.StrictMode>
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**/public/index.html**
|
|
142
|
+
|
|
143
|
+
```html
|
|
144
|
+
<!DOCTYPE html>
|
|
145
|
+
<html lang="en">
|
|
146
|
+
<head>
|
|
147
|
+
<meta charset="UTF-8" />
|
|
148
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
149
|
+
<title>Theming</title>
|
|
150
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
151
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
152
|
+
<link
|
|
153
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
|
|
154
|
+
rel="stylesheet"
|
|
155
|
+
/>
|
|
156
|
+
<link
|
|
157
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
|
|
158
|
+
rel="stylesheet"
|
|
159
|
+
/>
|
|
160
|
+
</head>
|
|
161
|
+
<body>
|
|
162
|
+
<div id="root"></div>
|
|
163
|
+
</body>
|
|
164
|
+
</html>
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**/package.json**
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{"dependencies":{"react":"^18.0.0","react-dom":"^18.0.0","react-scripts":"^4.0.0"},"devDependencies":{"@types/react":"^18.0.0","@types/react-dom":"^18.0.0","typescript":"^4.0.0"},"main":"/index.tsx"}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
### Dark Mode Based on System Preference
|
|
177
|
+
|
|
178
|
+
Users might have a preference for Light or Dark Mode set through their operating system—either systemwide, or for a single user agent.
|
|
179
|
+
|
|
180
|
+
You can ensure this preference is used in your application with the useMediaQuery hook and the prefers-color-scheme media query.
|
|
181
|
+
|
|
182
|
+
The following demo shows how to enable Dark Mode automatically by checking for the user's preference in their OS or browser settings:
|
|
183
|
+
|
|
184
|
+
**/styles.css**
|
|
185
|
+
|
|
186
|
+
```css
|
|
187
|
+
body {
|
|
188
|
+
font-size: 13px;
|
|
189
|
+
font-weight: 400;
|
|
190
|
+
letter-spacing: 0.08px;
|
|
191
|
+
line-height: 20px;
|
|
192
|
+
text-transform: none;
|
|
193
|
+
font-family: "Inter", sans-serif;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
h1 {
|
|
197
|
+
font-size: 1.5rem;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.app {
|
|
201
|
+
padding: 20px;
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**tsconfig.json**
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"include": [
|
|
210
|
+
"./**/*"
|
|
211
|
+
],
|
|
212
|
+
"compilerOptions": {
|
|
213
|
+
"strict": true,
|
|
214
|
+
"esModuleInterop": true,
|
|
215
|
+
"lib": [ "dom", "es2015" ],
|
|
216
|
+
"jsx": "react-jsx"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**/App.tsx**
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
import { Button } from "@czi-sds/components";
|
|
225
|
+
import "./styles.css";
|
|
226
|
+
|
|
227
|
+
function App() {
|
|
228
|
+
return (
|
|
229
|
+
<div className="app">
|
|
230
|
+
<Button sdsType="primary" sdsStyle="square">Label</Button>
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export default App;
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**/index.tsx**
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
import React from "react";
|
|
242
|
+
import { createRoot } from "react-dom/client";
|
|
243
|
+
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
|
|
244
|
+
import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
|
|
245
|
+
import { Theme } from "@czi-sds/components";
|
|
246
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
247
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
248
|
+
|
|
249
|
+
import App from "./App";
|
|
250
|
+
|
|
251
|
+
const container = document.getElementById("root");
|
|
252
|
+
const root = createRoot(container!);
|
|
253
|
+
|
|
254
|
+
// Create a wrapper component to handle theme and useMediaQuery
|
|
255
|
+
const RootApp = () => {
|
|
256
|
+
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
257
|
+
const theme = prefersDarkMode ? Theme("dark") : Theme("light");
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<StyledEngineProvider injectFirst>
|
|
261
|
+
<ThemeProvider theme={theme}>
|
|
262
|
+
<EmotionThemeProvider theme={theme}>
|
|
263
|
+
<CssBaseline />
|
|
264
|
+
<App />
|
|
265
|
+
</EmotionThemeProvider>
|
|
266
|
+
</ThemeProvider>
|
|
267
|
+
</StyledEngineProvider>
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
root.render(
|
|
272
|
+
<React.StrictMode>
|
|
273
|
+
<RootApp />
|
|
274
|
+
</React.StrictMode>
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**/public/index.html**
|
|
280
|
+
|
|
281
|
+
```html
|
|
282
|
+
<!DOCTYPE html>
|
|
283
|
+
<html lang="en">
|
|
284
|
+
<head>
|
|
285
|
+
<meta charset="UTF-8" />
|
|
286
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
287
|
+
<title>Theming</title>
|
|
288
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
289
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
290
|
+
<link
|
|
291
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
|
|
292
|
+
rel="stylesheet"
|
|
293
|
+
/>
|
|
294
|
+
<link
|
|
295
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
|
|
296
|
+
rel="stylesheet"
|
|
297
|
+
/>
|
|
298
|
+
</head>
|
|
299
|
+
<body>
|
|
300
|
+
<div id="root"></div>
|
|
301
|
+
</body>
|
|
302
|
+
</html>
|
|
303
|
+
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**/package.json**
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
{"dependencies":{"react":"^18.0.0","react-dom":"^18.0.0","react-scripts":"^4.0.0"},"devDependencies":{"@types/react":"^18.0.0","@types/react-dom":"^18.0.0","typescript":"^4.0.0"},"main":"/index.tsx"}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|