UNPKG

1.41 kBJavaScriptView Raw
1"use strict";
2/* eslint-disable prefer-rest-params */
3Object.defineProperty(exports, "__esModule", { value: true });
4var tslib_1 = require("tslib");
5var getTheme_1 = tslib_1.__importDefault(require("./getTheme"));
6// Unpack custom variants, and get correct value for the current theme
7function themedVariants(variantProp, variants) {
8 return function (props) {
9 var theme = getTheme_1.default(props);
10 if (props && props[variantProp] && variants) {
11 var modes = variants[props[variantProp]];
12 if (modes && modes[theme.mode]) {
13 var value = modes[theme.mode];
14 if (value)
15 return value; // TS believes value can be undefined
16 }
17 }
18 return '';
19 };
20}
21function themed(modesOrVariant, variantModes) {
22 if (typeof modesOrVariant === 'string') {
23 return themedVariants(modesOrVariant, variantModes);
24 }
25 var modes = modesOrVariant;
26 return function (props) {
27 // Get theme from the user's props
28 var theme = getTheme_1.default(props);
29 // User isn't required to provide both light and dark values
30 if (theme.mode in modes) {
31 var value = modes[theme.mode]; // TS believes value can be undefined
32 if (value)
33 return value;
34 }
35 return '';
36 };
37}
38exports.default = themed;
39//# sourceMappingURL=themed.js.map
\No newline at end of file