Sha256: 4d6ad7b57414f9a8723d6c18eb741212f684c666ea572bd3b3a1898137511621

Contents?: true

Size: 1.51 KB

Versions: 44

Compression:

Stored size: 1.51 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { spacing } from '../utilities/spacing.js'
import { buildCss } from '../utilities/props'

import { Caption, Title } from '../'

import DateTime from '../pb_kit/dateTime.js'

type WeekdayStackedProps = {
  align?: "left" | "center" | "right",
  className?: String,
  dark?: Boolean,
  date: Date,
  variant?: "day_only" | "month_day" | "expanded",
  compact?: Boolean,
  id?: String,
}

const getDayOfWeek = (date, compact) => {
  const dateTime = new DateTime({ value: date })
  if (compact) {
    return dateTime.toDayAbbr()
  } else {
    return dateTime.toWeekday()
  }
}

const getFormattedDate = (date, variant) => {
  const dateTime = new DateTime({ value: date })
  if (variant === 'day_only') {
    return dateTime.toDay()
  } else {
    const format = variant === 'expanded' ? '%b %-d' : '%-m/%-d'
    return dateTime.toCustomFormat(format)
  }
}

const WeekdayStacked = (props: WeekdayStackedProps) => {
  const {
    align = 'left',
    className,
    dark = false,
    date = new Date(),
    variant = 'month_day',
    compact = false,
  } = props
  return (
    <div
        className={classnames(
        buildCss('pb_weekday_stacked_kit', align),
        className,
        spacing(props)
      )}
    >
      <Caption dark={dark}>{getDayOfWeek(date, compact)}</Caption>
      <Title
          dark={dark}
          size={4}
          tag="span"
          text={getFormattedDate(date, variant)}
      />
    </div>
  )
}

export default WeekdayStacked

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
playbook_ui-6.0.1.pre.alpha5 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-6.0.1.pre.alpha4 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-6.0.1.pre.alpha3 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-6.0.1.pre.alpha2 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.2.0.pre.alpha15 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.2.0.pre.alpha14 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.2.0.pre.alpha13 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-6.0.1 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.2.0.pre.alpha12 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-6.0.0 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.2.0.pre.alpha11 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.5.1.pre.alpha4 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.5.1.pre.alpha3 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.5.1.pre.alpha2 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.5.1.pre.alpha1 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.2.0.pre.alpha10 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.5.1 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.5.0 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.5.0.pre.alpha1 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx
playbook_ui-5.2.0.pre.alpha9 app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx