Sha256: a4d96c3ee398856e2146c776f06d5a461224545ba3b47011376dd8d22755bd59

Contents?: true

Size: 1.44 KB

Versions: 138

Compression:

Stored size: 1.44 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 { globalProps } from '../utilities/globalProps.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(
    buildCss('pb_date_stacked_kit', align, size, {
      dark: dark,
      reverse: reverse,
    }),
    globalProps(props),
    className
  )

  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

138 entries across 138 versions & 1 rubygems

Version Path
playbook_ui-9.12.0.pre.text.addon app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.11.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.10.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.10.0.pre.alpha2 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.10.0.pre.alpha1 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.9.0.alpha.inline1 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.9.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.8.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.7.0.pre.alphawidth1 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.7.0.pre.alpha.a11y.btn app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.7.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.6.1 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.6.1.pre.deps1 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.6.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.5.0.alpha.rs.downgrade app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.5.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.4.0.alpha.sisense app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.4.0.alpha.user.kit.bug app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.4.0 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx
playbook_ui-9.3.1.pre.alpha2 app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx