@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 (55 loc) • 2.23 kB
JavaScript
import { css } from "styled-components";
import convertHexToRgba from "@kiwicom/orbit-design-tokens/lib/convertHexToRgba";
import { TOKENS, TYPE_OPTIONS, BUTTON_STATES } from "../consts";
import getTypeToken from "./getTypeToken";
const opacity = {
default: {
[]: 15,
[]: 8,
[]: 15,
[]: 15,
[]: 15,
[]: 15,
[]: 15,
[]: 8,
[]: 8
},
bordered: {
[]: 15,
[]: 15,
[]: 15,
[]: 15,
[]: 15,
[]: 15,
[]: 15,
[]: 15,
[]: 15
}
};
const getButtonBoxShadow = state => ({
disabled,
bordered,
theme,
type
}) => {
if (disabled) {
return null;
}
if (state === BUTTON_STATES.DEFAULT && bordered) {
return css(["box-shadow:inset 0 0 0 1px ", ";"], getTypeToken(TOKENS.borderColorButton));
}
if (state === BUTTON_STATES.HOVER && bordered) {
return css(["box-shadow:inset 0 0 0 1px ", ";"], getTypeToken(TOKENS.borderColorButtonHover));
}
if (state === BUTTON_STATES.ACTIVE) {
if (bordered) {
return css(["box-shadow:inset 0 0 0 1px ", ",inset 0 0 6px 3px ", ";"], getTypeToken(TOKENS.borderColorButtonActive), convertHexToRgba(theme.orbit.paletteInkNormal, opacity.bordered[type]));
}
return css(["box-shadow:inset 0 0 6px 3px ", ";"], convertHexToRgba(theme.orbit.paletteInkNormal, opacity.default[type]));
}
if (state === BUTTON_STATES.FOCUS) {
return css(["", " &:active{", ";}"], !bordered && css(["box-shadow:0 0 0 3px ", ";"], getTypeToken(TOKENS.borderColorButtonFocus)), bordered ? css(["box-shadow:inset 0 0 0 1px ", ",inset 0 0 6px 3px ", ";"], getTypeToken(TOKENS.borderColorButtonActive), convertHexToRgba(theme.orbit.paletteInkNormal, opacity.bordered[type])) : css(["box-shadow:inset 0 0 6px 3px ", ";"], convertHexToRgba(theme.orbit.paletteInkNormal, opacity.default[type])));
}
return null;
};
export default getButtonBoxShadow;