@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.
69 lines (63 loc) • 1.88 kB
JavaScript
import * as React from "react";
import styled, { css } from "styled-components";
import defaultTheme from "../defaultTheme";
import { SIZES, TYPES } from "./consts";
import getSpacingToken from "../common/getSpacingToken";
import { getLineHeightToken } from "./ListItem";
import ListContext from "./ListContext";
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 StyledList = styled(({
className,
children,
dataTest
}) => /*#__PURE__*/React.createElement("ul", {
className: className,
"data-test": dataTest
}, children)).withConfig({
displayName: "List__StyledList",
componentId: "sc-rq6gj8-0"
})(["", ""], ({
theme
}) => css(["display:flex;width:100%;flex-direction:column;font-family:", ";font-size:", ";line-height:", ";color:", ";list-style:none;padding:0;margin:0;margin-bottom:", ";"], theme.orbit.fontFamily, getSizeToken, getLineHeightToken, getTypeToken, getSpacingToken)); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledList.defaultProps = {
theme: defaultTheme
};
const List = ({
children,
size = SIZES.NORMAL,
type = TYPES.PRIMARY,
dataTest,
spaceAfter
}) => /*#__PURE__*/React.createElement(StyledList, {
type: type,
size: size,
dataTest: dataTest,
spaceAfter: spaceAfter
}, /*#__PURE__*/React.createElement(ListContext.Provider, {
value: {
size,
type
}
}, children));
export default List;
export { default as ListItem } from "./ListItem";