@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
63 lines (45 loc) • 3.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _styledComponents = require("styled-components");
var _convertHexToRgba = _interopRequireDefault(require("@kiwicom/orbit-design-tokens/lib/convertHexToRgba"));
var _consts = require("../consts");
var _getTypeToken = _interopRequireDefault(require("./getTypeToken"));
var _default, _bordered;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
var opacity = {
default: (_default = {}, _defineProperty(_default, _consts.TYPE_OPTIONS.PRIMARY, 15), _defineProperty(_default, _consts.TYPE_OPTIONS.SECONDARY, 8), _defineProperty(_default, _consts.TYPE_OPTIONS.INFO, 15), _defineProperty(_default, _consts.TYPE_OPTIONS.SUCCESS, 15), _defineProperty(_default, _consts.TYPE_OPTIONS.WARNING, 15), _defineProperty(_default, _consts.TYPE_OPTIONS.CRITICAL, 15), _defineProperty(_default, _consts.TYPE_OPTIONS.FACEBOOK, 15), _defineProperty(_default, _consts.TYPE_OPTIONS.GOOGLE, 8), _defineProperty(_default, _consts.TYPE_OPTIONS.WHITE, 8), _default),
bordered: (_bordered = {}, _defineProperty(_bordered, _consts.TYPE_OPTIONS.PRIMARY, 15), _defineProperty(_bordered, _consts.TYPE_OPTIONS.SECONDARY, 15), _defineProperty(_bordered, _consts.TYPE_OPTIONS.INFO, 15), _defineProperty(_bordered, _consts.TYPE_OPTIONS.SUCCESS, 15), _defineProperty(_bordered, _consts.TYPE_OPTIONS.WARNING, 15), _defineProperty(_bordered, _consts.TYPE_OPTIONS.CRITICAL, 15), _defineProperty(_bordered, _consts.TYPE_OPTIONS.FACEBOOK, 15), _defineProperty(_bordered, _consts.TYPE_OPTIONS.GOOGLE, 15), _defineProperty(_bordered, _consts.TYPE_OPTIONS.WHITE, 15), _bordered)
};
var getButtonBoxShadow = function getButtonBoxShadow(state) {
return function (_ref) {
var disabled = _ref.disabled,
bordered = _ref.bordered,
theme = _ref.theme,
type = _ref.type;
if (disabled) {
return null;
}
if (state === _consts.BUTTON_STATES.DEFAULT && bordered) {
return (0, _styledComponents.css)(["box-shadow:inset 0 0 0 1px ", ";"], (0, _getTypeToken.default)(_consts.TOKENS.borderColorButton));
}
if (state === _consts.BUTTON_STATES.HOVER && bordered) {
return (0, _styledComponents.css)(["box-shadow:inset 0 0 0 1px ", ";"], (0, _getTypeToken.default)(_consts.TOKENS.borderColorButtonHover));
}
if (state === _consts.BUTTON_STATES.ACTIVE) {
if (bordered) {
return (0, _styledComponents.css)(["box-shadow:inset 0 0 0 1px ", ",inset 0 0 6px 3px ", ";"], (0, _getTypeToken.default)(_consts.TOKENS.borderColorButtonActive), (0, _convertHexToRgba.default)(theme.orbit.paletteInkNormal, opacity.bordered[type]));
}
return (0, _styledComponents.css)(["box-shadow:inset 0 0 6px 3px ", ";"], (0, _convertHexToRgba.default)(theme.orbit.paletteInkNormal, opacity.default[type]));
}
if (state === _consts.BUTTON_STATES.FOCUS) {
return (0, _styledComponents.css)(["box-shadow:0 0 1px 1px ", ",0 0 1px 3px ", ";&:active{", ";}"], theme.orbit.colorTextButtonWhiteBordered, (0, _convertHexToRgba.default)(theme.orbit.paletteBlueNormal, 60), bordered ? (0, _styledComponents.css)(["box-shadow:inset 0 0 0 1px ", ",inset 0 0 6px 3px ", ";"], (0, _getTypeToken.default)(_consts.TOKENS.borderColorButtonActive), (0, _convertHexToRgba.default)(theme.orbit.paletteInkNormal, opacity.bordered[type])) : (0, _styledComponents.css)(["box-shadow:inset 0 0 6px 3px ", ";"], (0, _convertHexToRgba.default)(theme.orbit.paletteInkNormal, opacity.default[type])));
}
return null;
};
};
var _default2 = getButtonBoxShadow;
exports.default = _default2;