Sha256: 5ca9326578ecc5e6ba915efc442e94434d437c997557fa4815a87c6a3634012f

Contents?: true

Size: 1.33 KB

Versions: 17

Compression:

Stored size: 1.33 KB

Contents

/* @flow */

import React from 'react'

import { Body, Caption, Title } from '../'
import { buildCss } from '../utilities/props'

type CurrencyProps = {
  align?: 'left' | 'center' | 'right',
  amount: string,
  unit: string,
  className?: string,
  label?: string,
  size?: 'sm' | 'md' | 'lg',
  symbol?: string,
  dark?: boolean,
}

const sizes = {
  lg: 1,
  md: 3,
  sm: 4,
}

const Currency = ({
  align = 'left',
  amount,
  unit,
  className,
  label = '',
  size = 'sm',
  symbol = '$',
  dark = false,
}: CurrencyProps) => {
  const [whole, decimal = '00'] = amount.split('.')

  return (
    <div className={buildCss('pb_currency_kit', align, className, { dark: dark }, size)}>
      <Caption>{label}</Caption>

      <div className="pb_currency_wrapper">
        <Body
            className="dollar_sign"
            color="light"
            dark={dark}

        >
          {symbol}
        </Body>

        <Title
            className="pb_currency_value"
            dark={dark}
            size={sizes[size]}
        >
          {`${whole}`}
        </Title>

        <Body
            className="unit"
            color="light"
            dark={dark}

        >
          <If condition={unit}>
            {unit}
            <Else />
            {`.${decimal}`}
          </If>
        </Body>
      </div>
    </div>
  )
}

export default Currency

Version data entries

17 entries across 17 versions & 1 rubygems

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