UNPKG

@smart-react-components/ui

Version:
116 lines (107 loc) 8.89 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div")); const Svg_1 = __importDefault(require("@smart-react-components/core/Element/Svg")); const styled_components_1 = __importDefault(require("styled-components")); const types_1 = require("../../types"); const css_1 = require("../../util/css"); const props_1 = require("../../util/props"); exports.default = (0, styled_components_1.default)(Div_1.default).attrs({ className: 'src-button-addon', getButtonSize: (v, t) => ` font-size: ${t.$.size.button[v].fontSize}; padding: 0 ${(0, css_1.toCSSValue)(t.$.size.input[v].padding.x)(v => v / 2)}; > ${Svg_1.default} { height: ${t.$.size.button[v].iconSize}; width: ${t.$.size.button[v].iconSize}; } `, })(({ theme, addonPosition, hasHover, isDisabled, isOutline, isSeparated, isSoft, palette, shape }) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54; return ` align-items: center; border: solid 1px; border-${types_1.OrderPosition[(0, props_1.getReverseOrderPosition)(addonPosition)].toLowerCase()}: 0; border-bottom-${types_1.OrderPosition[addonPosition].toLowerCase()}-radius: ${theme.$.radius.button[shape]}; border-top-${types_1.OrderPosition[addonPosition].toLowerCase()}-radius: ${theme.$.radius.button[shape]}; box-sizing: border-box; display: inline-flex; fill: currentcolor; flex: 0 0 auto; justify-content: center; transition: 300ms 0s ease-in-out; transition-property: background, border, color; ${!isOutline ? ` ${!isSoft ? ` background: ${(_c = (_b = (_a = theme.$.palette[palette].button) === null || _a === void 0 ? void 0 : _a.addon) === null || _b === void 0 ? void 0 : _b.background) !== null && _c !== void 0 ? _c : theme.$.palette[palette].dynamicer}; border-color: ${(_f = (_e = (_d = theme.$.palette[palette].button) === null || _d === void 0 ? void 0 : _d.addon) === null || _e === void 0 ? void 0 : _e.border) !== null && _f !== void 0 ? _f : theme.$.palette[palette].dynamicer}; color: ${(_j = (_h = (_g = theme.$.palette[palette].button) === null || _g === void 0 ? void 0 : _g.addon) === null || _h === void 0 ? void 0 : _h.font) !== null && _j !== void 0 ? _j : theme.$.palette[palette].font}; ${(isSeparated && hasHover) ? ` &:hover { background: ${(_o = (_m = (_l = (_k = theme.$.palette[palette].button) === null || _k === void 0 ? void 0 : _k.hover) === null || _l === void 0 ? void 0 : _l.addon) === null || _m === void 0 ? void 0 : _m.background) !== null && _o !== void 0 ? _o : theme.$.palette[palette].dynamicest}; border-color: ${(_s = (_r = (_q = (_p = theme.$.palette[palette].button) === null || _p === void 0 ? void 0 : _p.hover) === null || _q === void 0 ? void 0 : _q.addon) === null || _r === void 0 ? void 0 : _r.border) !== null && _s !== void 0 ? _s : theme.$.palette[palette].dynamicest}; } ` : ''} ` : ` background: ${(_w = (_v = (_u = (_t = theme.$.palette[palette].button) === null || _t === void 0 ? void 0 : _t.soft) === null || _u === void 0 ? void 0 : _u.addon) === null || _v === void 0 ? void 0 : _v.background) !== null && _w !== void 0 ? _w : theme.$.palette[palette].softDynamicer}; border-color: ${(_0 = (_z = (_y = (_x = theme.$.palette[palette].button) === null || _x === void 0 ? void 0 : _x.soft) === null || _y === void 0 ? void 0 : _y.addon) === null || _z === void 0 ? void 0 : _z.border) !== null && _0 !== void 0 ? _0 : theme.$.palette[palette].softDynamicer}; color: ${(_4 = (_3 = (_2 = (_1 = theme.$.palette[palette].button) === null || _1 === void 0 ? void 0 : _1.soft) === null || _2 === void 0 ? void 0 : _2.addon) === null || _3 === void 0 ? void 0 : _3.font) !== null && _4 !== void 0 ? _4 : theme.$.palette[palette].softFont}; ${(isSeparated && hasHover) ? ` &:hover { background: ${(_9 = (_8 = (_7 = (_6 = (_5 = theme.$.palette[palette].button) === null || _5 === void 0 ? void 0 : _5.soft) === null || _6 === void 0 ? void 0 : _6.hover) === null || _7 === void 0 ? void 0 : _7.addon) === null || _8 === void 0 ? void 0 : _8.background) !== null && _9 !== void 0 ? _9 : theme.$.palette[palette].softDynamicest}; border-color: ${(_14 = (_13 = (_12 = (_11 = (_10 = theme.$.palette[palette].button) === null || _10 === void 0 ? void 0 : _10.soft) === null || _11 === void 0 ? void 0 : _11.hover) === null || _12 === void 0 ? void 0 : _12.addon) === null || _13 === void 0 ? void 0 : _13.border) !== null && _14 !== void 0 ? _14 : theme.$.palette[palette].softDynamicest}; } ` : ''} `} ` : ` ${!isSoft ? ` border-color: ${(_18 = (_17 = (_16 = (_15 = theme.$.palette[palette].button) === null || _15 === void 0 ? void 0 : _15.outline) === null || _16 === void 0 ? void 0 : _16.addon) === null || _17 === void 0 ? void 0 : _17.border) !== null && _18 !== void 0 ? _18 : theme.$.palette[palette].dynamicer}; color: ${(_22 = (_21 = (_20 = (_19 = theme.$.palette[palette].button) === null || _19 === void 0 ? void 0 : _19.outline) === null || _20 === void 0 ? void 0 : _20.addon) === null || _21 === void 0 ? void 0 : _21.font) !== null && _22 !== void 0 ? _22 : theme.$.palette[palette].dynamicer}; ${(isSeparated && hasHover) ? ` &:hover { background: ${(_27 = (_26 = (_25 = (_24 = (_23 = theme.$.palette[palette].button) === null || _23 === void 0 ? void 0 : _23.outline) === null || _24 === void 0 ? void 0 : _24.hover) === null || _25 === void 0 ? void 0 : _25.addon) === null || _26 === void 0 ? void 0 : _26.background) !== null && _27 !== void 0 ? _27 : theme.$.palette[palette].dynamicer}; color: ${(_32 = (_31 = (_30 = (_29 = (_28 = theme.$.palette[palette].button) === null || _28 === void 0 ? void 0 : _28.outline) === null || _29 === void 0 ? void 0 : _29.hover) === null || _30 === void 0 ? void 0 : _30.addon) === null || _31 === void 0 ? void 0 : _31.font) !== null && _32 !== void 0 ? _32 : theme.$.palette[palette].font}; } ` : ''} ` : ` border-color: ${(_37 = (_36 = (_35 = (_34 = (_33 = theme.$.palette[palette].button) === null || _33 === void 0 ? void 0 : _33.soft) === null || _34 === void 0 ? void 0 : _34.outline) === null || _35 === void 0 ? void 0 : _35.addon) === null || _36 === void 0 ? void 0 : _36.border) !== null && _37 !== void 0 ? _37 : theme.$.palette[palette].softDynamicer}; color: ${(_42 = (_41 = (_40 = (_39 = (_38 = theme.$.palette[palette].button) === null || _38 === void 0 ? void 0 : _38.soft) === null || _39 === void 0 ? void 0 : _39.outline) === null || _40 === void 0 ? void 0 : _40.addon) === null || _41 === void 0 ? void 0 : _41.font) !== null && _42 !== void 0 ? _42 : theme.$.palette[palette].softDynamicer}; ${(isSeparated && hasHover) ? ` &:hover { background: ${(_48 = (_47 = (_46 = (_45 = (_44 = (_43 = theme.$.palette[palette].button) === null || _43 === void 0 ? void 0 : _43.soft) === null || _44 === void 0 ? void 0 : _44.outline) === null || _45 === void 0 ? void 0 : _45.hover) === null || _46 === void 0 ? void 0 : _46.addon) === null || _47 === void 0 ? void 0 : _47.background) !== null && _48 !== void 0 ? _48 : theme.$.palette[palette].softDynamicer}; color: ${(_54 = (_53 = (_52 = (_51 = (_50 = (_49 = theme.$.palette[palette].button) === null || _49 === void 0 ? void 0 : _49.soft) === null || _50 === void 0 ? void 0 : _50.outline) === null || _51 === void 0 ? void 0 : _51.hover) === null || _52 === void 0 ? void 0 : _52.addon) === null || _53 === void 0 ? void 0 : _53.font) !== null && _54 !== void 0 ? _54 : theme.$.palette[palette].softFont}; } ` : ''} `} `} ${isSeparated ? ` cursor: ${!isDisabled ? theme.$.cursor.button : 'default'}; user-select: none; ` : ''} ${isDisabled ? ` opacity: ${theme.$.opacity.buttonDisabled}; pointer-events: none; ` : ''} `; });