@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.
76 lines (74 loc) • 2.9 kB
JavaScript
;
exports.__esModule = true;
exports.getLinkStyle = void 0;
var _styledComponents = require("styled-components");
var _consts = require("../consts");
const getColor = ({
$type
}) => ({
theme
}) => {
const tokens = {
[_consts.TYPE_OPTIONS.PRIMARY]: theme.orbit.colorTextLinkPrimary,
[_consts.TYPE_OPTIONS.SECONDARY]: theme.orbit.colorTextLinkSecondary,
[_consts.TYPE_OPTIONS.SUCCESS]: theme.orbit.paletteGreenDark,
[_consts.TYPE_OPTIONS.INFO]: theme.orbit.paletteBlueDark,
[_consts.TYPE_OPTIONS.WARNING]: theme.orbit.paletteOrangeDark,
[_consts.TYPE_OPTIONS.CRITICAL]: theme.orbit.paletteRedDark,
[_consts.TYPE_OPTIONS.WHITE]: theme.orbit.paletteWhite
};
if (!$type) return null;
return tokens[$type];
};
const getHoverColor = ({
$type
}) => ({
theme
}) => {
const tokens = {
[_consts.TYPE_OPTIONS.PRIMARY]: theme.orbit.paletteProductDarkHover,
[_consts.TYPE_OPTIONS.SECONDARY]: theme.orbit.paletteProductDarkHover,
[_consts.TYPE_OPTIONS.SUCCESS]: theme.orbit.paletteGreenDarkHover,
[_consts.TYPE_OPTIONS.INFO]: theme.orbit.paletteBlueDarkHover,
[_consts.TYPE_OPTIONS.WARNING]: theme.orbit.paletteOrangeDarkHover,
[_consts.TYPE_OPTIONS.CRITICAL]: theme.orbit.paletteRedDarkHover,
[_consts.TYPE_OPTIONS.WHITE]: theme.orbit.paletteProductLight
};
if (!$type) return null;
return tokens[$type];
};
const getActiveColor = ({
$type
}) => ({
theme
}) => {
const tokens = {
[_consts.TYPE_OPTIONS.PRIMARY]: theme.orbit.paletteProductDarkActive,
[_consts.TYPE_OPTIONS.SECONDARY]: theme.orbit.paletteProductDarkActive,
[_consts.TYPE_OPTIONS.SUCCESS]: theme.orbit.paletteGreenDarker,
[_consts.TYPE_OPTIONS.INFO]: theme.orbit.paletteBlueDarker,
[_consts.TYPE_OPTIONS.WARNING]: theme.orbit.paletteOrangeDarker,
[_consts.TYPE_OPTIONS.CRITICAL]: theme.orbit.paletteRedDarker,
[_consts.TYPE_OPTIONS.WHITE]: theme.orbit.paletteProductLight
};
if (!$type) return null;
return tokens[$type];
};
const resolveUnderline = ({
$type,
theme,
$noUnderline
}) => {
if ($noUnderline) return "none";
return $type === _consts.TYPE_OPTIONS.SECONDARY ? theme.orbit.textDecorationTextLinkSecondary : theme.orbit.textDecorationTextLinkPrimary;
};
/**
* @deprecated kept until StyledText is removed
*/
const getLinkStyle = ({
theme,
$type
}) => {
return (0, _styledComponents.css)(["&,&:link,&:visited{color:", " ", ";text-decoration:", " ", ";font-weight:", " ", ";}&:hover{outline:none;text-decoration:none;color:", ";}&:active{outline:none;text-decoration:none;color:", ";}"], getColor, $type === _consts.TYPE_OPTIONS.SECONDARY && `!important`, resolveUnderline, $type === _consts.TYPE_OPTIONS.SECONDARY && `!important`, theme.orbit.fontWeightLinks, $type === _consts.TYPE_OPTIONS.SECONDARY && `!important`, getHoverColor, getActiveColor);
};
exports.getLinkStyle = getLinkStyle;