@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.
84 lines (78 loc) • 2.19 kB
JavaScript
import * as React from "react";
import styled from "styled-components";
import defaultTokens from "../defaultTokens";
import { SIZES, TYPES } from "./consts";
import { StyledCarrierLogo } from "../CarrierLogo";
import getSpacingToken from "../common/getSpacingToken";
import { IconContainer } from "./ListItem";
const getSizeToken = ({
theme,
size
}) => {
const sizeTokens = {
[SIZES.SMALL]: theme.orbit.fontSizeTextSmall,
[SIZES.NORMAL]: theme.orbit.fontSizeTextNormal,
[SIZES.LARGE]: theme.orbit.fontSizeTextLarge
};
return sizeTokens[size];
};
const getTypeToken = ({
theme,
type
}) => {
const typeTokens = {
[TYPES.PRIMARY]: theme.orbit.colorTextPrimary,
[TYPES.SECONDARY]: theme.orbit.colorTextSecondary
};
return typeTokens[type];
};
const getIconHeight = ({
theme,
size
}) => `${Math.floor(parseInt(getSizeToken({
theme,
size
}), 10) * theme.orbit.lineHeightText)}px`;
const StyledList = styled(({
className,
children,
dataTest
}) => React.createElement("ul", {
className: className,
"data-test": dataTest
}, children)).withConfig({
displayName: "List__StyledList",
componentId: "iwilat-0"
})(["display:flex;width:100%;flex-direction:column;font-family:", ";font-size:", ";line-height:", ";color:", ";list-style:none;padding:0;margin:0;margin-bottom:", ";", "{height:", ";", "{height:", ";width:", ";img{height:", ";width:", ";}}svg{height:", ";width:", ";}}"], ({
theme
}) => theme.orbit.fontfamily, getSizeToken, ({
theme
}) => theme.orbit.lineHeightText, getTypeToken, getSpacingToken, IconContainer, getIconHeight, StyledCarrierLogo, ({
theme
}) => theme.orbit.heightIconSmall, ({
theme
}) => theme.orbit.widthIconSmall, ({
theme
}) => theme.orbit.heightIconSmall, ({
theme
}) => theme.orbit.widthIconSmall, ({
theme
}) => theme.orbit.heightIconSmall, ({
theme
}) => theme.orbit.widthIconSmall);
StyledList.defaultProps = {
theme: defaultTokens
};
const List = ({
children,
size = SIZES.NORMAL,
type = TYPES.PRIMARY,
dataTest,
spaceAfter
}) => React.createElement(StyledList, {
type: type,
size: size,
dataTest: dataTest,
spaceAfter: spaceAfter
}, children);
export default List;