import { Block, useTheme } from 'gloss' import { flow } from 'lodash' import * as React from 'react' import { preventDefault } from './helpers/preventDefault' import { Image } from './Image' import { Text } from './text/Text' import { Stack } from './View/Stack' const shortName = name => { const names = name.split(' ') const lastInitial = names[1] ? ` ${names[1][0]}.` : '' return `${names[0]}${lastInitial}` } const Person = props => ( {shortName(props.person.name)} {props.after} ) export function PersonRow({ people, onClickPerson = null }) { const activeTheme = useTheme() const total = (people || []).length if (total === 0) { return null } const half = total / 2 return ( {(people || []).slice(0, 3).map((person, i) => ( ))} {people.length <= 2 && (people || []).map((person, i) => ( onClickPerson(person), )} after={i < people.length - 1 ? ',' : ''} /> ))} {people.length > 2 && ( <> onClickPerson(people[0]), )} person={people[0]} />{' '} +{people.length - 1} )} ) }