UNPKG

@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.

51 lines (49 loc) 1.69 kB
import * as React from "react"; import styled from "styled-components"; import defaultTheme from "../../defaultTheme"; import CircleSmall from "../../icons/CircleSmall"; import { rtlSpacing } from "../../utils/rtl"; export const Item = styled.li.withConfig({ displayName: "ListItem__Item", componentId: "sc-1vswvev-0" })(["font-family:", ";display:flex;flex-direction:row;align-items:flex-start;margin-bottom:", ";&:last-child,&:last-of-type{margin:0;}"], ({ theme }) => theme.orbit.fontFamily, ({ theme }) => theme.orbit.spaceXXSmall); Item.defaultProps = { theme: defaultTheme }; export const IconContainer = styled.div.withConfig({ displayName: "ListItem__IconContainer", componentId: "sc-1vswvev-1" })(["display:flex;align-items:center;margin:", ";flex:0 0 auto;"], ({ theme }) => rtlSpacing(`0 ${theme.orbit.spaceXSmall} 0 0`)); IconContainer.defaultProps = { theme: defaultTheme }; export const StyledLabel = styled.div.withConfig({ displayName: "ListItem__StyledLabel", componentId: "sc-1vswvev-2" })(["font-family:", ";color:", ";"], ({ theme }) => theme.orbit.fontFamily, ({ theme }) => theme.orbit.colorTextSecondary); const StyledSpan = styled.span.withConfig({ displayName: "ListItem__StyledSpan", componentId: "sc-1vswvev-3" })(["width:100%;"]); StyledLabel.defaultProps = { theme: defaultTheme }; const ListItem = ({ label, children, icon = React.createElement(CircleSmall, null), dataTest }) => React.createElement(Item, { "data-test": dataTest }, React.createElement(IconContainer, null, icon), React.createElement(StyledSpan, null, label && React.createElement(StyledLabel, null, label), children)); export default ListItem;