UNPKG

@quarkly/atomize

Version:

Library for creating atomic react components

28 lines (27 loc) 766 B
import _extends from "@babel/runtime/helpers/esm/extends"; import _isUndefined from "lodash/fp/isUndefined"; import { getFromTheme, themeGet } from './theme'; export var variants = function variants(key) { return function (props) { return getFromTheme(props, key + "." + props.variant); }; }; export var themed = function themed(key) { return function (props) { return getFromTheme(props, key); }; }; export var mixins = function mixins(props) { var mix = themeGet(props, 'mixins', {}); return Object.keys(mix).reduce(function (acc, mixin) { if (_isUndefined(props[mixin])) { return acc; } return _extends(_extends({}, acc), mix[mixin]); }, {}); }; export default { variants: variants, themed: themed, mixins: mixins };