Sha256: deae4547a0d65c572bfce2717c177e21d7cf9bdbce95b0dc831d3134c836714e

Contents?: true

Size: 1.43 KB

Versions: 44

Compression:

Stored size: 1.43 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import DateTime from '../pb_kit/dateTime.js'
import { buildCss } from '../utilities/props'
import { Caption, Title } from '../'
import { spacing } from '../utilities/spacing.js'

type DateStackedProps = {
  align?: "left" | "center" | "right",
  className?: String | Array<String>,
  dark?: Boolean,
  data?: String,
  date: String,
  size?: "sm" | "md",
  id?: String,
  reverse?: Boolean,
}

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

const DateStacked = (props: DateStackedProps) => {
  const {
    align = 'left',
    reverse = false,
    className,
    dark = false,
    date,
    size = 'sm',
  } = props
  const classes = classnames(
    className,
    buildCss('pb_date_stacked_kit', align, size, {
      dark: dark,
      reverse: reverse,
    }),
    spacing(props)
  )

  const currentYear = new Date().getFullYear().toString()
  const dateTimestamp = new DateTime({ value: date })
  const inputYear = dateTimestamp.toYear().toString()

  return (
    <div className={classes}>
      <div className="pb_date_stacked_day_month">
        <Caption text={dateTimestamp.toMonth().toUpperCase()} />
        <Title
            dark={dark}
            size={sizes[size]}
            text={dateTimestamp.toDay()}
        />
      </div>
      <If condition={currentYear != inputYear}>
        <Caption size="xs">{inputYear}</Caption>
      </If>
    </div>
  )
}

export default DateStacked

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
playbook_ui-5.2.0.pre.alpha8 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.2.0.pre.alpha7 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.3.0.pre.alpha1 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.4.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.2.0.pre.alpha6 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.2.0.pre.alpha5 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.3.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.2.0.pre.alpha4 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.2.0.pre.alpha3 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.2.0.pre.alpha2 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.2.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.1.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.0.3 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.0.2 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.0.1.pre.beta app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.1.0.pre.alpha4 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.1.0.pre.alpha2 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.1.0.pre.alpha1 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.0.1 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-5.0.1.pre.alpha1 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx