UNPKG

6.58 kBJavaScriptView Raw
1import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
5function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
7import { createStyling } from 'react-base16-styling';
8import solarized from './themes/solarized';
9
10var colorMap = function colorMap(theme) {
11 return {
12 BACKGROUND_COLOR: theme.base00,
13 TEXT_COLOR: theme.base07,
14 STRING_COLOR: theme.base0B,
15 DATE_COLOR: theme.base0B,
16 NUMBER_COLOR: theme.base09,
17 BOOLEAN_COLOR: theme.base09,
18 NULL_COLOR: theme.base08,
19 UNDEFINED_COLOR: theme.base08,
20 FUNCTION_COLOR: theme.base08,
21 SYMBOL_COLOR: theme.base08,
22 LABEL_COLOR: theme.base0D,
23 ARROW_COLOR: theme.base0D,
24 ITEM_STRING_COLOR: theme.base0B,
25 ITEM_STRING_EXPANDED_COLOR: theme.base03
26 };
27};
28
29var valueColorMap = function valueColorMap(colors) {
30 return {
31 String: colors.STRING_COLOR,
32 Date: colors.DATE_COLOR,
33 Number: colors.NUMBER_COLOR,
34 Boolean: colors.BOOLEAN_COLOR,
35 Null: colors.NULL_COLOR,
36 Undefined: colors.UNDEFINED_COLOR,
37 Function: colors.FUNCTION_COLOR,
38 Symbol: colors.SYMBOL_COLOR
39 };
40};
41
42var getDefaultThemeStyling = function getDefaultThemeStyling(theme) {
43 var colors = colorMap(theme);
44 return {
45 tree: {
46 border: 0,
47 padding: 0,
48 marginTop: '0.5em',
49 marginBottom: '0.5em',
50 marginLeft: '0.125em',
51 marginRight: 0,
52 listStyle: 'none',
53 MozUserSelect: 'none',
54 WebkitUserSelect: 'none',
55 backgroundColor: colors.BACKGROUND_COLOR
56 },
57 value: function value(_ref, nodeType, keyPath) {
58 var style = _ref.style;
59 return {
60 style: _objectSpread(_objectSpread({}, style), {}, {
61 paddingTop: '0.25em',
62 paddingRight: 0,
63 marginLeft: '0.875em',
64 WebkitUserSelect: 'text',
65 MozUserSelect: 'text',
66 wordWrap: 'break-word',
67 paddingLeft: keyPath.length > 1 ? '2.125em' : '1.25em',
68 textIndent: '-0.5em',
69 wordBreak: 'break-all'
70 })
71 };
72 },
73 label: {
74 display: 'inline-block',
75 color: colors.LABEL_COLOR
76 },
77 valueLabel: {
78 margin: '0 0.5em 0 0'
79 },
80 valueText: function valueText(_ref2, nodeType) {
81 var style = _ref2.style;
82 return {
83 style: _objectSpread(_objectSpread({}, style), {}, {
84 color: valueColorMap(colors)[nodeType]
85 })
86 };
87 },
88 itemRange: function itemRange(styling, expanded) {
89 return {
90 style: {
91 paddingTop: expanded ? 0 : '0.25em',
92 cursor: 'pointer',
93 color: colors.LABEL_COLOR
94 }
95 };
96 },
97 arrow: function arrow(_ref3, nodeType, expanded) {
98 var style = _ref3.style;
99 return {
100 style: _objectSpread(_objectSpread({}, style), {}, {
101 marginLeft: 0,
102 transition: '150ms',
103 WebkitTransition: '150ms',
104 MozTransition: '150ms',
105 WebkitTransform: expanded ? 'rotateZ(90deg)' : 'rotateZ(0deg)',
106 MozTransform: expanded ? 'rotateZ(90deg)' : 'rotateZ(0deg)',
107 transform: expanded ? 'rotateZ(90deg)' : 'rotateZ(0deg)',
108 transformOrigin: '45% 50%',
109 WebkitTransformOrigin: '45% 50%',
110 MozTransformOrigin: '45% 50%',
111 position: 'relative',
112 lineHeight: '1.1em',
113 fontSize: '0.75em'
114 })
115 };
116 },
117 arrowContainer: function arrowContainer(_ref4, arrowStyle) {
118 var style = _ref4.style;
119 return {
120 style: _objectSpread(_objectSpread({}, style), {}, {
121 display: 'inline-block',
122 paddingRight: '0.5em',
123 paddingLeft: arrowStyle === 'double' ? '1em' : 0,
124 cursor: 'pointer'
125 })
126 };
127 },
128 arrowSign: {
129 color: colors.ARROW_COLOR
130 },
131 arrowSignInner: {
132 position: 'absolute',
133 top: 0,
134 left: '-0.4em'
135 },
136 nestedNode: function nestedNode(_ref5, keyPath, nodeType, expanded, expandable) {
137 var style = _ref5.style;
138 return {
139 style: _objectSpread(_objectSpread({}, style), {}, {
140 position: 'relative',
141 paddingTop: '0.25em',
142 marginLeft: keyPath.length > 1 ? '0.875em' : 0,
143 paddingLeft: !expandable ? '1.125em' : 0
144 })
145 };
146 },
147 rootNode: {
148 padding: 0,
149 margin: 0
150 },
151 nestedNodeLabel: function nestedNodeLabel(_ref6, keyPath, nodeType, expanded, expandable) {
152 var style = _ref6.style;
153 return {
154 style: _objectSpread(_objectSpread({}, style), {}, {
155 margin: 0,
156 padding: 0,
157 WebkitUserSelect: expandable ? 'inherit' : 'text',
158 MozUserSelect: expandable ? 'inherit' : 'text',
159 cursor: expandable ? 'pointer' : 'default'
160 })
161 };
162 },
163 nestedNodeItemString: function nestedNodeItemString(_ref7, keyPath, nodeType, expanded) {
164 var style = _ref7.style;
165 return {
166 style: _objectSpread(_objectSpread({}, style), {}, {
167 paddingLeft: '0.5em',
168 cursor: 'default',
169 color: expanded ? colors.ITEM_STRING_EXPANDED_COLOR : colors.ITEM_STRING_COLOR
170 })
171 };
172 },
173 nestedNodeItemType: {
174 marginLeft: '0.3em',
175 marginRight: '0.3em'
176 },
177 nestedNodeChildren: function nestedNodeChildren(_ref8, nodeType, expanded) {
178 var style = _ref8.style;
179 return {
180 style: _objectSpread(_objectSpread({}, style), {}, {
181 padding: 0,
182 margin: 0,
183 listStyle: 'none',
184 display: expanded ? 'block' : 'none'
185 })
186 };
187 },
188 rootNodeChildren: {
189 padding: 0,
190 margin: 0,
191 listStyle: 'none'
192 }
193 };
194};
195
196var createStylingFromTheme = createStyling(getDefaultThemeStyling, {
197 defaultBase16: solarized
198});
199export default createStylingFromTheme;
\No newline at end of file