import React from 'react'; import styled from '../'; const List = styled.dl({ marginTop: 0, }); const Heading = styled.dt(({ theme }) => ({ color: theme.colors.darkGray, font: theme.fonts.desktop.small, })); const Value = styled.dd({ margin: 0, '&:not(:last-child)': { marginBottom: 16, }, }); export interface ValueListProps { items: InfoItem[]; } export interface InfoItem { heading: string; value: any; } export const ValueList: React.FC = props => { const items = props.items .map(item => (Array.isArray(item.value) ? { ...item, value: item.value.filter(x => x) } : item)) .filter(item => item.heading && item.value && item.value.length > 0); return ( {items.map((item, i) => [ {item.heading}, {Array.isArray(item.value) ? item.value.map((val, j) =>
{val}
) : item.value}
, ])}
); };