Sha256: 1a6823798fc80f1353849fc5f4574168c2c9e8e1d8cc7db0175856f8905d0044

Contents?: true

Size: 1.22 KB

Versions: 44

Compression:

Stored size: 1.22 KB

Contents

/* @flow */

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

import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'

import { Body, Title } from '../'
import { spacing } from '../utilities/spacing.js'

type TitleCountProps = {
  align: "center" | "left" | "right",
  aria?: object,
  className?: String,
  count?: Numeric,
  data?: object,
  id?: String,
  title?: String,
  size?: "lg" | "sm",
};

const TitleCount = (props: TitleCountProps) => {
  const {
    align = 'left',
    aria = {},
    className,
    data = {},
    count,
    id,
    title,
    size = 'sm' } = props
  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)

  const css = classnames(buildCss('pb_title_count_kit', align, size), className, spacing(props))

  const formatCount = count.toLocaleString()

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={css}
        id={id}
    >
      <Title
          className={title !== undefined ? 'pb_title_count_text' : ''}
          size={size === 'lg' ? 3 : 4}
          text={title}
      />

      <Body color="light">
        <If condition={count}>{formatCount}</If>
      </Body>

    </div>
  )
}

export default TitleCount

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
playbook_ui-4.18.1.pre.alpha1 app/pb_kits/playbook/pb_title_count/_title_count.jsx
playbook_ui-4.18.1 app/pb_kits/playbook/pb_title_count/_title_count.jsx
playbook_ui-4.18.0 app/pb_kits/playbook/pb_title_count/_title_count.jsx
playbook_ui-4.17.0 app/pb_kits/playbook/pb_title_count/_title_count.jsx