/* @flow */ /*eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */ import React from 'react' import classnames from 'classnames' import { spacing } from '../utilities/spacing.js' import { Avatar, Badge } from '../' import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props' type MultipleUsersStackedProps = { className?: String, id?: String, data?: object, aria?: object, users: Array, } const MultipleUsersStacked = (props: MultipleUsersStackedProps) => { const { className, id, aria = {}, data = {}, users } = props const moreThanTwo = users.length > 2 const onlyOne = users.length == 1 const displayCount = () => { return moreThanTwo ? 1 : users.length } const ariaProps = buildAriaProps(aria) const dataProps = buildDataProps(data) const css = buildCss({ 'pb_multiple_users_stacked_kit': true, single: onlyOne, }) const firstUser = () => { return users.slice(0, 1).map((userObject, index) => { return ( ) }) } const secondUser = () => { if (moreThanTwo === false) { return users.slice(1, 2).map((userObject, index) => { return ( ) }) } } const plusUsers = () => { if (moreThanTwo === true) { return ( ) } } return (
{firstUser()} {secondUser()} {plusUsers()}
) } export default MultipleUsersStacked