Sha256: 4fbca17a04ffec9ea629284a0dc9845a91263c732514dfb3fc84e5e459fb242c

Contents?: true

Size: 1.28 KB

Versions: 38

Compression:

Stored size: 1.28 KB

Contents

/* @flow */

import React from 'react'
import DateTime from '../pb_kit/dateTime.js'
import { Icon } from '../'

const defaultDateString = (value: DateTime) => {
  const weekday = value.toWeekday().toUpperCase()
  const month = value.toMonth().toUpperCase()
  const day = value.toDay()

  return `${weekday} ยท ${month} ${day}`
}

const largeDateString = (value: DateTime) => {
  const month = value.toMonth().toUpperCase()
  const day = value.toDay()

  return `${month} ${day}`
}

type DateSubcomponent = {
  value: DateTime
}

const ExtraSmallDate = ({ value }: DateSubcomponent) => (
  <h3 className="pb_title_kit_4">{defaultDateString(value)}</h3>
)

const SmallDate = ({ value }: DateSubcomponent) => (
  <h3 className="pb_title_kit_4">
    <Icon
        fixedWidth
        icon="calendar"
    />
    {defaultDateString(value)}
  </h3>
)

const LargeDate = ({ value }: DateSubcomponent) => (
  <h3 className="pb_title_kit_3">{largeDateString(value)}</h3>
)

type PbDateProps = {
  size?: 'xs' | 'sm' | 'lg',
  value?: String,
}

const PbDate = ({
  size,
  value,
}: PbDateProps) => {
  const date = new DateTime({ value: value })

  if (size == 'xs') return <ExtraSmallDate value={date} />
  if (size == 'lg') return <LargeDate value={date} />
  return <SmallDate value={date} />
}

export default PbDate

Version data entries

38 entries across 38 versions & 1 rubygems

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