Sha256: 9996930d9b87372c312b2885b8cba5229382043fbf93587f8cef718b6d4cc1e3

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

/* @flow */

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

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

import { Body, Title } from '../'
import { globalProps } from '../utilities/globalProps.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, globalProps(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

3 entries across 3 versions & 1 rubygems

Version Path
playbook_ui-6.2.1 app/pb_kits/playbook/pb_title_count/_title_count.jsx
playbook_ui-6.2.0 app/pb_kits/playbook/pb_title_count/_title_count.jsx
playbook_ui-7.0.0.pre.alpha1 app/pb_kits/playbook/pb_title_count/_title_count.jsx