Sha256: cef2d56c24e6309095153533a8fc0b88431bd262e21f2773ec7bc07e3b12c631

Contents?: true

Size: 1.6 KB

Versions: 34

Compression:

Stored size: 1.6 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { Avatar } from '../'
import { globalProps } from '../utilities/globalProps.js'

type MultipleUsersProps = {
  aria?: object,
  className?: string,
  dark?: boolean,
  data?: object,
  id?: string,
  maxDisplayedUsers?: number,
  reverse?: boolean,
  users: array<object>,
}

const MultipleUsers = (props: MultipleUsersProps) => {
  const {
    aria = {},
    className,
    dark = false,
    data = {},
    id,
    maxDisplayedUsers = 4,
    reverse = false,
    users,
  } = props

  const displayCount =
    users.length > maxDisplayedUsers ? maxDisplayedUsers - 1 : users.length
  const usersToDisplay = users.slice(0, displayCount)

  const reverseClass = reverse === true ? 'reverse' : ''
  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(buildCss('pb_multiple_users_kit', reverseClass),
    className, globalProps(props))

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={classes}
        id={id}
    >
      {usersToDisplay.map((avatarData, index) => (
        <Avatar
            {...avatarData}
            className="pb_multiple_users_item"
            dark={dark}
            key={index}
            size="xs"
        />
      ))}

      <If condition={users.length > maxDisplayedUsers}>
        <div className="pb_multiple_users_item multiple_users_badge">
          {`+${users.length - 3}`}
        </div>
      </If>
    </div>
  )
}

export default MultipleUsers

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
playbook_ui-7.3.0.pre.alpha2 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-6.7.0.pre.alpha1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-6.7.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-6.6.1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.0.pre.alpha10 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-6.6.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-6.5.2 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha12 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha11 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha10 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha9 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-6.5.1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-6.5.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha8 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha7 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha6 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha5 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha4 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha3 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-7.0.1.pre.alpha2 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx