UNPKG

6.46 kBJavaScriptView Raw
1"use strict";
2
3require("core-js/modules/es.symbol.js");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.convert = void 0;
9
10require("core-js/modules/es.object.assign.js");
11
12require("core-js/modules/es.object.keys.js");
13
14var _polished = require("polished");
15
16var _base = require("./base");
17
18var _animation = require("./animation");
19
20var _syntax = require("./modules/syntax");
21
22var _utils = require("./utils");
23
24var _create = require("./create");
25
26function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
28function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
29
30var lightSyntaxColors = {
31 green1: '#008000',
32 red1: '#A31515',
33 red2: '#9a050f',
34 red3: '#800000',
35 red4: '#ff0000',
36 gray1: '#393A34',
37 cyan1: '#36acaa',
38 cyan2: '#2B91AF',
39 blue1: '#0000ff',
40 blue2: '#00009f'
41};
42var darkSyntaxColors = {
43 green1: '#7C7C7C',
44 red1: '#92C379',
45 red2: '#9a050f',
46 red3: '#A8FF60',
47 red4: '#96CBFE',
48 gray1: '#EDEDED',
49 cyan1: '#C6C5FE',
50 cyan2: '#FFFFB6',
51 blue1: '#B474DD',
52 blue2: '#00009f'
53};
54
55var createColors = function createColors(vars) {
56 return {
57 // Changeable colors
58 primary: vars.colorPrimary,
59 secondary: vars.colorSecondary,
60 tertiary: _base.color.tertiary,
61 ancillary: _base.color.ancillary,
62 // Complimentary
63 orange: _base.color.orange,
64 gold: _base.color.gold,
65 green: _base.color.green,
66 seafoam: _base.color.seafoam,
67 purple: _base.color.purple,
68 ultraviolet: _base.color.ultraviolet,
69 // Monochrome
70 lightest: _base.color.lightest,
71 lighter: _base.color.lighter,
72 light: _base.color.light,
73 mediumlight: _base.color.mediumlight,
74 medium: _base.color.medium,
75 mediumdark: _base.color.mediumdark,
76 dark: _base.color.dark,
77 darker: _base.color.darker,
78 darkest: _base.color.darkest,
79 // For borders
80 border: _base.color.border,
81 // Status
82 positive: _base.color.positive,
83 negative: _base.color.negative,
84 warning: _base.color.warning,
85 critical: _base.color.critical,
86 defaultText: vars.textColor || _base.color.darkest,
87 inverseText: vars.textInverseColor || _base.color.lightest
88 };
89};
90
91var convert = function convert() {
92 var inherit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _create.themes[(0, _utils.getPreferredColorScheme)()];
93
94 var base = inherit.base,
95 colorPrimary = inherit.colorPrimary,
96 colorSecondary = inherit.colorSecondary,
97 appBg = inherit.appBg,
98 appContentBg = inherit.appContentBg,
99 appBorderColor = inherit.appBorderColor,
100 appBorderRadius = inherit.appBorderRadius,
101 fontBase = inherit.fontBase,
102 fontCode = inherit.fontCode,
103 textColor = inherit.textColor,
104 textInverseColor = inherit.textInverseColor,
105 barTextColor = inherit.barTextColor,
106 barSelectedColor = inherit.barSelectedColor,
107 barBg = inherit.barBg,
108 inputBg = inherit.inputBg,
109 inputBorder = inherit.inputBorder,
110 inputTextColor = inherit.inputTextColor,
111 inputBorderRadius = inherit.inputBorderRadius,
112 brandTitle = inherit.brandTitle,
113 brandUrl = inherit.brandUrl,
114 brandImage = inherit.brandImage,
115 gridCellSize = inherit.gridCellSize,
116 rest = _objectWithoutProperties(inherit, ["base", "colorPrimary", "colorSecondary", "appBg", "appContentBg", "appBorderColor", "appBorderRadius", "fontBase", "fontCode", "textColor", "textInverseColor", "barTextColor", "barSelectedColor", "barBg", "inputBg", "inputBorder", "inputTextColor", "inputBorderRadius", "brandTitle", "brandUrl", "brandImage", "gridCellSize"]);
117
118 return Object.assign({}, rest || {}, {
119 base: base,
120 color: createColors(inherit),
121 background: {
122 app: appBg,
123 bar: barBg,
124 content: appContentBg,
125 gridCellSize: gridCellSize || _base.background.gridCellSize,
126 hoverable: base === 'light' ? 'rgba(0,0,0,.05)' : 'rgba(250,250,252,.1)' || _base.background.hoverable,
127 positive: _base.background.positive,
128 negative: _base.background.negative,
129 warning: _base.background.warning,
130 critical: _base.background.critical
131 },
132 typography: {
133 fonts: {
134 base: fontBase,
135 mono: fontCode
136 },
137 weight: _base.typography.weight,
138 size: _base.typography.size
139 },
140 animation: _animation.animation,
141 easing: _animation.easing,
142 input: {
143 border: inputBorder,
144 background: inputBg,
145 color: inputTextColor,
146 borderRadius: inputBorderRadius
147 },
148 // UI
149 layoutMargin: 10,
150 appBorderColor: appBorderColor,
151 appBorderRadius: appBorderRadius,
152 // Toolbar default/active colors
153 barTextColor: barTextColor,
154 barSelectedColor: barSelectedColor || colorSecondary,
155 barBg: barBg,
156 // Brand logo/text
157 brand: {
158 title: brandTitle,
159 url: brandUrl,
160 image: brandImage || (brandTitle ? null : undefined)
161 },
162 code: (0, _syntax.create)({
163 colors: base === 'light' ? lightSyntaxColors : darkSyntaxColors,
164 mono: fontCode
165 }),
166 // Addon actions theme
167 // API example https://github.com/xyc/react-inspector/blob/master/src/styles/themes/chromeLight.js
168 addonActionsTheme: Object.assign({}, base === 'light' ? _syntax.chromeLight : _syntax.chromeDark, {
169 BASE_FONT_FAMILY: fontCode,
170 BASE_FONT_SIZE: _base.typography.size.s2 - 1,
171 BASE_LINE_HEIGHT: '18px',
172 BASE_BACKGROUND_COLOR: 'transparent',
173 BASE_COLOR: textColor,
174 ARROW_COLOR: (0, _polished.opacify)(0.2, appBorderColor),
175 ARROW_MARGIN_RIGHT: 4,
176 ARROW_FONT_SIZE: 8,
177 TREENODE_FONT_FAMILY: fontCode,
178 TREENODE_FONT_SIZE: _base.typography.size.s2 - 1,
179 TREENODE_LINE_HEIGHT: '18px',
180 TREENODE_PADDING_LEFT: 12
181 })
182 });
183};
184
185exports.convert = convert;
\No newline at end of file