datocms-react-ui 0.3.27 → 0.3.28
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/package.json +3 -2
- package/src/Button/index.tsx +173 -0
- package/src/Button/styles.module.css +149 -0
- package/src/Button/styles.module.css.json +1 -0
- package/src/ButtonGroup/Button/index.tsx +40 -0
- package/src/ButtonGroup/Button/styles.module.css +72 -0
- package/src/ButtonGroup/Button/styles.module.css.json +1 -0
- package/src/ButtonGroup/Group/index.tsx +31 -0
- package/src/ButtonGroup/Group/styles.module.css +6 -0
- package/src/ButtonGroup/Group/styles.module.css.json +1 -0
- package/src/ButtonGroup/index.ts +4 -0
- package/src/Canvas/index.tsx +556 -0
- package/src/Canvas/styles.module.css +75 -0
- package/src/Canvas/styles.module.css.json +1 -0
- package/src/ContextInspector/index.tsx +316 -0
- package/src/ContextInspector/styles.module.css +90 -0
- package/src/ContextInspector/styles.module.css.json +1 -0
- package/src/Dropdown/Dropdown.tsx +171 -0
- package/src/Dropdown/DropdownContext.tsx +10 -0
- package/src/Dropdown/Group.tsx +16 -0
- package/src/Dropdown/Menu.tsx +351 -0
- package/src/Dropdown/MenuContext.tsx +18 -0
- package/src/Dropdown/Option.tsx +148 -0
- package/src/Dropdown/OptionAction.tsx +42 -0
- package/src/Dropdown/Portal.tsx +46 -0
- package/src/Dropdown/Separator.tsx +13 -0
- package/src/Dropdown/Text.tsx +8 -0
- package/src/Dropdown/index.tsx +26 -0
- package/src/Dropdown/styles.module.css +331 -0
- package/src/Dropdown/styles.module.css.json +1 -0
- package/src/FieldError/index.tsx +10 -0
- package/src/FieldError/styles.module.css +6 -0
- package/src/FieldError/styles.module.css.json +1 -0
- package/src/FieldGroup/index.tsx +25 -0
- package/src/FieldGroup/styles.module.css +12 -0
- package/src/FieldGroup/styles.module.css.json +1 -0
- package/src/FieldHint/index.tsx +10 -0
- package/src/FieldHint/styles.module.css +6 -0
- package/src/FieldHint/styles.module.css.json +1 -0
- package/src/Form/index.tsx +145 -0
- package/src/Form/styles.module.css +19 -0
- package/src/Form/styles.module.css.json +1 -0
- package/src/FormLabel/index.tsx +36 -0
- package/src/FormLabel/styles.module.css +31 -0
- package/src/FormLabel/styles.module.css.json +1 -0
- package/src/Section/index.tsx +104 -0
- package/src/Section/styles.module.css +100 -0
- package/src/Section/styles.module.css.json +1 -0
- package/src/SelectField/index.tsx +244 -0
- package/src/SelectInput/index.tsx +233 -0
- package/src/SidebarPanel/index.tsx +110 -0
- package/src/SidebarPanel/styles.module.css +49 -0
- package/src/SidebarPanel/styles.module.css.json +1 -0
- package/src/Spinner/index.tsx +68 -0
- package/src/Spinner/styles.module.css +31 -0
- package/src/Spinner/styles.module.css.json +1 -0
- package/src/SwitchField/index.tsx +67 -0
- package/src/SwitchField/styles.module.css +25 -0
- package/src/SwitchField/styles.module.css.json +1 -0
- package/src/SwitchInput/index.tsx +74 -0
- package/src/SwitchInput/styles.module.css +100 -0
- package/src/SwitchInput/styles.module.css.json +1 -0
- package/src/TextField/index.tsx +58 -0
- package/src/TextField/styles.module.css +0 -0
- package/src/TextField/styles.module.css.json +1 -0
- package/src/TextInput/index.tsx +73 -0
- package/src/TextInput/styles.module.css +52 -0
- package/src/TextInput/styles.module.css.json +1 -0
- package/src/Toolbar/Button/index.tsx +32 -0
- package/src/Toolbar/Button/styles.module.css +43 -0
- package/src/Toolbar/Button/styles.module.css.json +1 -0
- package/src/Toolbar/Stack/index.tsx +33 -0
- package/src/Toolbar/Stack/styles.module.css +18 -0
- package/src/Toolbar/Stack/styles.module.css.json +1 -0
- package/src/Toolbar/Title/index.tsx +17 -0
- package/src/Toolbar/Title/styles.module.css +12 -0
- package/src/Toolbar/Title/styles.module.css.json +1 -0
- package/src/Toolbar/Toolbar/index.tsx +112 -0
- package/src/Toolbar/Toolbar/styles.module.css +15 -0
- package/src/Toolbar/Toolbar/styles.module.css.json +1 -0
- package/src/Toolbar/index.ts +8 -0
- package/src/base.css +89 -0
- package/src/generateStyleFromCtx/index.ts +25 -0
- package/src/global.css +23 -0
- package/src/icons.tsx +108 -0
- package/src/index.ts +23 -0
- package/src/mergeRefs/index.ts +8 -0
- package/src/useClickOutside/index.ts +30 -0
- package/src/useMediaQuery/index.ts +185 -0
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import React, { createContext, ReactNode, useContext, useEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
RenderMethods,
|
|
4
|
+
RenderProperties,
|
|
5
|
+
SizingUtilities,
|
|
6
|
+
} from 'datocms-plugin-sdk';
|
|
7
|
+
import s from './styles.module.css.json';
|
|
8
|
+
import { generateStyleFromCtx } from '../generateStyleFromCtx';
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
|
|
11
|
+
type BaseRenderPropertiesAndMethods = RenderProperties & RenderMethods;
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
export const CtxContext = createContext<BaseRenderPropertiesAndMethods | null>(
|
|
15
|
+
null,
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export function useCtx<T extends BaseRenderPropertiesAndMethods>(): T {
|
|
19
|
+
const ctx = useContext(CtxContext);
|
|
20
|
+
|
|
21
|
+
if (!ctx) {
|
|
22
|
+
throw new Error('useCtx requires <Canvas />!');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return ctx as T;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type CanvasProps = {
|
|
29
|
+
ctx: BaseRenderPropertiesAndMethods;
|
|
30
|
+
noAutoResizer?: boolean;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @example Color palette CSS variables
|
|
36
|
+
*
|
|
37
|
+
* Within the `Canvas` component, a color palette is made available as a set of
|
|
38
|
+
* CSS variables, allowing you to conform to the theme of the current environment:
|
|
39
|
+
*
|
|
40
|
+
* ```js
|
|
41
|
+
* <Canvas ctx={ctx}>
|
|
42
|
+
* <Section title="Text colors">
|
|
43
|
+
* <table>
|
|
44
|
+
* <tbody>
|
|
45
|
+
* <tr>
|
|
46
|
+
* <td>
|
|
47
|
+
* <code>--base-body-color</code>
|
|
48
|
+
* </td>
|
|
49
|
+
* <td width="30%">
|
|
50
|
+
* <div
|
|
51
|
+
* style={{
|
|
52
|
+
* width: '30px',
|
|
53
|
+
* height: '30px',
|
|
54
|
+
* background: 'var(--base-body-color)',
|
|
55
|
+
* }}
|
|
56
|
+
* />
|
|
57
|
+
* </td>
|
|
58
|
+
* </tr>
|
|
59
|
+
* <tr>
|
|
60
|
+
* <td>
|
|
61
|
+
* <code>--light-body-color</code>
|
|
62
|
+
* </td>
|
|
63
|
+
* <td width="30%">
|
|
64
|
+
* <div
|
|
65
|
+
* style={{
|
|
66
|
+
* width: '30px',
|
|
67
|
+
* height: '30px',
|
|
68
|
+
* background: 'var(--light-body-color)',
|
|
69
|
+
* }}
|
|
70
|
+
* />
|
|
71
|
+
* </td>
|
|
72
|
+
* </tr>
|
|
73
|
+
* <tr>
|
|
74
|
+
* <td>
|
|
75
|
+
* <code>--placeholder-body-color</code>
|
|
76
|
+
* </td>
|
|
77
|
+
* <td width="30%">
|
|
78
|
+
* <div
|
|
79
|
+
* style={{
|
|
80
|
+
* width: '30px',
|
|
81
|
+
* height: '30px',
|
|
82
|
+
* background: 'var(--placeholder-body-color)',
|
|
83
|
+
* }}
|
|
84
|
+
* />
|
|
85
|
+
* </td>
|
|
86
|
+
* </tr>
|
|
87
|
+
* </tbody>
|
|
88
|
+
* </table>
|
|
89
|
+
* </Section>
|
|
90
|
+
* <Section title="UI colors">
|
|
91
|
+
* <table>
|
|
92
|
+
* <tbody>
|
|
93
|
+
* <tr>
|
|
94
|
+
* <td>
|
|
95
|
+
* <code>--light-bg-color</code>
|
|
96
|
+
* </td>
|
|
97
|
+
* <td width="30%">
|
|
98
|
+
* <div
|
|
99
|
+
* style={{
|
|
100
|
+
* width: '30px',
|
|
101
|
+
* height: '30px',
|
|
102
|
+
* background: 'var(--light-bg-color)',
|
|
103
|
+
* }}
|
|
104
|
+
* />
|
|
105
|
+
* </td>
|
|
106
|
+
* </tr>
|
|
107
|
+
* <tr>
|
|
108
|
+
* <td>
|
|
109
|
+
* <code>--lighter-bg-color</code>
|
|
110
|
+
* </td>
|
|
111
|
+
* <td width="30%">
|
|
112
|
+
* <div
|
|
113
|
+
* style={{
|
|
114
|
+
* width: '30px',
|
|
115
|
+
* height: '30px',
|
|
116
|
+
* background: 'var(--lighter-bg-color)',
|
|
117
|
+
* }}
|
|
118
|
+
* />
|
|
119
|
+
* </td>
|
|
120
|
+
* </tr>
|
|
121
|
+
* <tr>
|
|
122
|
+
* <td>
|
|
123
|
+
* <code>--disabled-bg-color</code>
|
|
124
|
+
* </td>
|
|
125
|
+
* <td width="30%">
|
|
126
|
+
* <div
|
|
127
|
+
* style={{
|
|
128
|
+
* width: '30px',
|
|
129
|
+
* height: '30px',
|
|
130
|
+
* background: 'var(--disabled-bg-color)',
|
|
131
|
+
* }}
|
|
132
|
+
* />
|
|
133
|
+
* </td>
|
|
134
|
+
* </tr>
|
|
135
|
+
* <tr>
|
|
136
|
+
* <td>
|
|
137
|
+
* <code>--border-color</code>
|
|
138
|
+
* </td>
|
|
139
|
+
* <td width="30%">
|
|
140
|
+
* <div
|
|
141
|
+
* style={{
|
|
142
|
+
* width: '30px',
|
|
143
|
+
* height: '30px',
|
|
144
|
+
* background: 'var(--border-color)',
|
|
145
|
+
* }}
|
|
146
|
+
* />
|
|
147
|
+
* </td>
|
|
148
|
+
* </tr>
|
|
149
|
+
* <tr>
|
|
150
|
+
* <td>
|
|
151
|
+
* <code>--darker-border-color</code>
|
|
152
|
+
* </td>
|
|
153
|
+
* <td width="30%">
|
|
154
|
+
* <div
|
|
155
|
+
* style={{
|
|
156
|
+
* width: '30px',
|
|
157
|
+
* height: '30px',
|
|
158
|
+
* background: 'var(--darker-border-color)',
|
|
159
|
+
* }}
|
|
160
|
+
* />
|
|
161
|
+
* </td>
|
|
162
|
+
* </tr>
|
|
163
|
+
* <tr>
|
|
164
|
+
* <td>
|
|
165
|
+
* <code>--alert-color</code>
|
|
166
|
+
* </td>
|
|
167
|
+
* <td width="30%">
|
|
168
|
+
* <div
|
|
169
|
+
* style={{
|
|
170
|
+
* width: '30px',
|
|
171
|
+
* height: '30px',
|
|
172
|
+
* background: 'var(--alert-color)',
|
|
173
|
+
* }}
|
|
174
|
+
* />
|
|
175
|
+
* </td>
|
|
176
|
+
* </tr>
|
|
177
|
+
* <tr>
|
|
178
|
+
* <td>
|
|
179
|
+
* <code>--warning-color</code>
|
|
180
|
+
* </td>
|
|
181
|
+
* <td width="30%">
|
|
182
|
+
* <div
|
|
183
|
+
* style={{
|
|
184
|
+
* width: '30px',
|
|
185
|
+
* height: '30px',
|
|
186
|
+
* background: 'var(--warning-color)',
|
|
187
|
+
* }}
|
|
188
|
+
* />
|
|
189
|
+
* </td>
|
|
190
|
+
* </tr>
|
|
191
|
+
* <tr>
|
|
192
|
+
* <td>
|
|
193
|
+
* <code>--notice-color</code>
|
|
194
|
+
* </td>
|
|
195
|
+
* <td width="30%">
|
|
196
|
+
* <div
|
|
197
|
+
* style={{
|
|
198
|
+
* width: '30px',
|
|
199
|
+
* height: '30px',
|
|
200
|
+
* background: 'var(--notice-color)',
|
|
201
|
+
* }}
|
|
202
|
+
* />
|
|
203
|
+
* </td>
|
|
204
|
+
* </tr>
|
|
205
|
+
* <tr>
|
|
206
|
+
* <td>
|
|
207
|
+
* <code>--warning-bg-color</code>
|
|
208
|
+
* </td>
|
|
209
|
+
* <td width="30%">
|
|
210
|
+
* <div
|
|
211
|
+
* style={{
|
|
212
|
+
* width: '30px',
|
|
213
|
+
* height: '30px',
|
|
214
|
+
* background: 'var(--warning-bg-color)',
|
|
215
|
+
* }}
|
|
216
|
+
* />
|
|
217
|
+
* </td>
|
|
218
|
+
* </tr>
|
|
219
|
+
* <tr>
|
|
220
|
+
* <td>
|
|
221
|
+
* <code>--add-color</code>
|
|
222
|
+
* </td>
|
|
223
|
+
* <td width="30%">
|
|
224
|
+
* <div
|
|
225
|
+
* style={{
|
|
226
|
+
* width: '30px',
|
|
227
|
+
* height: '30px',
|
|
228
|
+
* background: 'var(--add-color)',
|
|
229
|
+
* }}
|
|
230
|
+
* />
|
|
231
|
+
* </td>
|
|
232
|
+
* </tr>
|
|
233
|
+
* <tr>
|
|
234
|
+
* <td>
|
|
235
|
+
* <code>--remove-color</code>
|
|
236
|
+
* </td>
|
|
237
|
+
* <td width="30%">
|
|
238
|
+
* <div
|
|
239
|
+
* style={{
|
|
240
|
+
* width: '30px',
|
|
241
|
+
* height: '30px',
|
|
242
|
+
* background: 'var(--remove-color)',
|
|
243
|
+
* }}
|
|
244
|
+
* />
|
|
245
|
+
* </td>
|
|
246
|
+
* </tr>
|
|
247
|
+
* </tbody>
|
|
248
|
+
* </table>
|
|
249
|
+
* </Section>
|
|
250
|
+
* <Section title="Project-specific colors">
|
|
251
|
+
* <table>
|
|
252
|
+
* <tbody>
|
|
253
|
+
* <tr>
|
|
254
|
+
* <td>
|
|
255
|
+
* <code>--accent-color</code>
|
|
256
|
+
* </td>
|
|
257
|
+
* <td width="30%">
|
|
258
|
+
* <div
|
|
259
|
+
* style={{
|
|
260
|
+
* width: '30px',
|
|
261
|
+
* height: '30px',
|
|
262
|
+
* background: 'var(--accent-color)',
|
|
263
|
+
* }}
|
|
264
|
+
* />
|
|
265
|
+
* </td>
|
|
266
|
+
* </tr>
|
|
267
|
+
* <tr>
|
|
268
|
+
* <td>
|
|
269
|
+
* <code>--primary-color</code>
|
|
270
|
+
* </td>
|
|
271
|
+
* <td width="30%">
|
|
272
|
+
* <div
|
|
273
|
+
* style={{
|
|
274
|
+
* width: '30px',
|
|
275
|
+
* height: '30px',
|
|
276
|
+
* background: 'var(--primary-color)',
|
|
277
|
+
* }}
|
|
278
|
+
* />
|
|
279
|
+
* </td>
|
|
280
|
+
* </tr>
|
|
281
|
+
* <tr>
|
|
282
|
+
* <td>
|
|
283
|
+
* <code>--light-color</code>
|
|
284
|
+
* </td>
|
|
285
|
+
* <td width="30%">
|
|
286
|
+
* <div
|
|
287
|
+
* style={{
|
|
288
|
+
* width: '30px',
|
|
289
|
+
* height: '30px',
|
|
290
|
+
* background: 'var(--light-color)',
|
|
291
|
+
* }}
|
|
292
|
+
* />
|
|
293
|
+
* </td>
|
|
294
|
+
* </tr>
|
|
295
|
+
* <tr>
|
|
296
|
+
* <td>
|
|
297
|
+
* <code>--dark-color</code>
|
|
298
|
+
* </td>
|
|
299
|
+
* <td width="30%">
|
|
300
|
+
* <div
|
|
301
|
+
* style={{
|
|
302
|
+
* width: '30px',
|
|
303
|
+
* height: '30px',
|
|
304
|
+
* background: 'var(--dark-color)',
|
|
305
|
+
* }}
|
|
306
|
+
* />
|
|
307
|
+
* </td>
|
|
308
|
+
* </tr>
|
|
309
|
+
* </tbody>
|
|
310
|
+
* </table>
|
|
311
|
+
* </Section>
|
|
312
|
+
* </Canvas>;
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* @example Typography CSS variables
|
|
316
|
+
*
|
|
317
|
+
* Typography is a foundational element in UI design. Good typography
|
|
318
|
+
* establishes a strong, cohesive visual hierarchy and presents content clearly
|
|
319
|
+
* and efficiently to users. Within the `Canvas` component, a set of CSS
|
|
320
|
+
* variables is available allowing your plugin to conform to the overall
|
|
321
|
+
* look&feel of DatoCMS:
|
|
322
|
+
*
|
|
323
|
+
* ```js
|
|
324
|
+
* <Canvas ctx={ctx}>
|
|
325
|
+
* <table>
|
|
326
|
+
* <tbody>
|
|
327
|
+
* <tr>
|
|
328
|
+
* <td>
|
|
329
|
+
* <code>--font-size-xxs</code>
|
|
330
|
+
* </td>
|
|
331
|
+
* <td>
|
|
332
|
+
* <div style={{ fontSize: 'var(--font-size-xxs)' }}>
|
|
333
|
+
* Size XXS
|
|
334
|
+
* </div>
|
|
335
|
+
* </td>
|
|
336
|
+
* </tr>
|
|
337
|
+
* <tr>
|
|
338
|
+
* <td>
|
|
339
|
+
* <code>--font-size-xs</code>
|
|
340
|
+
* </td>
|
|
341
|
+
* <td>
|
|
342
|
+
* <div style={{ fontSize: 'var(--font-size-xs)' }}>Size XS</div>
|
|
343
|
+
* </td>
|
|
344
|
+
* </tr>
|
|
345
|
+
* <tr>
|
|
346
|
+
* <td>
|
|
347
|
+
* <code>--font-size-s</code>
|
|
348
|
+
* </td>
|
|
349
|
+
* <td>
|
|
350
|
+
* <div style={{ fontSize: 'var(--font-size-s)' }}>Size S</div>
|
|
351
|
+
* </td>
|
|
352
|
+
* </tr>
|
|
353
|
+
* <tr>
|
|
354
|
+
* <td>
|
|
355
|
+
* <code>--font-size-m</code>
|
|
356
|
+
* </td>
|
|
357
|
+
* <td>
|
|
358
|
+
* <div style={{ fontSize: 'var(--font-size-m)' }}>Size M</div>
|
|
359
|
+
* </td>
|
|
360
|
+
* </tr>
|
|
361
|
+
* <tr>
|
|
362
|
+
* <td>
|
|
363
|
+
* <code>--font-size-l</code>
|
|
364
|
+
* </td>
|
|
365
|
+
* <td>
|
|
366
|
+
* <div
|
|
367
|
+
* style={{
|
|
368
|
+
* fontSize: 'var(--font-size-l)',
|
|
369
|
+
* fontWeight: 'var(--font-weight-bold)',
|
|
370
|
+
* }}
|
|
371
|
+
* >
|
|
372
|
+
* Size L
|
|
373
|
+
* </div>
|
|
374
|
+
* </td>
|
|
375
|
+
* </tr>
|
|
376
|
+
* <tr>
|
|
377
|
+
* <td>
|
|
378
|
+
* <code>--font-size-xl</code>
|
|
379
|
+
* </td>
|
|
380
|
+
* <td>
|
|
381
|
+
* <div
|
|
382
|
+
* style={{
|
|
383
|
+
* fontSize: 'var(--font-size-xl)',
|
|
384
|
+
* fontWeight: 'var(--font-weight-bold)',
|
|
385
|
+
* }}
|
|
386
|
+
* >
|
|
387
|
+
* Size XL
|
|
388
|
+
* </div>
|
|
389
|
+
* </td>
|
|
390
|
+
* </tr>
|
|
391
|
+
* <tr>
|
|
392
|
+
* <td>
|
|
393
|
+
* <code>--font-size-xxl</code>
|
|
394
|
+
* </td>
|
|
395
|
+
* <td>
|
|
396
|
+
* <div
|
|
397
|
+
* style={{
|
|
398
|
+
* fontSize: 'var(--font-size-xxl)',
|
|
399
|
+
* fontWeight: 'var(--font-weight-bold)',
|
|
400
|
+
* }}
|
|
401
|
+
* >
|
|
402
|
+
* Size XXL
|
|
403
|
+
* </div>
|
|
404
|
+
* </td>
|
|
405
|
+
* </tr>
|
|
406
|
+
* <tr>
|
|
407
|
+
* <td>
|
|
408
|
+
* <code>--font-size-xxxl</code>
|
|
409
|
+
* </td>
|
|
410
|
+
* <td>
|
|
411
|
+
* <div
|
|
412
|
+
* style={{
|
|
413
|
+
* fontSize: 'var(--font-size-xxxl)',
|
|
414
|
+
* fontWeight: 'var(--font-weight-bold)',
|
|
415
|
+
* }}
|
|
416
|
+
* >
|
|
417
|
+
* Size XXXL
|
|
418
|
+
* </div>
|
|
419
|
+
* </td>
|
|
420
|
+
* </tr>
|
|
421
|
+
* </tbody>
|
|
422
|
+
* </table>
|
|
423
|
+
* </Canvas>;
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* @example Spacing CSS variables
|
|
427
|
+
*
|
|
428
|
+
* The following CSS variables are available as well, to mimick the spacing
|
|
429
|
+
* between elements used by the main DatoCMS application. Negative spacing
|
|
430
|
+
* variables are available too (`--negative-spacing-<SIZE>`).
|
|
431
|
+
*
|
|
432
|
+
* ```js
|
|
433
|
+
* <Canvas ctx={ctx}>
|
|
434
|
+
* <table>
|
|
435
|
+
* <tbody>
|
|
436
|
+
* <tr>
|
|
437
|
+
* <td>
|
|
438
|
+
* <code>--spacing-s</code>
|
|
439
|
+
* </td>
|
|
440
|
+
* <td>
|
|
441
|
+
* <div
|
|
442
|
+
* style={{
|
|
443
|
+
* background: 'var(--accent-color)',
|
|
444
|
+
* width: 'var(--spacing-s)',
|
|
445
|
+
* height: 'var(--spacing-s)',
|
|
446
|
+
* }}
|
|
447
|
+
* />
|
|
448
|
+
* </td>
|
|
449
|
+
* </tr>
|
|
450
|
+
* <tr>
|
|
451
|
+
* <td>
|
|
452
|
+
* <code>--spacing-m</code>
|
|
453
|
+
* </td>
|
|
454
|
+
* <td>
|
|
455
|
+
* <div
|
|
456
|
+
* style={{
|
|
457
|
+
* background: 'var(--accent-color)',
|
|
458
|
+
* width: 'var(--spacing-m)',
|
|
459
|
+
* height: 'var(--spacing-m)',
|
|
460
|
+
* }}
|
|
461
|
+
* />
|
|
462
|
+
* </td>
|
|
463
|
+
* </tr>
|
|
464
|
+
* <tr>
|
|
465
|
+
* <td>
|
|
466
|
+
* <code>--spacing-l</code>
|
|
467
|
+
* </td>
|
|
468
|
+
* <td>
|
|
469
|
+
* <div
|
|
470
|
+
* style={{
|
|
471
|
+
* background: 'var(--accent-color)',
|
|
472
|
+
* width: 'var(--spacing-l)',
|
|
473
|
+
* height: 'var(--spacing-l)',
|
|
474
|
+
* }}
|
|
475
|
+
* />
|
|
476
|
+
* </td>
|
|
477
|
+
* </tr>
|
|
478
|
+
* <tr>
|
|
479
|
+
* <td>
|
|
480
|
+
* <code>--spacing-xl</code>
|
|
481
|
+
* </td>
|
|
482
|
+
* <td>
|
|
483
|
+
* <div
|
|
484
|
+
* style={{
|
|
485
|
+
* background: 'var(--accent-color)',
|
|
486
|
+
* width: 'var(--spacing-xl)',
|
|
487
|
+
* height: 'var(--spacing-xl)',
|
|
488
|
+
* }}
|
|
489
|
+
* />
|
|
490
|
+
* </td>
|
|
491
|
+
* </tr>
|
|
492
|
+
* <tr>
|
|
493
|
+
* <td>
|
|
494
|
+
* <code>--spacing-xxl</code>
|
|
495
|
+
* </td>
|
|
496
|
+
* <td>
|
|
497
|
+
* <div
|
|
498
|
+
* style={{
|
|
499
|
+
* background: 'var(--accent-color)',
|
|
500
|
+
* width: 'var(--spacing-xxl)',
|
|
501
|
+
* height: 'var(--spacing-xxl)',
|
|
502
|
+
* }}
|
|
503
|
+
* />
|
|
504
|
+
* </td>
|
|
505
|
+
* </tr>
|
|
506
|
+
* <tr>
|
|
507
|
+
* <td>
|
|
508
|
+
* <code>--spacing-xxxl</code>
|
|
509
|
+
* </td>
|
|
510
|
+
* <td>
|
|
511
|
+
* <div
|
|
512
|
+
* style={{
|
|
513
|
+
* background: 'var(--accent-color)',
|
|
514
|
+
* width: 'var(--spacing-xxxl)',
|
|
515
|
+
* height: 'var(--spacing-xxxl)',
|
|
516
|
+
* }}
|
|
517
|
+
* />
|
|
518
|
+
* </td>
|
|
519
|
+
* </tr>
|
|
520
|
+
* </tbody>
|
|
521
|
+
* </table>
|
|
522
|
+
* </Canvas>;
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
|
|
526
|
+
export function Canvas({
|
|
527
|
+
ctx,
|
|
528
|
+
children,
|
|
529
|
+
noAutoResizer,
|
|
530
|
+
}: CanvasProps): JSX.Element {
|
|
531
|
+
const { mode } = (ctx as unknown) as { mode: string };
|
|
532
|
+
|
|
533
|
+
useEffect(() => {
|
|
534
|
+
if (mode !== 'renderPage' && !noAutoResizer) {
|
|
535
|
+
const ctxWithAutoResizer = (ctx as unknown) as SizingUtilities;
|
|
536
|
+
ctxWithAutoResizer.startAutoResizer();
|
|
537
|
+
|
|
538
|
+
return () => {
|
|
539
|
+
ctxWithAutoResizer.stopAutoResizer();
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
return undefined;
|
|
544
|
+
}, [mode, noAutoResizer]);
|
|
545
|
+
|
|
546
|
+
return (
|
|
547
|
+
<CtxContext.Provider value={ctx}>
|
|
548
|
+
<div
|
|
549
|
+
className={classNames(s['themeVariables'], s['canvas'])}
|
|
550
|
+
style={generateStyleFromCtx(ctx)}
|
|
551
|
+
>
|
|
552
|
+
{children}
|
|
553
|
+
</div>
|
|
554
|
+
</CtxContext.Provider>
|
|
555
|
+
);
|
|
556
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
.themeVariables {
|
|
2
|
+
/* Colors */
|
|
3
|
+
--base-body-color: rgb(52, 54, 58);
|
|
4
|
+
--base-body-color-rgb-components: 52, 54, 58;
|
|
5
|
+
--light-body-color: rgb(132, 132, 132);
|
|
6
|
+
--light-body-color-rgb-components: 132, 132, 132;
|
|
7
|
+
--placeholder-body-color: rgb(198, 198, 198);
|
|
8
|
+
--placeholder-body-color-rgb-components: 198, 198, 198;
|
|
9
|
+
--light-bg-color: rgb(245, 245, 245);
|
|
10
|
+
--light-bg-color-rgb-components: 245, 245, 245;
|
|
11
|
+
--lighter-bg-color: rgb(248, 248, 248);
|
|
12
|
+
--lighter-bg-color-rgb-components: 248, 248, 248;
|
|
13
|
+
--disabled-bg-color: rgb(237, 237, 237);
|
|
14
|
+
--disabled-bg-color-rgb-components: 237, 237, 237;
|
|
15
|
+
--border-color: rgb(240, 240, 240);
|
|
16
|
+
--border-color-rgb-components: 240, 240, 240;
|
|
17
|
+
--darker-border-color: rgb(215, 215, 215);
|
|
18
|
+
--darker-border-color-rgb-components: 215, 215, 215;
|
|
19
|
+
--alert-color: rgb(255, 94, 73);
|
|
20
|
+
--alert-color-rgb-components: 255, 94, 73;
|
|
21
|
+
--warning-color: rgb(255, 215, 0);
|
|
22
|
+
--warning-color-rgb-components: 255, 215, 0;
|
|
23
|
+
--notice-color: rgb(70, 215, 0);
|
|
24
|
+
--notice-color-rgb-components: 70, 215, 0;
|
|
25
|
+
--warning-bg-color: rgb(255, 255, 229);
|
|
26
|
+
--warning-bg-color-rgb-components: 255, 255, 229;
|
|
27
|
+
--add-color: rgb(76, 176, 109);
|
|
28
|
+
--add-color-rgb-components: 76, 176, 109;
|
|
29
|
+
--remove-color: rgb(235, 87, 106);
|
|
30
|
+
--remove-color-rgb-components: 235, 87, 106;
|
|
31
|
+
|
|
32
|
+
/* Fonts */
|
|
33
|
+
--base-font-family: 'colfax-web', 'Roboto', 'Helvetica Neue', Helvetica,
|
|
34
|
+
Roboto, Arial, sans-serif;
|
|
35
|
+
--monospaced-font-family: 'Roboto Mono', 'Menlo', 'Bitstream Vera Sans Mono',
|
|
36
|
+
Consolas, Courier, monospace;
|
|
37
|
+
--font-weight-bold: 500;
|
|
38
|
+
|
|
39
|
+
/* Spacing */
|
|
40
|
+
--spacing-s: calc(0.5 * 12 * 0.0625rem);
|
|
41
|
+
--spacing-m: calc(1 * 12 * 0.0625rem);
|
|
42
|
+
--spacing-l: calc(2 * 12 * 0.0625rem);
|
|
43
|
+
--spacing-xl: calc(3 * 12 * 0.0625rem);
|
|
44
|
+
--spacing-xxl: calc(5 * 12 * 0.0625rem);
|
|
45
|
+
--spacing-xxxl: calc(8 * 12 * 0.0625rem);
|
|
46
|
+
|
|
47
|
+
--negative-spacing-s: calc(-0.5 * 12 * 0.0625rem);
|
|
48
|
+
--negative-spacing-m: calc(-1 * 12 * 0.0625rem);
|
|
49
|
+
--negative-spacing-l: calc(-2 * 12 * 0.0625rem);
|
|
50
|
+
--negative-spacing-xl: calc(-3 * 12 * 0.0625rem);
|
|
51
|
+
--negative-spacing-xxl: calc(-5 * 12 * 0.0625rem);
|
|
52
|
+
--negative-spacing-xxxl: calc(-8 * 12 * 0.0625rem);
|
|
53
|
+
|
|
54
|
+
/* Font-size */
|
|
55
|
+
--font-size-xxs: calc(11 * 0.0625rem);
|
|
56
|
+
--font-size-xs: calc(12 * 0.0625rem);
|
|
57
|
+
--font-size-s: calc(14 * 0.0625rem);
|
|
58
|
+
--font-size-m: calc(15 * 0.0625rem);
|
|
59
|
+
--font-size-l: calc(17 * 0.0625rem);
|
|
60
|
+
--font-size-xl: calc(19 * 0.0625rem);
|
|
61
|
+
--font-size-xxl: calc(25 * 0.0625rem);
|
|
62
|
+
--font-size-xxxl: calc(30 * 0.0625rem);
|
|
63
|
+
|
|
64
|
+
--material-ease: cubic-bezier(0.55, 0, 0.1, 1);
|
|
65
|
+
--inertial-ease: cubic-bezier(0.19, 1, 0.22, 1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.canvas {
|
|
69
|
+
font-family: var(--base-font-family);
|
|
70
|
+
-webkit-text-size-adjust: 100%;
|
|
71
|
+
line-height: 1.5;
|
|
72
|
+
color: var(--base-body-color);
|
|
73
|
+
font-size: var(--font-size-m);
|
|
74
|
+
text-rendering: optimizeLegibility;
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"themeVariables":"_themeVariables_ovgoa_1","canvas":"_canvas_ovgoa_68"}
|