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