UNPKG

@kalamazoo/theme

Version:
39 lines 1.41 kB
"use strict"; /* eslint-disable prefer-rest-params */ Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var getTheme_1 = tslib_1.__importDefault(require("./getTheme")); // Unpack custom variants, and get correct value for the current theme function themedVariants(variantProp, variants) { return function (props) { var theme = getTheme_1.default(props); if (props && props[variantProp] && variants) { var modes = variants[props[variantProp]]; if (modes && modes[theme.mode]) { var value = modes[theme.mode]; if (value) return value; // TS believes value can be undefined } } return ''; }; } function themed(modesOrVariant, variantModes) { if (typeof modesOrVariant === 'string') { return themedVariants(modesOrVariant, variantModes); } var modes = modesOrVariant; return function (props) { // Get theme from the user's props var theme = getTheme_1.default(props); // User isn't required to provide both light and dark values if (theme.mode in modes) { var value = modes[theme.mode]; // TS believes value can be undefined if (value) return value; } return ''; }; } exports.default = themed; //# sourceMappingURL=themed.js.map