Sha256: 4f32ee7dad458c122a3c6cecb46b5abed3fac5e8dd23c60590b42c33dd72731b

Contents?: true

Size: 1.82 KB

Versions: 6

Compression:

Stored size: 1.82 KB

Contents

/* @flow */

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

import DateTime from '../pb_kit/dateTime.js'
import { buildCss } from '../utilities/props'
import { globalProps } from '../utilities/globalProps.js'

import { Body, Caption, Icon } from '../'

type TimeProps = {
  align?: 'left' | 'center' | 'right',
  className?: string | array<string>,
  data?: string,
  date: string,
  dark?: boolean,
  id?: string,
  showIcon?: boolean,
  size?: 'md' | 'sm',
  timeZone?: string,
}

const Time = (props: TimeProps) => {
  const { align, className, date, showIcon, size, timeZone } = props
  const classes = classnames(
    className,
    buildCss('pb_time_kit', align, size),
    globalProps(props)
  )

  const dateTimestamp = new DateTime({ value: date, zone: timeZone })

  return (
    <div className={classes}>
      <span className="pb_body_kit">
        <If condition={showIcon}>
          <Body
              color="light"
              tag="span"
          >
            <Icon
                fixedWidth
                icon="clock"
                size={size === 'md' ? 'lg' : 'sm'}
            />
          </Body>
          {' '}
        </If>
        <time dateTime={date}>
          <span>
            <If condition={size !== 'md'}>
              <Body
                  color="light"
                  tag="span"
                  text={dateTimestamp.toTimeWithMeridian()}
              />
              <Else />
              <Caption
                  size="lg"
                  tag="span"
                  text={dateTimestamp.toTimeWithMeridian()}
              />
            </If>
            <If condition={timeZone !== undefined}>
              <span className="pb_time_timezone">{dateTimestamp.toTimezone()}</span>
            </If>
          </span>
        </time>
      </span>
    </div>
  )
}

export default Time

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
playbook_ui-7.3.0.pre.alpha2 app/pb_kits/playbook/pb_time/_time.jsx
playbook_ui-6.7.0.pre.alpha1 app/pb_kits/playbook/pb_time/_time.jsx
playbook_ui-6.7.0 app/pb_kits/playbook/pb_time/_time.jsx
playbook_ui-6.6.1 app/pb_kits/playbook/pb_time/_time.jsx
playbook_ui-7.0.0.pre.alpha10 app/pb_kits/playbook/pb_time/_time.jsx
playbook_ui-6.6.0 app/pb_kits/playbook/pb_time/_time.jsx