@czi-sds/mcp 0.2.2 → 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 +188 -0
- package/package.json +4 -3
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
# Segmented Control
|
|
2
|
+
|
|
3
|
+
Segmented Control allows users to toggle between different views within an on-screen element such as viewing the same set of data in table or tree format.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
| | In Figma | | | Meets Accessibility | | | In CZ ID Codebase |
|
|
8
|
+
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
9
|
+
|
|
10
|
+
Segmented Control allows users to toggle between different views of an on-screen element. There must be a minimum of two and can be up to four segments.
|
|
11
|
+
|
|
12
|
+
The Segmented Control component is comprised of Segmented Control Items each of which has a Default, Hover, and Active state. Designers can swap out default icons for icons relevant to their needed use case.
|
|
13
|
+
|
|
14
|
+
| **Default / Active** | **Hover** |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### Segmented Control Spacing
|
|
20
|
+
|
|
21
|
+
These rules establish how much margin should exist between and around elements.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### Segmented Control Best Practices
|
|
26
|
+
|
|
27
|
+
Segmented control relies on icons to communicate what’s being shown to the user. Because of this, it should always be coupled with a dark Tooltip that displays the name of the segment item when the user hovers over it.
|
|
28
|
+
|
|
29
|
+
## Code
|
|
30
|
+
|
|
31
|
+
## Segmented Control Component
|
|
32
|
+
|
|
33
|
+
| Below you will find an interactive Storybook iframe for the Segmented Control. 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:** SegmentedControl |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
### SegmentedControl
|
|
39
|
+
|
|
40
|
+
Storybook
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
Segmented Control allows users to toggle between different views within an on-screen element such as viewing the same set of data in table or tree format.
|
|
45
|
+
|
|
46
|
+
## Guidelines
|
|
47
|
+
|
|
48
|
+
## Overview
|
|
49
|
+
|
|
50
|
+
| | In Figma | | | Meets Accessibility | | | In Code |
|
|
51
|
+
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
52
|
+
|
|
53
|
+
### Live Instance
|
|
54
|
+
|
|
55
|
+
Interact with the live instance below and adjust the available props to better conceptualize how it will appear in product:
|
|
56
|
+
|
|
57
|
+
Default
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
Segmented Control allows users to switch between different views of an on-screen element. There must be a minimum of two and can be up to four segments.
|
|
62
|
+
|
|
63
|
+
Icons are used to communicate what will be shown on screen when that segment is clicked. When hovered over, each segment displays Tooltip – Dark to communicate what the icon represents. Any small variant icon can be used as a segment indicator.
|
|
64
|
+
|
|
65
|
+
| Default / Active | Hover |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### Segmented Control Spacing
|
|
71
|
+
|
|
72
|
+
These rules establish how much margin should exist between and around elements.
|
|
73
|
+
|
|
74
|
+
## Code
|
|
75
|
+
|
|
76
|
+
>**Note:** The code examples below must install dependencies before displaying and may take extra time to load
|
|
77
|
+
|
|
78
|
+
## SegmentedControl
|
|
79
|
+
|
|
80
|
+
### SDS Source Code
|
|
81
|
+
|
|
82
|
+
The component's source code in the SDS codebase can be found here.
|
|
83
|
+
|
|
84
|
+
### SDS vs MUI
|
|
85
|
+
|
|
86
|
+
The following props are available to MUI's `ToggleButtonGroup` but not SDS's `SegementedControl`:
|
|
87
|
+
|
|
88
|
+
* **`exclusive`****:** This boolean prop determines whether just a single button within the control group can be selected at a time (default) or whether multiple can be. SDS's`SegmentedControl` is an exclusive control only, and setting `exclusive` to `false` has no effect.
|
|
89
|
+
* **`size`****:** Has no effect for SDS's `SegmentedControl`
|
|
90
|
+
|
|
91
|
+
### MUI Documentation
|
|
92
|
+
|
|
93
|
+
Documentation for the underlying MUI component can be found here.
|
|
94
|
+
|
|
95
|
+
### Props
|
|
96
|
+
|
|
97
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
98
|
+
|
|
99
|
+
| Name | Type | Default | Description |
|
|
100
|
+
| --- | --- | --- | --- |
|
|
101
|
+
| `buttonDefinition` | `{` `disabled?: boolean;` `iconName: string;` `tooltipText: string;` `value: string;` `}[]` | `-` | An array of items containing an icon name and a tooltip text. |
|
|
102
|
+
|
|
103
|
+
### Code examples
|
|
104
|
+
|
|
105
|
+
#### **Default SegmentedControl**
|
|
106
|
+
|
|
107
|
+
This example demonstrates the most basic usage of the `SegmentedControl` component with default props.
|
|
108
|
+
|
|
109
|
+
**/styles.css**
|
|
110
|
+
|
|
111
|
+
```css
|
|
112
|
+
body {
|
|
113
|
+
font-size: 13px;
|
|
114
|
+
font-weight: 400;
|
|
115
|
+
letter-spacing: 0.08px;
|
|
116
|
+
line-height: 20px;
|
|
117
|
+
text-transform: none;
|
|
118
|
+
font-family: "Inter", sans-serif;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
h1 {
|
|
122
|
+
font-size: 1.5rem;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.app {
|
|
126
|
+
padding: 20px;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**tsconfig.json**
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"include": [
|
|
135
|
+
"./**/*"
|
|
136
|
+
],
|
|
137
|
+
"compilerOptions": {
|
|
138
|
+
"strict": true,
|
|
139
|
+
"esModuleInterop": true,
|
|
140
|
+
"lib": [ "dom", "es2015" ],
|
|
141
|
+
"jsx": "react-jsx"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**/App.tsx**
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { SegmentedControl } from "@czi-sds/components";
|
|
150
|
+
import "./styles.css";
|
|
151
|
+
|
|
152
|
+
function App() {
|
|
153
|
+
const buttonDefinition = [
|
|
154
|
+
{
|
|
155
|
+
icon: "List",
|
|
156
|
+
tooltipText: "List A",
|
|
157
|
+
value: "A",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
icon: "List",
|
|
161
|
+
tooltipText: "List B",
|
|
162
|
+
value: "B",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
icon: "List",
|
|
166
|
+
tooltipText: "List C",
|
|
167
|
+
value: "C",
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
return (
|
|
171
|
+
<div className="app">
|
|
172
|
+
<SegmentedControl buttonDefinition={buttonDefinition}/>
|
|
173
|
+
</div>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export default App;
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**/index.tsx**
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
import React from "react";
|
|
184
|
+
import { createRoot } from "react-dom/client";
|
|
185
|
+
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
|
|
186
|
+
import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
|
|
187
|
+
import { Theme } from "@czi-sds/components";
|
|
188
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
189
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
190
|
+
|
|
191
|
+
import App from "./App";
|
|
192
|
+
|
|
193
|
+
const container = document.getElementById("root");
|
|
194
|
+
const root = createRoot(container!);
|
|
195
|
+
|
|
196
|
+
const RootApp = () => {
|
|
197
|
+
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
198
|
+
const theme = prefersDarkMode ? Theme("dark") : Theme("light");
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<StyledEngineProvider injectFirst>
|
|
202
|
+
<ThemeProvider theme={theme}>
|
|
203
|
+
<EmotionThemeProvider theme={theme}>
|
|
204
|
+
<CssBaseline />
|
|
205
|
+
<App />
|
|
206
|
+
</EmotionThemeProvider>
|
|
207
|
+
</ThemeProvider>
|
|
208
|
+
</StyledEngineProvider>
|
|
209
|
+
);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
root.render(
|
|
213
|
+
<React.StrictMode>
|
|
214
|
+
<RootApp />
|
|
215
|
+
</React.StrictMode>
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**/public/index.html**
|
|
221
|
+
|
|
222
|
+
```html
|
|
223
|
+
<!DOCTYPE html>
|
|
224
|
+
<html lang="en">
|
|
225
|
+
<head>
|
|
226
|
+
<meta charset="UTF-8" />
|
|
227
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
228
|
+
<title>Segmented Control</title>
|
|
229
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
230
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
231
|
+
<link
|
|
232
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
|
|
233
|
+
rel="stylesheet"
|
|
234
|
+
/>
|
|
235
|
+
<link
|
|
236
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
|
|
237
|
+
rel="stylesheet"
|
|
238
|
+
/>
|
|
239
|
+
</head>
|
|
240
|
+
<body>
|
|
241
|
+
<div id="root"></div>
|
|
242
|
+
</body>
|
|
243
|
+
</html>
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**/package.json**
|
|
248
|
+
|
|
249
|
+
```json
|
|
250
|
+
{"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"}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
#### **Controlled SegmentedControl**
|
|
256
|
+
|
|
257
|
+
This example shows a controlled `SegmentedControl` component.
|
|
258
|
+
|
|
259
|
+
**/styles.css**
|
|
260
|
+
|
|
261
|
+
```css
|
|
262
|
+
body {
|
|
263
|
+
font-size: 13px;
|
|
264
|
+
font-weight: 400;
|
|
265
|
+
letter-spacing: 0.08px;
|
|
266
|
+
line-height: 20px;
|
|
267
|
+
text-transform: none;
|
|
268
|
+
font-family: "Inter", sans-serif;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
h1 {
|
|
272
|
+
font-size: 1.5rem;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.app {
|
|
276
|
+
padding: 20px;
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**tsconfig.json**
|
|
281
|
+
|
|
282
|
+
```json
|
|
283
|
+
{
|
|
284
|
+
"include": [
|
|
285
|
+
"./**/*"
|
|
286
|
+
],
|
|
287
|
+
"compilerOptions": {
|
|
288
|
+
"strict": true,
|
|
289
|
+
"esModuleInterop": true,
|
|
290
|
+
"lib": [ "dom", "es2015" ],
|
|
291
|
+
"jsx": "react-jsx"
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**/App.tsx**
|
|
297
|
+
|
|
298
|
+
```tsx
|
|
299
|
+
import { useState } from "react";
|
|
300
|
+
import { SegmentedControl } from "@czi-sds/components";
|
|
301
|
+
import "./styles.css";
|
|
302
|
+
|
|
303
|
+
function App() {
|
|
304
|
+
const [value, setValue] = useState("B");
|
|
305
|
+
const buttonDefinition = [
|
|
306
|
+
{
|
|
307
|
+
icon: "List",
|
|
308
|
+
tooltipText: "List A",
|
|
309
|
+
value: "A",
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
icon: "List",
|
|
313
|
+
tooltipText: "List B",
|
|
314
|
+
value: "B",
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
icon: "List",
|
|
318
|
+
tooltipText: "List C",
|
|
319
|
+
value: "C",
|
|
320
|
+
},
|
|
321
|
+
];
|
|
322
|
+
return (
|
|
323
|
+
<div className="app">
|
|
324
|
+
<SegmentedControl
|
|
325
|
+
buttonDefinition={buttonDefinition}
|
|
326
|
+
value={value}
|
|
327
|
+
onChange={(e, newValue) => setValue(newValue)}
|
|
328
|
+
/>
|
|
329
|
+
</div>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export default App;
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**/index.tsx**
|
|
337
|
+
|
|
338
|
+
```tsx
|
|
339
|
+
import React from "react";
|
|
340
|
+
import { createRoot } from "react-dom/client";
|
|
341
|
+
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
|
|
342
|
+
import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
|
|
343
|
+
import { Theme } from "@czi-sds/components";
|
|
344
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
345
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
346
|
+
|
|
347
|
+
import App from "./App";
|
|
348
|
+
|
|
349
|
+
const container = document.getElementById("root");
|
|
350
|
+
const root = createRoot(container!);
|
|
351
|
+
|
|
352
|
+
const RootApp = () => {
|
|
353
|
+
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
354
|
+
const theme = prefersDarkMode ? Theme("dark") : Theme("light");
|
|
355
|
+
|
|
356
|
+
return (
|
|
357
|
+
<StyledEngineProvider injectFirst>
|
|
358
|
+
<ThemeProvider theme={theme}>
|
|
359
|
+
<EmotionThemeProvider theme={theme}>
|
|
360
|
+
<CssBaseline />
|
|
361
|
+
<App />
|
|
362
|
+
</EmotionThemeProvider>
|
|
363
|
+
</ThemeProvider>
|
|
364
|
+
</StyledEngineProvider>
|
|
365
|
+
);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
root.render(
|
|
369
|
+
<React.StrictMode>
|
|
370
|
+
<RootApp />
|
|
371
|
+
</React.StrictMode>
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**/public/index.html**
|
|
377
|
+
|
|
378
|
+
```html
|
|
379
|
+
<!DOCTYPE html>
|
|
380
|
+
<html lang="en">
|
|
381
|
+
<head>
|
|
382
|
+
<meta charset="UTF-8" />
|
|
383
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
384
|
+
<title>Segmented Control</title>
|
|
385
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
386
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
387
|
+
<link
|
|
388
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
|
|
389
|
+
rel="stylesheet"
|
|
390
|
+
/>
|
|
391
|
+
<link
|
|
392
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
|
|
393
|
+
rel="stylesheet"
|
|
394
|
+
/>
|
|
395
|
+
</head>
|
|
396
|
+
<body>
|
|
397
|
+
<div id="root"></div>
|
|
398
|
+
</body>
|
|
399
|
+
</html>
|
|
400
|
+
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**/package.json**
|
|
404
|
+
|
|
405
|
+
```json
|
|
406
|
+
{"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"}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
#### **SegmentedControl with disabled items**
|
|
412
|
+
|
|
413
|
+
This example shows a `SegmentedControl` component that has one disabled item.
|
|
414
|
+
|
|
415
|
+
**/styles.css**
|
|
416
|
+
|
|
417
|
+
```css
|
|
418
|
+
body {
|
|
419
|
+
font-size: 13px;
|
|
420
|
+
font-weight: 400;
|
|
421
|
+
letter-spacing: 0.08px;
|
|
422
|
+
line-height: 20px;
|
|
423
|
+
text-transform: none;
|
|
424
|
+
font-family: "Inter", sans-serif;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
h1 {
|
|
428
|
+
font-size: 1.5rem;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.app {
|
|
432
|
+
padding: 20px;
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
**tsconfig.json**
|
|
437
|
+
|
|
438
|
+
```json
|
|
439
|
+
{
|
|
440
|
+
"include": [
|
|
441
|
+
"./**/*"
|
|
442
|
+
],
|
|
443
|
+
"compilerOptions": {
|
|
444
|
+
"strict": true,
|
|
445
|
+
"esModuleInterop": true,
|
|
446
|
+
"lib": [ "dom", "es2015" ],
|
|
447
|
+
"jsx": "react-jsx"
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**/App.tsx**
|
|
453
|
+
|
|
454
|
+
```tsx
|
|
455
|
+
import { SegmentedControl } from "@czi-sds/components";
|
|
456
|
+
import "./styles.css";
|
|
457
|
+
|
|
458
|
+
function App() {
|
|
459
|
+
const buttonDefinition = [
|
|
460
|
+
{
|
|
461
|
+
icon: "List",
|
|
462
|
+
tooltipText: "List A",
|
|
463
|
+
value: "A",
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
disabled: true,
|
|
467
|
+
icon: "List",
|
|
468
|
+
tooltipText: "List B",
|
|
469
|
+
value: "B",
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
icon: "List",
|
|
473
|
+
tooltipText: "List C",
|
|
474
|
+
value: "C",
|
|
475
|
+
},
|
|
476
|
+
];
|
|
477
|
+
return (
|
|
478
|
+
<div className="app">
|
|
479
|
+
<SegmentedControl buttonDefinition={buttonDefinition}/>
|
|
480
|
+
</div>
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export default App;
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
**/index.tsx**
|
|
488
|
+
|
|
489
|
+
```tsx
|
|
490
|
+
import React from "react";
|
|
491
|
+
import { createRoot } from "react-dom/client";
|
|
492
|
+
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
|
|
493
|
+
import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
|
|
494
|
+
import { Theme } from "@czi-sds/components";
|
|
495
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
496
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
497
|
+
|
|
498
|
+
import App from "./App";
|
|
499
|
+
|
|
500
|
+
const container = document.getElementById("root");
|
|
501
|
+
const root = createRoot(container!);
|
|
502
|
+
|
|
503
|
+
const RootApp = () => {
|
|
504
|
+
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
505
|
+
const theme = prefersDarkMode ? Theme("dark") : Theme("light");
|
|
506
|
+
|
|
507
|
+
return (
|
|
508
|
+
<StyledEngineProvider injectFirst>
|
|
509
|
+
<ThemeProvider theme={theme}>
|
|
510
|
+
<EmotionThemeProvider theme={theme}>
|
|
511
|
+
<CssBaseline />
|
|
512
|
+
<App />
|
|
513
|
+
</EmotionThemeProvider>
|
|
514
|
+
</ThemeProvider>
|
|
515
|
+
</StyledEngineProvider>
|
|
516
|
+
);
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
root.render(
|
|
520
|
+
<React.StrictMode>
|
|
521
|
+
<RootApp />
|
|
522
|
+
</React.StrictMode>
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
**/public/index.html**
|
|
528
|
+
|
|
529
|
+
```html
|
|
530
|
+
<!DOCTYPE html>
|
|
531
|
+
<html lang="en">
|
|
532
|
+
<head>
|
|
533
|
+
<meta charset="UTF-8" />
|
|
534
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
535
|
+
<title>Segmented Control</title>
|
|
536
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
537
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
538
|
+
<link
|
|
539
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
|
|
540
|
+
rel="stylesheet"
|
|
541
|
+
/>
|
|
542
|
+
<link
|
|
543
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
|
|
544
|
+
rel="stylesheet"
|
|
545
|
+
/>
|
|
546
|
+
</head>
|
|
547
|
+
<body>
|
|
548
|
+
<div id="root"></div>
|
|
549
|
+
</body>
|
|
550
|
+
</html>
|
|
551
|
+
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
**/package.json**
|
|
555
|
+
|
|
556
|
+
```json
|
|
557
|
+
{"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"}
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
---
|
|
561
|
+
|