Sha256: c1468f8fb84122262a3f7fa1222d67de207c4cc2467c05fb5767671276c355bc

Contents?: true

Size: 1.76 KB

Versions: 644

Compression:

Stored size: 1.76 KB

Contents

import React from 'react'
import classnames from 'classnames'

import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
import { globalProps } from '../utilities/globalProps'

import Flex from '../pb_flex/_flex'
import Time from '../pb_time/_time'
import FormattedDate from '../pb_date/_date'

type DateTimeProps = {
  align?: "left" | "center" | "right",
  aria?: { [key: string]: string; },
  className?: string,
  data?: { [key: string]: string; },
  datetime: Date,
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
  id?: string,
  size?: "sm" | "md",
  showDayOfWeek: boolean,
  showIcon?: boolean,
  timeZone?: string
}

const DateTime = (props: DateTimeProps): React.ReactElement => {
  const {
    align = 'left',
    aria = {},
    className,
    data = {},
    htmlOptions = {},
    showDayOfWeek = false,
    datetime,
    id,
    showIcon = false,
    size = 'md',
    timeZone = 'America/New_York',
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const htmlProps = buildHtmlProps(htmlOptions)
  const classes = classnames(
    buildCss('pb_date_time', size),
    globalProps(props),
    className
  )

  return (
    <div
        {...ariaProps}
        {...dataProps}
        {...htmlProps}
        className={classes}
        id={id}
    >
      <Flex
          horizontal={align}
          vertical="baseline"
      >
        <FormattedDate
            showDayOfWeek={showDayOfWeek}
            size={size}
            value={datetime}
        />
        <Time
            date={datetime}
            marginLeft="sm"
            showIcon={showIcon}
            size={size}
            timeZone={timeZone}
        />
      </Flex>
    </div>
  )
}

export default DateTime

Version data entries

644 entries across 644 versions & 1 rubygems

Version Path
playbook_ui-14.11.0.pre.rc.17 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.0 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.0.pre.rc.16 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.play16825301 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.0.pre.rc.15 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.0.pre.rc.14 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.0.pre.rc.13 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.0.pre.rc.12 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5274 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.play1465attempt25272 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.play16825244 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.0.pre.rc.11 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.0.pre.rc.10 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5214 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5213 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5210 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5208 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5207 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.play16825206 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5204 app/pb_kits/playbook/pb_date_time/_date_time.tsx