@splunk/themes 0.12.0 → 0.13.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/CHANGELOG.md +5 -0
- package/mixins/index.js +59 -0
- package/mixins/tests/typography.unit.js +236 -0
- package/mixins/tests/utilityMixins.unit.js +138 -0
- package/mixins/typography.js +270 -0
- package/{mixins.js → mixins/utilityMixins.js} +2 -2
- package/package.json +2 -1
- package/types/mixins/index.d.ts +18 -0
- package/types/mixins/tests/typography.unit.d.ts +1 -0
- package/types/{tests/mixins.unit.d.ts → mixins/tests/utilityMixins.unit.d.ts} +0 -0
- package/types/mixins/typography.d.ts +83 -0
- package/types/{mixins.d.ts → mixins/utilityMixins.d.ts} +1 -1
package/CHANGELOG.md
CHANGED
package/mixins/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
var _exportNames = {
|
|
9
|
+
typography: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "typography", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function get() {
|
|
14
|
+
return _typography["default"];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
exports["default"] = void 0;
|
|
18
|
+
|
|
19
|
+
var _utilityMixins = _interopRequireWildcard(require("./utilityMixins"));
|
|
20
|
+
|
|
21
|
+
Object.keys(_utilityMixins).forEach(function (key) {
|
|
22
|
+
if (key === "default" || key === "__esModule") return;
|
|
23
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
24
|
+
Object.defineProperty(exports, key, {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _utilityMixins[key];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
var _typography = _interopRequireWildcard(require("./typography"));
|
|
33
|
+
|
|
34
|
+
Object.keys(_typography).forEach(function (key) {
|
|
35
|
+
if (key === "default" || key === "__esModule") return;
|
|
36
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
37
|
+
Object.defineProperty(exports, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function get() {
|
|
40
|
+
return _typography[key];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
46
|
+
|
|
47
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
48
|
+
|
|
49
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
50
|
+
|
|
51
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
52
|
+
|
|
53
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
54
|
+
|
|
55
|
+
var _default = _objectSpread(_objectSpread({}, _utilityMixins["default"]), {}, {
|
|
56
|
+
typography: _typography["default"]
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
9
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
10
|
+
|
|
11
|
+
var _SplunkThemeProvider = _interopRequireDefault(require("@splunk/themes/SplunkThemeProvider"));
|
|
12
|
+
|
|
13
|
+
require("jest-styled-components");
|
|
14
|
+
|
|
15
|
+
var _typography = _interopRequireWildcard(require("../typography"));
|
|
16
|
+
|
|
17
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
18
|
+
|
|
19
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
|
+
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
22
|
+
|
|
23
|
+
function _templateObject6() {
|
|
24
|
+
var data = _taggedTemplateLiteral(["\n ", "\n ", ";\n ", ";\n "]);
|
|
25
|
+
|
|
26
|
+
_templateObject6 = function _templateObject6() {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _templateObject5() {
|
|
34
|
+
var data = _taggedTemplateLiteral(["\n ", "\n "]);
|
|
35
|
+
|
|
36
|
+
_templateObject5 = function _templateObject5() {
|
|
37
|
+
return data;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function _templateObject4() {
|
|
44
|
+
var data = _taggedTemplateLiteral(["\n ", "\n "]);
|
|
45
|
+
|
|
46
|
+
_templateObject4 = function _templateObject4() {
|
|
47
|
+
return data;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function _templateObject3() {
|
|
54
|
+
var data = _taggedTemplateLiteral(["\n ", "\n "]);
|
|
55
|
+
|
|
56
|
+
_templateObject3 = function _templateObject3() {
|
|
57
|
+
return data;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return data;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function _templateObject2() {
|
|
64
|
+
var data = _taggedTemplateLiteral(["\n ", "\n "]);
|
|
65
|
+
|
|
66
|
+
_templateObject2 = function _templateObject2() {
|
|
67
|
+
return data;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function _templateObject() {
|
|
74
|
+
var data = _taggedTemplateLiteral(["\n ", "\n "]);
|
|
75
|
+
|
|
76
|
+
_templateObject = function _templateObject() {
|
|
77
|
+
return data;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
84
|
+
|
|
85
|
+
describe('typography', function () {
|
|
86
|
+
function ThemeSettingsList(_ref) {
|
|
87
|
+
var family = _ref.family,
|
|
88
|
+
Component = _ref.component;
|
|
89
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], {
|
|
90
|
+
family: family,
|
|
91
|
+
colorScheme: "dark",
|
|
92
|
+
density: "comfortable"
|
|
93
|
+
}, /*#__PURE__*/_react["default"].createElement(Component, null, family, " dark comfortable")), /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], {
|
|
94
|
+
family: family,
|
|
95
|
+
colorScheme: "light",
|
|
96
|
+
density: "comfortable"
|
|
97
|
+
}, /*#__PURE__*/_react["default"].createElement(Component, null, family, " light comfortable")), /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], {
|
|
98
|
+
family: family,
|
|
99
|
+
colorScheme: "dark",
|
|
100
|
+
density: "compact"
|
|
101
|
+
}, /*#__PURE__*/_react["default"].createElement(Component, null, family, " dark compact")), /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], {
|
|
102
|
+
family: family,
|
|
103
|
+
colorScheme: "light",
|
|
104
|
+
density: "compact"
|
|
105
|
+
}, /*#__PURE__*/_react["default"].createElement(Component, null, family, " light compact")));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
describe('uses default values based on theme family', function () {
|
|
109
|
+
var Component = _styledComponents["default"].p(_templateObject(), (0, _typography["default"])());
|
|
110
|
+
|
|
111
|
+
it('prisma', function () {
|
|
112
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(ThemeSettingsList, {
|
|
113
|
+
family: "prisma",
|
|
114
|
+
component: Component
|
|
115
|
+
})),
|
|
116
|
+
container = _render.container;
|
|
117
|
+
|
|
118
|
+
expect(container).toMatchInlineSnapshot("\n .c0 {\n color: #b5b5b5;\n font-family: 'Splunk Platform Sans','Splunk Data Sans',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 14px;\n font-weight: normal;\n line-height: 20px;\n }\n\n .c1 {\n color: #4d4d4d;\n font-family: 'Splunk Platform Sans','Splunk Data Sans',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 14px;\n font-weight: normal;\n line-height: 20px;\n }\n\n <div>\n <p\n class=\"c0\"\n >\n prisma\n dark comfortable\n </p>\n <p\n class=\"c1\"\n >\n prisma\n light comfortable\n </p>\n <p\n class=\"c0\"\n >\n prisma\n dark compact\n </p>\n <p\n class=\"c1\"\n >\n prisma\n light compact\n </p>\n </div>\n ");
|
|
119
|
+
});
|
|
120
|
+
it('enterprise', function () {
|
|
121
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(ThemeSettingsList, {
|
|
122
|
+
family: "enterprise",
|
|
123
|
+
component: Component
|
|
124
|
+
})),
|
|
125
|
+
container = _render2.container;
|
|
126
|
+
|
|
127
|
+
expect(container).toMatchInlineSnapshot("\n .c0 {\n color: #ffffff;\n font-family: 'Splunk Platform Sans','Proxima Nova',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 14px;\n font-weight: normal;\n line-height: 20px;\n }\n\n .c1 {\n color: #3c444d;\n font-family: 'Splunk Platform Sans','Proxima Nova',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 14px;\n font-weight: normal;\n line-height: 20px;\n }\n\n .c2 {\n color: #ffffff;\n font-family: 'Splunk Platform Sans','Proxima Nova',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 12px;\n font-weight: normal;\n line-height: 20px;\n }\n\n .c3 {\n color: #3c444d;\n font-family: 'Splunk Platform Sans','Proxima Nova',Roboto,Droid,'Helvetica Neue',Helvetica,Arial,sans-serif;\n font-size: 12px;\n font-weight: normal;\n line-height: 20px;\n }\n\n <div>\n <p\n class=\"c0\"\n >\n enterprise\n dark comfortable\n </p>\n <p\n class=\"c1\"\n >\n enterprise\n light comfortable\n </p>\n <p\n class=\"c2\"\n >\n enterprise\n dark compact\n </p>\n <p\n class=\"c3\"\n >\n enterprise\n light compact\n </p>\n </div>\n ");
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
describe('support variants in each theme', function () {
|
|
131
|
+
function testTypographyVariantForThemeFamily(variant, family) {
|
|
132
|
+
it("".concat(variant), function () {
|
|
133
|
+
var Component = _styledComponents["default"].p(_templateObject2(), (0, _typography["default"])(variant));
|
|
134
|
+
|
|
135
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(ThemeSettingsList, {
|
|
136
|
+
family: family,
|
|
137
|
+
component: Component
|
|
138
|
+
})),
|
|
139
|
+
container = _render3.container;
|
|
140
|
+
|
|
141
|
+
expect(container).toMatchSnapshot();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
describe('prisma', function () {
|
|
146
|
+
_typography.typographyVariants.forEach(function (variant) {
|
|
147
|
+
return testTypographyVariantForThemeFamily(variant, 'prisma');
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
describe('enterprise', function () {
|
|
151
|
+
_typography.typographyVariants.forEach(function (variant) {
|
|
152
|
+
return testTypographyVariantForThemeFamily(variant, 'enterprise');
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
it('merges parameters with variant values', function () {
|
|
157
|
+
var Component = _styledComponents["default"].p(_templateObject3(), (0, _typography["default"])('body', {
|
|
158
|
+
color: 'muted',
|
|
159
|
+
family: 'monospace'
|
|
160
|
+
}));
|
|
161
|
+
|
|
162
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Component, null)),
|
|
163
|
+
container = _render4.container;
|
|
164
|
+
|
|
165
|
+
expect(container.firstChild).toMatchInlineSnapshot("\n .c0 {\n margin: 0;\n padding: 0;\n color: #909090;\n font-family: 'Splunk Platform Mono','Roboto Mono',Consolas,'Droid Sans Mono',Monaco,'Courier New',Courier,monospace;\n font-size: 14px;\n font-weight: normal;\n line-height: 20px;\n }\n\n <p\n class=\"c0\"\n />\n ");
|
|
166
|
+
});
|
|
167
|
+
it('allows a variants values to be overridden', function () {
|
|
168
|
+
var Component = _styledComponents["default"].p(_templateObject4(), (0, _typography["default"])('body', {
|
|
169
|
+
color: 'muted',
|
|
170
|
+
family: 'monospace',
|
|
171
|
+
lineHeight: 64,
|
|
172
|
+
size: 56,
|
|
173
|
+
weight: 'extraBold',
|
|
174
|
+
withReset: false
|
|
175
|
+
}));
|
|
176
|
+
|
|
177
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Component, null)),
|
|
178
|
+
container = _render5.container;
|
|
179
|
+
|
|
180
|
+
expect(container.firstChild).toMatchInlineSnapshot("\n .c0 {\n color: #909090;\n font-family: 'Splunk Platform Mono','Roboto Mono',Consolas,'Droid Sans Mono',Monaco,'Courier New',Courier,monospace;\n font-size: 56px;\n font-weight: extraBold;\n line-height: 64px;\n }\n\n <p\n class=\"c0\"\n />\n ");
|
|
181
|
+
});
|
|
182
|
+
it('allows default values to be overridden with params', function () {
|
|
183
|
+
var Component = _styledComponents["default"].p(_templateObject5(), (0, _typography["default"])({
|
|
184
|
+
color: 'muted',
|
|
185
|
+
family: 'monospace',
|
|
186
|
+
lineHeight: 64,
|
|
187
|
+
size: 56,
|
|
188
|
+
weight: 'extraBold',
|
|
189
|
+
withReset: false
|
|
190
|
+
}));
|
|
191
|
+
|
|
192
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Component, null)),
|
|
193
|
+
container = _render6.container;
|
|
194
|
+
|
|
195
|
+
expect(container.firstChild).toMatchInlineSnapshot("\n .c0 {\n color: #909090;\n font-family: 'Splunk Platform Mono','Roboto Mono',Consolas,'Droid Sans Mono',Monaco,'Courier New',Courier,monospace;\n font-size: 56px;\n font-weight: extraBold;\n line-height: 64px;\n }\n\n <p\n class=\"c0\"\n />\n ");
|
|
196
|
+
});
|
|
197
|
+
it.skip('passes TS verification', function () {
|
|
198
|
+
(0, _typography["default"])();
|
|
199
|
+
(0, _typography["default"])({});
|
|
200
|
+
(0, _typography["default"])('title1');
|
|
201
|
+
(0, _typography["default"])('title1', {
|
|
202
|
+
color: 'disabled'
|
|
203
|
+
});
|
|
204
|
+
(0, _typography["default"])({
|
|
205
|
+
family: 'monospace'
|
|
206
|
+
}); // @ts-expect-error
|
|
207
|
+
|
|
208
|
+
(0, _typography["default"])('foo'); // @ts-expect-error
|
|
209
|
+
|
|
210
|
+
(0, _typography["default"])({
|
|
211
|
+
family: 'monospace'
|
|
212
|
+
}, true); // @ts-expect-error
|
|
213
|
+
|
|
214
|
+
(0, _typography["default"])({
|
|
215
|
+
family: 'monospace'
|
|
216
|
+
}, {
|
|
217
|
+
color: 'disabled'
|
|
218
|
+
}); // @ts-expect-error
|
|
219
|
+
|
|
220
|
+
(0, _typography["default"])(''); // @ts-expect-error
|
|
221
|
+
|
|
222
|
+
(0, _typography["default"])({
|
|
223
|
+
variant: 'title1'
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
describe('passes TS verification', function () {
|
|
228
|
+
it.skip('allows mixins in styled-components css', function () {
|
|
229
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-expressions */
|
|
230
|
+
(0, _styledComponents.css)(_templateObject6(), (0, _typography["default"])('title1'), (0, _typography["default"])('title1', {
|
|
231
|
+
color: 'disabled'
|
|
232
|
+
}), (0, _typography["default"])({
|
|
233
|
+
family: 'monospace'
|
|
234
|
+
}));
|
|
235
|
+
});
|
|
236
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _chai = require("chai");
|
|
4
|
+
|
|
5
|
+
var _sinon = require("sinon");
|
|
6
|
+
|
|
7
|
+
var _styledComponents = require("styled-components");
|
|
8
|
+
|
|
9
|
+
var _variables = _interopRequireDefault(require("../../variables"));
|
|
10
|
+
|
|
11
|
+
var _utilityMixins = require("../utilityMixins");
|
|
12
|
+
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
+
|
|
15
|
+
function _templateObject() {
|
|
16
|
+
var data = _taggedTemplateLiteral(["\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", "\n ", "\n ", ";\n "]);
|
|
17
|
+
|
|
18
|
+
_templateObject = function _templateObject() {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
26
|
+
|
|
27
|
+
describe('colorWithAlpha', function () {
|
|
28
|
+
var defaultProps = {};
|
|
29
|
+
var enterpriseLightProps = {
|
|
30
|
+
theme: {
|
|
31
|
+
splunkThemeV1: {
|
|
32
|
+
family: 'enterprise',
|
|
33
|
+
colorScheme: 'light'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
it('sets alpha on a string value', function () {
|
|
38
|
+
var result = (0, _utilityMixins.colorWithAlpha)('#70f', 0.5)(defaultProps);
|
|
39
|
+
|
|
40
|
+
_chai.assert.strictEqual(result, 'rgba(119, 0, 255, 0.5)');
|
|
41
|
+
|
|
42
|
+
var result2 = (0, _utilityMixins.colorWithAlpha)('#1700f3', 0.5)(defaultProps);
|
|
43
|
+
|
|
44
|
+
_chai.assert.strictEqual(result2, 'rgba(23, 0, 243, 0.5)');
|
|
45
|
+
|
|
46
|
+
var result3 = (0, _utilityMixins.colorWithAlpha)('rgb(51, 162, 212)', 0.2)(defaultProps);
|
|
47
|
+
|
|
48
|
+
_chai.assert.strictEqual(result3, 'rgba(51, 162, 212, 0.2)');
|
|
49
|
+
|
|
50
|
+
var result4 = (0, _utilityMixins.colorWithAlpha)('rgba(255, 255, 255, 0.7)', 0.2)(defaultProps);
|
|
51
|
+
|
|
52
|
+
_chai.assert.strictEqual(result4, 'rgba(255, 255, 255, 0.2)');
|
|
53
|
+
});
|
|
54
|
+
it('sets alpha on a variable', function () {
|
|
55
|
+
var result = (0, _utilityMixins.colorWithAlpha)(_variables["default"].white, 0.5)(defaultProps);
|
|
56
|
+
|
|
57
|
+
_chai.assert.strictEqual(result, 'rgba(255, 255, 255, 0.5)');
|
|
58
|
+
|
|
59
|
+
var result2 = (0, _utilityMixins.colorWithAlpha)(_variables["default"].contentColorDefault, 0.2)(defaultProps);
|
|
60
|
+
|
|
61
|
+
_chai.assert.strictEqual(result2, 'rgba(181, 181, 181, 0.2)');
|
|
62
|
+
|
|
63
|
+
var result3 = (0, _utilityMixins.colorWithAlpha)(_variables["default"].contentColorDefault, 0.3)(enterpriseLightProps);
|
|
64
|
+
|
|
65
|
+
_chai.assert.strictEqual(result3, 'rgba(60, 68, 77, 0.3)');
|
|
66
|
+
|
|
67
|
+
var result4 = (0, _utilityMixins.colorWithAlpha)(_variables["default"].brandColor, 0.3)(enterpriseLightProps);
|
|
68
|
+
|
|
69
|
+
_chai.assert.strictEqual(result4, 'rgba(92, 192, 92, 0.3)');
|
|
70
|
+
});
|
|
71
|
+
it('defaults to black for undefined variable', function () {
|
|
72
|
+
var consoleStub = (0, _sinon.stub)(console, 'warn');
|
|
73
|
+
var result4 = (0, _utilityMixins.colorWithAlpha)(_variables["default"].brandColor, 0.3)(defaultProps);
|
|
74
|
+
|
|
75
|
+
_chai.assert.strictEqual(result4, 'rgba(0, 0, 0, 0.3)');
|
|
76
|
+
|
|
77
|
+
_chai.assert.isTrue(consoleStub.calledOnce, "The colorWithAlpha's console warning was called");
|
|
78
|
+
|
|
79
|
+
_chai.assert.strictEqual(consoleStub.args[0][0], "The variable 'brandColor' does not exist in the theme 'prisma dark comfortable'.");
|
|
80
|
+
|
|
81
|
+
consoleStub.restore();
|
|
82
|
+
});
|
|
83
|
+
it('warns developers of invalid alpha prop at runtime', function () {
|
|
84
|
+
var consoleStub = (0, _sinon.stub)(console, 'warn');
|
|
85
|
+
(0, _utilityMixins.colorWithAlpha)(_variables["default"].white, 1.1)(defaultProps);
|
|
86
|
+
(0, _utilityMixins.colorWithAlpha)(_variables["default"].white, -0.1)(defaultProps);
|
|
87
|
+
|
|
88
|
+
_chai.assert.isTrue(consoleStub.calledTwice, "The colorWithAlpha's console warning was called twice");
|
|
89
|
+
|
|
90
|
+
_chai.assert.strictEqual(consoleStub.args[0][0], 'The alpha value "1.1" is not within acceptable 0-1 range.');
|
|
91
|
+
|
|
92
|
+
_chai.assert.strictEqual(consoleStub.args[1][0], 'The alpha value "-0.1" is not within acceptable 0-1 range.');
|
|
93
|
+
|
|
94
|
+
consoleStub.restore();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe('overlayColors', function () {
|
|
98
|
+
var defaultProps = {};
|
|
99
|
+
it('overlays two string values', function () {
|
|
100
|
+
var result = (0, _utilityMixins.overlayColors)('#f0f', 'rgba(255, 255, 128, 0.5)')(defaultProps);
|
|
101
|
+
|
|
102
|
+
_chai.assert.strictEqual(result, 'rgb(255, 128, 192)');
|
|
103
|
+
});
|
|
104
|
+
it('overlays a solid color', function () {
|
|
105
|
+
var result = (0, _utilityMixins.overlayColors)('#f39', _variables["default"].black)(defaultProps);
|
|
106
|
+
|
|
107
|
+
_chai.assert.strictEqual(result, 'rgb(0, 0, 0)');
|
|
108
|
+
});
|
|
109
|
+
it('uses default theme variables', function () {
|
|
110
|
+
var result = (0, _utilityMixins.overlayColors)(_variables["default"].interactiveColorPrimary, _variables["default"].interactiveColorOverlayHover)(defaultProps);
|
|
111
|
+
|
|
112
|
+
_chai.assert.strictEqual(result, 'rgb(67, 152, 255)');
|
|
113
|
+
});
|
|
114
|
+
var enterpriseLightProps = {
|
|
115
|
+
theme: {
|
|
116
|
+
splunkThemeV1: {
|
|
117
|
+
family: 'enterprise',
|
|
118
|
+
colorScheme: 'light'
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
it('uses Enterprise variables', function () {
|
|
123
|
+
var result = (0, _utilityMixins.overlayColors)(_variables["default"].brandColor, 'rgba(255, 255, 255, 0.5)')(enterpriseLightProps);
|
|
124
|
+
|
|
125
|
+
_chai.assert.strictEqual(result, 'rgb(174, 224, 174)');
|
|
126
|
+
});
|
|
127
|
+
it('defaults to black for undefined colors', function () {
|
|
128
|
+
var result = (0, _utilityMixins.overlayColors)(_variables["default"].brandColor, 'rgba(255, 255, 255, 0.5)')(defaultProps);
|
|
129
|
+
|
|
130
|
+
_chai.assert.strictEqual(result, 'rgb(128, 128, 128)');
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe('passes TS verification', function () {
|
|
134
|
+
it.skip('allows mixins in styled-components css', function () {
|
|
135
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-expressions */
|
|
136
|
+
(0, _styledComponents.css)(_templateObject(), _utilityMixins.clearfix, (0, _utilityMixins.colorWithAlpha)('foo', 0.5), _utilityMixins.ellipsis, (0, _utilityMixins.overlayColors)('foo', 'bar'), _utilityMixins.printHide, _utilityMixins.printNoBackground, _utilityMixins.printWidth100Percent, _utilityMixins.printWrapAll, (0, _utilityMixins.reset)(), (0, _utilityMixins.reset)('block'), _utilityMixins.screenReaderContent);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.typographyVariants = exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = require("styled-components");
|
|
9
|
+
|
|
10
|
+
var _lodash = require("lodash");
|
|
11
|
+
|
|
12
|
+
var _variables = _interopRequireDefault(require("../variables"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
16
|
+
function _templateObject2() {
|
|
17
|
+
var data = _taggedTemplateLiteral(["\n margin: 0;\n padding: 0;\n "]);
|
|
18
|
+
|
|
19
|
+
_templateObject2 = function _templateObject2() {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function _templateObject() {
|
|
27
|
+
var data = _taggedTemplateLiteral(["\n ", "\n\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n "]);
|
|
28
|
+
|
|
29
|
+
_templateObject = function _templateObject() {
|
|
30
|
+
return data;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
37
|
+
|
|
38
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
39
|
+
|
|
40
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
41
|
+
|
|
42
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
43
|
+
|
|
44
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
45
|
+
|
|
46
|
+
var typographyVariants = ['body', 'title1', 'title2', 'title3', 'title4', 'title5', 'title6', 'title7', 'largeBody', 'smallBody', 'footnote', 'monoBody', 'monoSmallBody'];
|
|
47
|
+
exports.typographyVariants = typographyVariants;
|
|
48
|
+
|
|
49
|
+
function isTypographyVariant(s) {
|
|
50
|
+
if (typeof s !== 'string') {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return typographyVariants.includes(s);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getStylesForVariant(variant) {
|
|
58
|
+
var color = _variables["default"].contentColorDefault;
|
|
59
|
+
var family = _variables["default"].fontFamily;
|
|
60
|
+
var lineHeight = _variables["default"].lineHeight; // eslint-disable-line prefer-destructuring
|
|
61
|
+
|
|
62
|
+
var size = _variables["default"].fontSize;
|
|
63
|
+
var weight = 'normal';
|
|
64
|
+
|
|
65
|
+
switch (variant) {
|
|
66
|
+
case 'title1':
|
|
67
|
+
color = _variables["default"].contentColorActive;
|
|
68
|
+
lineHeight = '40px';
|
|
69
|
+
size = '36px';
|
|
70
|
+
weight = _variables["default"].fontWeightBold;
|
|
71
|
+
break;
|
|
72
|
+
|
|
73
|
+
case 'title2':
|
|
74
|
+
color = _variables["default"].contentColorActive;
|
|
75
|
+
lineHeight = '48px';
|
|
76
|
+
size = _variables["default"].fontSizeXXLarge;
|
|
77
|
+
weight = _variables["default"].fontWeightBold;
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
case 'title3':
|
|
81
|
+
color = _variables["default"].contentColorActive;
|
|
82
|
+
lineHeight = '24px';
|
|
83
|
+
size = '20px';
|
|
84
|
+
weight = _variables["default"].fontWeightBold;
|
|
85
|
+
break;
|
|
86
|
+
|
|
87
|
+
case 'title4':
|
|
88
|
+
color = _variables["default"].contentColorActive;
|
|
89
|
+
lineHeight = '22px';
|
|
90
|
+
size = _variables["default"].fontSizeLarge;
|
|
91
|
+
weight = _variables["default"].fontWeightBold;
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
case 'title5':
|
|
95
|
+
color = _variables["default"].contentColorActive;
|
|
96
|
+
lineHeight = _variables["default"].lineHeight;
|
|
97
|
+
size = _variables["default"].fontSize;
|
|
98
|
+
weight = _variables["default"].fontWeightBold;
|
|
99
|
+
break;
|
|
100
|
+
|
|
101
|
+
case 'title6':
|
|
102
|
+
color = _variables["default"].contentColorActive;
|
|
103
|
+
lineHeight = _variables["default"].lineHeight;
|
|
104
|
+
size = _variables["default"].fontSize;
|
|
105
|
+
weight = _variables["default"].fontWeightSemiBold;
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
case 'title7':
|
|
109
|
+
color = _variables["default"].contentColorActive;
|
|
110
|
+
lineHeight = '16px';
|
|
111
|
+
size = _variables["default"].fontSizeSmall;
|
|
112
|
+
weight = _variables["default"].fontWeightSemiBold;
|
|
113
|
+
break;
|
|
114
|
+
|
|
115
|
+
case 'largeBody':
|
|
116
|
+
color = _variables["default"].contentColorDefault;
|
|
117
|
+
lineHeight = '24px';
|
|
118
|
+
size = _variables["default"].fontSizeLarge;
|
|
119
|
+
weight = 'normal';
|
|
120
|
+
break;
|
|
121
|
+
|
|
122
|
+
case 'smallBody':
|
|
123
|
+
color = _variables["default"].contentColorDefault;
|
|
124
|
+
lineHeight = '16px';
|
|
125
|
+
size = _variables["default"].fontSizeSmall;
|
|
126
|
+
weight = 'normal';
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case 'footnote':
|
|
130
|
+
color = _variables["default"].contentColorDefault;
|
|
131
|
+
lineHeight = '13px';
|
|
132
|
+
size = '10px';
|
|
133
|
+
weight = 'normal';
|
|
134
|
+
break;
|
|
135
|
+
|
|
136
|
+
case 'monoBody':
|
|
137
|
+
family = _variables["default"].monoFontFamily;
|
|
138
|
+
break;
|
|
139
|
+
|
|
140
|
+
case 'monoSmallBody':
|
|
141
|
+
color = _variables["default"].contentColorDefault;
|
|
142
|
+
family = _variables["default"].monoFontFamily;
|
|
143
|
+
lineHeight = '16px';
|
|
144
|
+
size = _variables["default"].fontSizeSmall;
|
|
145
|
+
weight = 'normal';
|
|
146
|
+
break;
|
|
147
|
+
|
|
148
|
+
case 'body':
|
|
149
|
+
// Theme defaults set the 'body' style
|
|
150
|
+
break;
|
|
151
|
+
|
|
152
|
+
default:
|
|
153
|
+
{
|
|
154
|
+
if (false) {
|
|
155
|
+
// eslint-disable-line no-console
|
|
156
|
+
console.log("Unknown typography variant, ".concat(variant, ". Using default values for theme."));
|
|
157
|
+
} // Make sure this "never" happens https://www.typescriptlang.org/docs/handbook/2/narrowing.html#exhaustiveness-checking
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
var exhaustiveCheck = variant;
|
|
161
|
+
return exhaustiveCheck;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
color: color,
|
|
167
|
+
family: family,
|
|
168
|
+
size: size,
|
|
169
|
+
weight: weight,
|
|
170
|
+
lineHeight: lineHeight,
|
|
171
|
+
withReset: true
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
var colorPropToVariableMap = {
|
|
176
|
+
active: _variables["default"].contentColorActive,
|
|
177
|
+
"default": _variables["default"].contentColorDefault,
|
|
178
|
+
disabled: _variables["default"].contentColorDisabled,
|
|
179
|
+
inverted: _variables["default"].contentColorInverted,
|
|
180
|
+
muted: _variables["default"].contentColorMuted
|
|
181
|
+
};
|
|
182
|
+
var familyPropToVariableMap = {
|
|
183
|
+
sansSerif: _variables["default"].sansFontFamily,
|
|
184
|
+
monospace: _variables["default"].monoFontFamily
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* A mixin for styling text content using predefined typography variants
|
|
188
|
+
* and/or customizing font-settings with system parameters: e.g. size, weight, font-family.
|
|
189
|
+
*
|
|
190
|
+
* The default variant is `body` and will be used if no variant or settings
|
|
191
|
+
* are given: i.e. `typography()` or `typography({})`.
|
|
192
|
+
* Variants have the reset applied by default.
|
|
193
|
+
*
|
|
194
|
+
* ##### Example
|
|
195
|
+
* ```js
|
|
196
|
+
* import styled from 'styled-components';
|
|
197
|
+
* import { typography } from '@splunk/themes/mixins';
|
|
198
|
+
*
|
|
199
|
+
* const MyTitle = styled.h1`
|
|
200
|
+
* ${typography('title1')};
|
|
201
|
+
* `;
|
|
202
|
+
*
|
|
203
|
+
* const MyCustomizedTitle = styled.h1`
|
|
204
|
+
* ${typography('title1', { color: 'inverted' })};
|
|
205
|
+
* `;
|
|
206
|
+
*
|
|
207
|
+
* const CustomTitle = styled.h1`
|
|
208
|
+
* ${typography({size: 56, weight: 'light', color: 'inverted' })};
|
|
209
|
+
* `;
|
|
210
|
+
* ```
|
|
211
|
+
* @name typography
|
|
212
|
+
* @kind function
|
|
213
|
+
* @param {string} [variant] Use a predefined typography variant:
|
|
214
|
+
* `'body'`,
|
|
215
|
+
* `'title1'`,
|
|
216
|
+
* `'title2'`,
|
|
217
|
+
* `'title3'`,
|
|
218
|
+
* `'title4'`,
|
|
219
|
+
* `'title5'`,
|
|
220
|
+
* `'subtitle'`,
|
|
221
|
+
* `'smallSubtitle'`,
|
|
222
|
+
* `'largeBody'`,
|
|
223
|
+
* `'smallBody'`,
|
|
224
|
+
* `'footnote'`,
|
|
225
|
+
* `'monoBody'`, or
|
|
226
|
+
* `'monoSmallBody'`,
|
|
227
|
+
* @param {object} [typographyParams] Customize the font settings or element using system values for: `family`, `size`, `lineHeight`, `color`, and `weight`.
|
|
228
|
+
* Default margin and padding can be removed with `withReset`.
|
|
229
|
+
* @public
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
function typography(variantOrParams, additionalParams) {
|
|
233
|
+
var variant = isTypographyVariant(variantOrParams) ? variantOrParams : undefined;
|
|
234
|
+
var params;
|
|
235
|
+
|
|
236
|
+
if (variant && additionalParams !== undefined) {
|
|
237
|
+
params = additionalParams;
|
|
238
|
+
} else if (variant === undefined && _typeof(variantOrParams) === 'object' && additionalParams === undefined) {
|
|
239
|
+
params = variantOrParams;
|
|
240
|
+
} else {
|
|
241
|
+
params = {};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
var variantParams = variant ? getStylesForVariant(variant) : {}; // Transform params to be ready for css literal below: i.e size="24" -> "24px"
|
|
245
|
+
|
|
246
|
+
var transformedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
247
|
+
size: params.size ? "".concat(params.size, "px") : undefined,
|
|
248
|
+
lineHeight: params.lineHeight ? "".concat(params.lineHeight, "px") : undefined,
|
|
249
|
+
color: params.color ? colorPropToVariableMap[params.color] : undefined,
|
|
250
|
+
family: params.family ? familyPropToVariableMap[params.family] : undefined
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
var defaultTypographyParams = {
|
|
254
|
+
color: _variables["default"].contentColorDefault,
|
|
255
|
+
family: _variables["default"].fontFamily,
|
|
256
|
+
size: _variables["default"].fontSize,
|
|
257
|
+
weight: 'normal',
|
|
258
|
+
lineHeight: _variables["default"].lineHeight,
|
|
259
|
+
withReset: false
|
|
260
|
+
};
|
|
261
|
+
var finalParams = (0, _lodash.merge)(defaultTypographyParams, variantParams, transformedParams);
|
|
262
|
+
return function () {
|
|
263
|
+
return (0, _styledComponents.css)(_templateObject(), function () {
|
|
264
|
+
return finalParams.withReset && (0, _styledComponents.css)(_templateObject2());
|
|
265
|
+
}, finalParams.color, finalParams.family, finalParams.size, finalParams.weight, finalParams.lineHeight);
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
var _default = typography;
|
|
270
|
+
exports["default"] = _default;
|
|
@@ -20,9 +20,9 @@ var _styledComponents = require("styled-components");
|
|
|
20
20
|
|
|
21
21
|
var _colorBlend = require("color-blend");
|
|
22
22
|
|
|
23
|
-
var _variables = _interopRequireDefault(require("
|
|
23
|
+
var _variables = _interopRequireDefault(require("../variables"));
|
|
24
24
|
|
|
25
|
-
var _pick = _interopRequireDefault(require("
|
|
25
|
+
var _pick = _interopRequireDefault(require("../pick"));
|
|
26
26
|
|
|
27
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
28
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splunk/themes",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Theme variables and mixins for the Splunk design language",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"babel": "babel src -d . --ignore src/babel-plugin-base64-png,src/tests --ignore \"**/docs\" --extensions .js,.ts,.tsx",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"eslint-plugin-react": "^7.20.3",
|
|
88
88
|
"eslint-plugin-react-hooks": "^4.0.5",
|
|
89
89
|
"jest": "^25.1.0",
|
|
90
|
+
"jest-styled-components": "^7.0.8",
|
|
90
91
|
"react": "^16.12.0",
|
|
91
92
|
"styled-components": "5.1.1",
|
|
92
93
|
"typescript": "^4.0.5",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import typography from './typography';
|
|
2
|
+
export * from './utilityMixins';
|
|
3
|
+
export { default as typography } from './typography';
|
|
4
|
+
export * from './typography';
|
|
5
|
+
declare const _default: {
|
|
6
|
+
typography: typeof typography;
|
|
7
|
+
reset: <T extends import("../types").AnyTheme, A extends import("../types").ThemedProps<import("../types").AnyTheme>>(display?: string) => import("../types").Interpolation<T, A>;
|
|
8
|
+
clearfix: typeof import("./utilityMixins").clearfix;
|
|
9
|
+
ellipsis: typeof import("./utilityMixins").ellipsis;
|
|
10
|
+
printWidth100Percent: typeof import("./utilityMixins").printWidth100Percent;
|
|
11
|
+
printHide: typeof import("./utilityMixins").printHide;
|
|
12
|
+
printNoBackground: typeof import("./utilityMixins").printNoBackground;
|
|
13
|
+
printWrapAll: typeof import("./utilityMixins").printWrapAll;
|
|
14
|
+
screenReaderContent: typeof import("./utilityMixins").screenReaderContent;
|
|
15
|
+
colorWithAlpha: typeof import("./utilityMixins").colorWithAlpha;
|
|
16
|
+
overlayColors: typeof import("./utilityMixins").overlayColors;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'jest-styled-components';
|
|
File without changes
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AnyTheme, Interpolation, ThemedProps } from '../types';
|
|
2
|
+
declare const typographyVariants: readonly ["body", "title1", "title2", "title3", "title4", "title5", "title6", "title7", "largeBody", "smallBody", "footnote", "monoBody", "monoSmallBody"];
|
|
3
|
+
declare type TypographyVariant = typeof typographyVariants[number];
|
|
4
|
+
interface TypographyParams {
|
|
5
|
+
/**
|
|
6
|
+
* Set the font-family to sans-serif or monospace based on current theme.
|
|
7
|
+
*/
|
|
8
|
+
family?: 'sansSerif' | 'monospace';
|
|
9
|
+
/**
|
|
10
|
+
* Set the size to a system-standard size.
|
|
11
|
+
*/
|
|
12
|
+
size?: 56 | 36 | 32 | 24 | 20 | 18 | 16 | 14 | 12 | 10;
|
|
13
|
+
/**
|
|
14
|
+
* Set the line-height to a system-standard size.
|
|
15
|
+
*/
|
|
16
|
+
lineHeight?: 64 | 40 | 32 | 28 | 24 | 22 | 20 | 16 | 13;
|
|
17
|
+
/**
|
|
18
|
+
* Set the color to a system-standard color: e.g. `active` for `@splunk/themes/variables.contentColorActive`.
|
|
19
|
+
*/
|
|
20
|
+
color?: 'active' | 'default' | 'disabled' | 'inverted' | 'muted';
|
|
21
|
+
/**
|
|
22
|
+
* Set the font-weight to a system-standard value.
|
|
23
|
+
*
|
|
24
|
+
* Number or equivalent string can be used.
|
|
25
|
+
* See: [font-weight | MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
|
|
26
|
+
*/
|
|
27
|
+
weight?: 300 | 400 | 500 | 600 | 700 | 800 | 900 | 'light' | 'normal' | 'semiBold' | 'bold' | 'extraBold' | 'heavy';
|
|
28
|
+
/**
|
|
29
|
+
* Apply a reset to the element's margin and padding. This defaults to true if using a `variant`.
|
|
30
|
+
*/
|
|
31
|
+
withReset?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A mixin for styling text content using predefined typography variants
|
|
35
|
+
* and/or customizing font-settings with system parameters: e.g. size, weight, font-family.
|
|
36
|
+
*
|
|
37
|
+
* The default variant is `body` and will be used if no variant or settings
|
|
38
|
+
* are given: i.e. `typography()` or `typography({})`.
|
|
39
|
+
* Variants have the reset applied by default.
|
|
40
|
+
*
|
|
41
|
+
* ##### Example
|
|
42
|
+
* ```js
|
|
43
|
+
* import styled from 'styled-components';
|
|
44
|
+
* import { typography } from '@splunk/themes/mixins';
|
|
45
|
+
*
|
|
46
|
+
* const MyTitle = styled.h1`
|
|
47
|
+
* ${typography('title1')};
|
|
48
|
+
* `;
|
|
49
|
+
*
|
|
50
|
+
* const MyCustomizedTitle = styled.h1`
|
|
51
|
+
* ${typography('title1', { color: 'inverted' })};
|
|
52
|
+
* `;
|
|
53
|
+
*
|
|
54
|
+
* const CustomTitle = styled.h1`
|
|
55
|
+
* ${typography({size: 56, weight: 'light', color: 'inverted' })};
|
|
56
|
+
* `;
|
|
57
|
+
* ```
|
|
58
|
+
* @name typography
|
|
59
|
+
* @kind function
|
|
60
|
+
* @param {string} [variant] Use a predefined typography variant:
|
|
61
|
+
* `'body'`,
|
|
62
|
+
* `'title1'`,
|
|
63
|
+
* `'title2'`,
|
|
64
|
+
* `'title3'`,
|
|
65
|
+
* `'title4'`,
|
|
66
|
+
* `'title5'`,
|
|
67
|
+
* `'subtitle'`,
|
|
68
|
+
* `'smallSubtitle'`,
|
|
69
|
+
* `'largeBody'`,
|
|
70
|
+
* `'smallBody'`,
|
|
71
|
+
* `'footnote'`,
|
|
72
|
+
* `'monoBody'`, or
|
|
73
|
+
* `'monoSmallBody'`,
|
|
74
|
+
* @param {object} [typographyParams] Customize the font settings or element using system values for: `family`, `size`, `lineHeight`, `color`, and `weight`.
|
|
75
|
+
* Default margin and padding can be removed with `withReset`.
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
declare function typography<T extends AnyTheme, A extends ThemedProps>(): Interpolation<T, A>;
|
|
79
|
+
declare function typography<T extends AnyTheme, A extends ThemedProps>(variant: TypographyVariant): Interpolation<T, A>;
|
|
80
|
+
declare function typography<T extends AnyTheme, A extends ThemedProps>({ family, size, lineHeight, color, weight, withReset, }: TypographyParams): Interpolation<T, A>;
|
|
81
|
+
declare function typography<T extends AnyTheme, A extends ThemedProps>(variant: TypographyVariant, additionalParams: TypographyParams): Interpolation<T, A>;
|
|
82
|
+
export default typography;
|
|
83
|
+
export { typographyVariants, TypographyVariant, TypographyParams };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSObject } from 'styled-components';
|
|
2
|
-
import { AnyTheme, Interpolation, ThemedProps, OptionalThemedProps } from '
|
|
2
|
+
import { AnyTheme, Interpolation, ThemedProps, OptionalThemedProps } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* @file
|
|
5
5
|
* A collection of style-related helper functions. All of them return a single object containing
|