UNPKG

19.5 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.base = exports.generate = void 0;
5
6var _polished = require("polished");
7
8var _styledComponents = require("styled-components");
9
10var _grommetIcons = require("grommet-icons");
11
12var _utils = require("../utils");
13
14function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
16var brandColor = '#7D4CDB';
17var accentColors = ['#FD6FFF', '#61EC9F', '#60EBE1', '#FFCA58'];
18var neutralColors = ['#3D138D', '#BE60EB', '#00C781', '#6194EB', '#FFB202'];
19var statusColors = {
20 critical: '#EB6060',
21 error: '#EB6060',
22 warning: '#F7E463',
23 ok: '#7CD992',
24 unknown: '#a8a8a8',
25 disabled: '#a8a8a8'
26};
27var darkColors = ['#333333', '#444444', '#555555', '#666666', '#777777', '#999999'];
28var lightColors = ['#F6F6F6', '#EEEEEE', '#DDDDDD', '#CCCCCC', '#BBBBBB', '#AAAAAA'];
29var focusColor = accentColors[0];
30var colors = {
31 active: (0, _polished.rgba)(221, 221, 221, 0.5),
32 black: '#000000',
33 border: {
34 dark: (0, _polished.rgba)(255, 255, 255, 0.33),
35 light: (0, _polished.rgba)(0, 0, 0, 0.33)
36 },
37 brand: brandColor,
38 control: {
39 dark: 'accent-1',
40 light: 'brand'
41 },
42 focus: focusColor,
43 placeholder: '#AAAAAA',
44 text: {
45 dark: '#f8f8f8',
46 light: '#444444'
47 },
48 white: '#FFFFFF'
49};
50
51var colorArray = function colorArray(array, prefix) {
52 return array.forEach(function (color, index) {
53 colors[prefix + "-" + (index + 1)] = color;
54 });
55};
56
57colorArray(accentColors, 'accent');
58colorArray(darkColors, 'dark');
59colorArray(lightColors, 'light');
60colorArray(neutralColors, 'neutral');
61Object.keys(statusColors).forEach(function (color) {
62 colors["status-" + color] = statusColors[color];
63});
64
65var generate = function generate(baseSpacing, scale) {
66 if (baseSpacing === void 0) {
67 baseSpacing = 24;
68 }
69
70 if (scale === void 0) {
71 scale = 6;
72 }
73
74 // 24
75 var baseFontSize = baseSpacing * 0.75; // 18
76
77 var fontScale = baseSpacing / scale; // 4
78
79 var fontSizing = function fontSizing(factor) {
80 return {
81 size: baseFontSize + factor * fontScale + "px",
82 height: baseSpacing + factor * fontScale + "px",
83 // maxWidth chosen to be ~50 characters wide
84 // see: https://ux.stackexchange.com/a/34125
85 maxWidth: baseSpacing * (baseFontSize + factor * fontScale) + "px"
86 };
87 };
88
89 var borderWidth = 2;
90 var result = {
91 global: {
92 animation: {
93 duration: '1s',
94 jiggle: {
95 duration: '0.1s'
96 }
97 },
98 borderSize: {
99 xsmall: '1px',
100 small: '2px',
101 medium: baseSpacing / 6 + "px",
102 // 4
103 large: baseSpacing / 2 + "px",
104 // 12
105 xlarge: baseSpacing + "px" // 24
106
107 },
108 breakpoints: {
109 small: {
110 value: baseSpacing * 32,
111 // 768
112 borderSize: {
113 xsmall: '1px',
114 small: '2px',
115 medium: baseSpacing / 6 + "px",
116 // 4
117 large: baseSpacing / 4 + "px",
118 // 6
119 xlarge: baseSpacing / 2 + "px" // 12
120
121 },
122 edgeSize: {
123 none: '0px',
124 hair: '1px',
125 // for Chart
126 xxsmall: '2px',
127 xsmall: baseSpacing / 8 + "px",
128 // 3
129 small: baseSpacing / 4 + "px",
130 // 6
131 medium: baseSpacing / 2 + "px",
132 // 12
133 large: baseSpacing + "px",
134 // 24
135 xlarge: baseSpacing * 2 + "px" // 48
136
137 },
138 size: {
139 xxsmall: baseSpacing + "px",
140 // 24
141 xsmall: baseSpacing * 2 + "px",
142 // 48
143 small: baseSpacing * 4 + "px",
144 // 96
145 medium: baseSpacing * 8 + "px",
146 // 192
147 large: baseSpacing * 16 + "px",
148 // 384
149 xlarge: baseSpacing * 32 + "px",
150 // 768
151 full: '100%'
152 }
153 },
154 medium: {
155 value: baseSpacing * 64 // 1536
156
157 },
158 large: {} // anything above 'medium'
159
160 },
161 // Breakpoints used at Server Side Rendering for the initial rendering
162 // These values correspond to the theme breakpoints
163 deviceBreakpoints: {
164 phone: 'small',
165 tablet: 'medium',
166 computer: 'large'
167 },
168 colors: colors,
169 control: {
170 border: {
171 width: '1px',
172 radius: '4px',
173 color: 'border'
174 }
175 },
176 debounceDelay: 300,
177 // The time to wait after the user stopped typing, measured in ms.
178 drop: {
179 background: '#ffffff',
180 border: {
181 width: '0px',
182 radius: '0px'
183 },
184 shadowSize: 'small',
185 zIndex: '20'
186 },
187 edgeSize: {
188 none: '0px',
189 hair: '1px',
190 // for Chart
191 xxsmall: baseSpacing / 8 + "px",
192 // 3
193 xsmall: baseSpacing / 4 + "px",
194 // 6
195 small: baseSpacing / 2 + "px",
196 // 12
197 medium: baseSpacing + "px",
198 // 24
199 large: baseSpacing * 2 + "px",
200 // 48
201 xlarge: baseSpacing * 4 + "px",
202 // 96
203 responsiveBreakpoint: 'small'
204 },
205 elevation: {
206 light: {
207 none: 'none',
208 xsmall: '0px 1px 2px rgba(0, 0, 0, 0.20)',
209 small: '0px 2px 4px rgba(0, 0, 0, 0.20)',
210 medium: '0px 4px 8px rgba(0, 0, 0, 0.20)',
211 large: '0px 8px 16px rgba(0, 0, 0, 0.20)',
212 xlarge: '0px 12px 24px rgba(0, 0, 0, 0.20)'
213 },
214 dark: {
215 none: 'none',
216 xsmall: '0px 2px 2px rgba(255, 255, 255, 0.40)',
217 small: '0px 4px 4px rgba(255, 255, 255, 0.40)',
218 medium: '0px 6px 8px rgba(255, 255, 255, 0.40)',
219 large: '0px 8px 16px rgba(255, 255, 255, 0.40)',
220 xlarge: '0px 12px 24px rgba(255, 255, 255, 0.40)'
221 }
222 },
223 focus: {
224 border: {
225 color: 'focus'
226 }
227 },
228 font: _extends({}, fontSizing(0)),
229 hover: {
230 background: {
231 dark: {
232 color: 'active',
233 opacity: 'medium'
234 },
235 light: {
236 color: 'active',
237 opacity: 'medium'
238 }
239 },
240 color: {
241 dark: 'white',
242 light: 'black'
243 }
244 },
245 input: {
246 padding: baseSpacing / 2 + "px",
247 weight: 600
248 },
249 opacity: {
250 strong: 0.8,
251 medium: 0.4,
252 weak: 0.1
253 },
254 spacing: baseSpacing + "px",
255 size: {
256 xxsmall: baseSpacing * 2 + "px",
257 // 48
258 xsmall: baseSpacing * 4 + "px",
259 // 96
260 small: baseSpacing * 8 + "px",
261 // 192
262 medium: baseSpacing * 16 + "px",
263 // 384
264 large: baseSpacing * 32 + "px",
265 // 768
266 xlarge: baseSpacing * 48 + "px",
267 // 1152
268 xxlarge: baseSpacing * 64 + "px",
269 // 1536
270 full: '100%'
271 }
272 },
273 accordion: {
274 icons: {
275 collapse: _grommetIcons.FormUp,
276 expand: _grommetIcons.FormDown // color: { dark: undefined, light: undefined },
277
278 }
279 },
280 anchor: {
281 textDecoration: 'none',
282 fontWeight: 600,
283 color: {
284 dark: '#6194EB',
285 light: '#1D67E3'
286 },
287 hover: {
288 textDecoration: 'underline' // fontWeight: undefined,
289 // extend: undefined,
290
291 } // extend: undefined,
292
293 },
294 box: {
295 responsiveBreakpoint: 'small' // when we switch rows to columns
296 // extend: undefined,
297
298 },
299 button: {
300 border: {
301 // color: { dark: undefined, light: undefined }
302 width: borderWidth + "px",
303 radius: baseSpacing * 0.75 + "px"
304 },
305 // color: { dark: undefined, light: undefined }
306 primary: {// color: { dark: undefined, light: undefined }
307 },
308 disabled: {
309 opacity: 0.3
310 },
311 minWidth: baseSpacing * 4 + "px",
312 maxWidth: baseSpacing * 16 + "px",
313 padding: {
314 vertical: baseSpacing / 4 - borderWidth + "px",
315 horizontal: baseSpacing - borderWidth + "px"
316 }
317 },
318 calendar: {
319 // daySize must align with global.size
320 small: {
321 fontSize: baseFontSize - fontScale + "px",
322 lineHeight: 1.375,
323 daySize: baseSpacing * 8 / 7 + "px",
324 slideDuration: '0.2s'
325 },
326 medium: {
327 fontSize: baseFontSize + "px",
328 lineHeight: 1.45,
329 daySize: baseSpacing * 16 / 7 + "px",
330 slideDuration: '0.5s'
331 },
332 large: {
333 fontSize: baseFontSize + 3 * fontScale + "px",
334 lineHeight: 1.11,
335 daySize: baseSpacing * 32 / 7 + "px",
336 slideDuration: '0.8s'
337 },
338 icons: {
339 previous: _grommetIcons.Previous,
340 next: _grommetIcons.Next,
341 small: {
342 previous: _grommetIcons.FormPrevious,
343 next: _grommetIcons.FormNext
344 }
345 }
346 },
347 carousel: {
348 icons: {
349 current: _grommetIcons.Subtract,
350 next: _grommetIcons.Next,
351 previous: _grommetIcons.Previous // color: undefined,
352
353 }
354 },
355 checkBox: {
356 border: {
357 color: {
358 dark: 'rgba(255, 255, 255, 0.5)',
359 light: 'rgba(0, 0, 0, 0.15)'
360 },
361 width: '2px'
362 },
363 check: {
364 radius: '4px',
365 thickness: '4px' // extend: undefined,
366
367 },
368 icon: {// size: undefined,
369 // extend: undefined,
370 },
371 icons: {// checked: undefined,
372 // indeterminate: undefined,
373 },
374 hover: {
375 border: {
376 color: {
377 dark: 'white',
378 light: 'black'
379 }
380 }
381 },
382 size: baseSpacing + "px",
383 // color: { dark: undefined, light: undefined },
384 toggle: {
385 color: {
386 dark: '#d9d9d9',
387 light: '#d9d9d9'
388 },
389 radius: baseSpacing + "px",
390 size: baseSpacing * 2 + "px",
391 // extend: undefined,
392 knob: {// extend: undefined,
393 }
394 } // extend: undefined,
395
396 },
397 clock: {
398 analog: {
399 hour: {
400 color: {
401 dark: 'light-2',
402 light: 'dark-3'
403 },
404 width: baseSpacing / 3 + "px",
405 size: baseSpacing + "px",
406 shape: 'round'
407 },
408 minute: {
409 color: {
410 dark: 'light-5',
411 light: 'dark-5'
412 },
413 width: baseSpacing / 6 + "px",
414 size: Math.round(baseSpacing / 2) + "px",
415 shape: 'round'
416 },
417 second: {
418 color: {
419 dark: 'accent-1',
420 light: 'accent-1'
421 },
422 width: baseSpacing / 8 + "px",
423 size: Math.round(baseSpacing / 2.666) + "px",
424 shape: 'round'
425 },
426 size: {
427 small: baseSpacing * 3 + "px",
428 medium: baseSpacing * 4 + "px",
429 large: baseSpacing * 6 + "px",
430 xlarge: baseSpacing * 9 + "px",
431 huge: baseSpacing * 12 + "px"
432 }
433 },
434 digital: {
435 text: {
436 xsmall: {
437 size: baseFontSize - 2 * fontScale + "px",
438 height: 1.5
439 },
440 small: {
441 size: baseFontSize - fontScale + "px",
442 height: 1.43
443 },
444 medium: {
445 size: baseFontSize + "px",
446 height: 1.375
447 },
448 large: {
449 size: baseFontSize + fontScale + "px",
450 height: 1.167
451 },
452 xlarge: {
453 size: baseFontSize + 2 * fontScale + "px",
454 height: 1.1875
455 },
456 xxlarge: {
457 size: baseFontSize + 4 * fontScale + "px",
458 height: 1.125
459 }
460 }
461 }
462 },
463 collapsible: {
464 minSpeed: 200,
465 baseline: 500
466 },
467 dataTable: {
468 header: {},
469 groupHeader: {
470 border: {
471 side: 'bottom',
472 size: 'xsmall'
473 },
474 fill: 'vertical',
475 pad: {
476 horizontal: 'small',
477 vertical: 'xsmall'
478 },
479 background: {
480 dark: 'dark-2',
481 light: 'light-2'
482 }
483 },
484 icons: {
485 ascending: _grommetIcons.FormDown,
486 contract: _grommetIcons.FormUp,
487 descending: _grommetIcons.FormUp,
488 expand: _grommetIcons.FormDown
489 },
490 resize: {
491 border: {
492 side: 'right',
493 color: 'border'
494 }
495 },
496 primary: {
497 weight: 'bold'
498 }
499 },
500 // drop: {
501 // maxHeight: undefined,
502 // },
503 formField: {
504 border: {
505 color: 'border',
506 position: 'inner',
507 side: 'bottom',
508 error: {
509 color: {
510 dark: 'white',
511 light: 'status-critical'
512 }
513 }
514 },
515 error: {
516 color: {
517 dark: 'status-critical',
518 light: 'status-critical'
519 }
520 },
521 help: {
522 color: {
523 dark: 'dark-5',
524 light: 'dark-5'
525 }
526 },
527 label: {}
528 },
529 grommet: {},
530 heading: {
531 font: {// family: undefined
532 },
533 level: {
534 1: {
535 font: {// family: undefined,
536 },
537 small: _extends({}, fontSizing(4)),
538 medium: _extends({}, fontSizing(8)),
539 large: _extends({}, fontSizing(16)),
540 xlarge: _extends({}, fontSizing(24))
541 },
542 2: {
543 font: {// family: undefined,
544 },
545 small: _extends({}, fontSizing(2)),
546 medium: _extends({}, fontSizing(4)),
547 large: _extends({}, fontSizing(8)),
548 xlarge: _extends({}, fontSizing(12))
549 },
550 3: {
551 font: {// family: undefined,
552 },
553 small: _extends({}, fontSizing(1)),
554 medium: _extends({}, fontSizing(1)),
555 large: _extends({}, fontSizing(4)),
556 xlarge: _extends({}, fontSizing(6))
557 },
558 4: {
559 font: {// family: undefined,
560 },
561 small: _extends({}, fontSizing(0)),
562 medium: _extends({}, fontSizing(0)),
563 large: _extends({}, fontSizing(0)),
564 xlarge: _extends({}, fontSizing(0))
565 }
566 },
567 responsiveBreakpoint: 'small',
568 // when we scale the font size down
569 weight: 600
570 },
571 icon: {
572 colors: colors
573 },
574 iconThemes: {},
575 layer: {
576 background: 'white',
577 border: {
578 radius: '4px'
579 },
580 container: {
581 zIndex: '15'
582 },
583 overlay: {
584 background: 'rgba(0, 0, 0, 0.5)'
585 },
586 responsiveBreakpoint: 'small',
587 // when Layer takes over the full screen
588 zIndex: '10'
589 },
590 menu: {
591 // background: undefined,
592 // extend: undefined,
593 icons: {
594 down: _grommetIcons.FormDown
595 }
596 },
597 paragraph: {
598 small: _extends({}, fontSizing(-1)),
599 medium: _extends({}, fontSizing(0)),
600 large: _extends({}, fontSizing(1)),
601 xlarge: _extends({}, fontSizing(2)),
602 xxlarge: _extends({}, fontSizing(4))
603 },
604 radioButton: {
605 border: {
606 color: {
607 dark: 'rgba(255, 255, 255, 0.5)',
608 light: 'rgba(0, 0, 0, 0.15)'
609 },
610 width: '2px'
611 },
612 check: {
613 radius: '100%' // color: { dark: undefined, light: undefined },
614 // extend: undefined,
615
616 },
617 hover: {
618 border: {
619 color: {
620 dark: 'white',
621 light: 'black'
622 }
623 }
624 },
625 icon: {// size: undefined,
626 // extend: undefined,
627 },
628 icons: {// circle: undefined,
629 },
630 gap: 'small',
631 size: baseSpacing + "px"
632 },
633 rangeInput: {
634 track: {
635 height: '4px',
636 color: (0, _styledComponents.css)(["", ";"], function (props) {
637 return (0, _polished.rgba)((0, _utils.normalizeColor)('border', props.theme), 0.2);
638 })
639 },
640 thumb: {// color: { dark: undefined, light: undefined },
641 }
642 },
643 select: {
644 // background: undefined,
645 container: {// extend: undefined,
646 },
647 control: {// extend: undefined,
648 },
649 icons: {
650 // color: { dark: undefined, light: undefined },
651 down: _grommetIcons.FormDown
652 },
653 // searchInput: undefined,
654 step: 20
655 },
656 tab: {
657 active: {
658 color: 'text' // background: undefined,
659
660 },
661 // background: undefined,
662 border: {
663 side: 'bottom',
664 size: 'small',
665 color: {
666 dark: 'accent-1',
667 light: 'brand'
668 },
669 active: {
670 color: {
671 dark: 'white',
672 light: 'black'
673 }
674 },
675 hover: {
676 color: {
677 dark: 'white',
678 light: 'black'
679 }
680 }
681 },
682 color: 'control',
683 // extend: undefined,
684 hover: {
685 // background: undefined,
686 // extend: undefined,
687 color: {
688 dark: 'white',
689 light: 'black'
690 }
691 },
692 margin: {
693 vertical: 'xxsmall',
694 horizontal: 'small'
695 },
696 pad: {
697 bottom: 'xsmall'
698 }
699 },
700 tabs: {
701 // background: undefined,
702 // extend: undefined,
703 header: {// background: undefined,
704 // extend: undefined,
705 },
706 panel: {// extend: undefined,
707 } // gap: undefined,
708
709 },
710 table: {
711 header: {
712 align: 'start',
713 pad: {
714 horizontal: 'small',
715 vertical: 'xsmall'
716 },
717 border: 'bottom',
718 verticalAlign: 'bottom',
719 fill: 'vertical' // background: undefined,
720 // extend: undefined,
721
722 },
723 body: {
724 align: 'start',
725 pad: {
726 horizontal: 'small',
727 vertical: 'xsmall'
728 } // border: undefined,
729 // extend: undefined,
730
731 },
732 footer: {
733 align: 'start',
734 pad: {
735 horizontal: 'small',
736 vertical: 'xsmall'
737 },
738 border: 'top',
739 verticalAlign: 'top',
740 fill: 'vertical' // extend: undefined,
741
742 }
743 },
744 text: {
745 xsmall: _extends({}, fontSizing(-1.5)),
746 small: _extends({}, fontSizing(-1)),
747 medium: _extends({}, fontSizing(0)),
748 large: _extends({}, fontSizing(1)),
749 xlarge: _extends({}, fontSizing(2)),
750 xxlarge: _extends({}, fontSizing(4))
751 },
752 // textInput: {
753 // extend: undefined,
754 // },
755 video: {
756 captions: {
757 background: 'rgba(0, 0, 0, 0.7)'
758 },
759 // controls: { background: undefined },
760 icons: {
761 closedCaption: _grommetIcons.ClosedCaption,
762 configure: _grommetIcons.Actions,
763 fullScreen: _grommetIcons.Expand,
764 pause: _grommetIcons.Pause,
765 play: _grommetIcons.Play,
766 reduceVolume: _grommetIcons.VolumeLow,
767 volume: _grommetIcons.Volume // color: { dark: undefined, light: undefined },
768
769 } // scrubber: { track: { color: undefined } },
770
771 },
772 worldMap: {
773 color: 'light-3',
774 continent: {
775 active: '8px',
776 base: '6px'
777 },
778 hover: {
779 color: 'light-4'
780 },
781 place: {
782 active: '20px',
783 base: '8px'
784 }
785 }
786 };
787 return (0, _utils.deepFreeze)(result);
788};
789
790exports.generate = generate;
791var base = generate(24);
792exports.base = base;
\No newline at end of file