Sha256: 9ab59f3b53344df0060132badceeeff89515e98a82a504bd92af5f422c4c697a

Contents?: true

Size: 1.13 KB

Versions: 38

Compression:

Stored size: 1.13 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'

import { buildCss } from '../utilities/props'
import { Avatar } from '../'

type MultipleUsersProps = {
  className?: String,
  id?: String,
  maxDisplayedUsers?: Number,
  reverse?: Boolean,
  users: Array<Object>,
}

const MultipleUsers = ({
  className,
  id,
  maxDisplayedUsers = 4,
  reverse = false,
  users,
}: MultipleUsersProps) => {
  const displayCount = users.length > maxDisplayedUsers ? maxDisplayedUsers - 1 : users.length
  const usersToDisplay = users.slice(0, displayCount)

  return (
    <div
        className={classnames(className, buildCss('pb_multiple_users_kit', reverse && 'reverse'))}
        id={id}
    >
      {usersToDisplay.map((avatarData, index) => (
        <Avatar
            {...avatarData}
            className="pb_multiple_users_item"
            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

38 entries across 38 versions & 1 rubygems

Version Path
playbook_ui-4.17.0.pre.alpha1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.16.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.15.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.14.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.15.1.alpha1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.13.1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.13.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.12.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.11.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.11.0.pre.alpha3 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.11.0.pre.alpha.pre.2 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.10.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.10.0.pre.alpha1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.9.0.pre.alpha1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.9.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.8.2 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.8.1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.7.1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.7.0 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx
playbook_ui-4.6.1 app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx