Sha256: 8ca7dab66374e72bcc86ee74ccd41b603f89b54e1319c38e713d810730068c5c

Contents?: true

Size: 1.62 KB

Versions: 15

Compression:

Stored size: 1.62 KB

Contents

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

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

import TimelineItem from './_item'
import {
  TimelineStep,
  TimelineLabel,
  TimelineDetail,
} from './subcomponents'

type TimelineProps = {
  aria?: { [key: string]: string },
  children?: React.ReactChild[] | React.ReactChild,
  className?: string,
  data?: { [key: string]: string },
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
  id?: string,
  orientation?: string,
  showDate?: boolean,
  itemGap?: 'xs' | 'sm' | 'md' | 'lg' | 'none',
} & GlobalProps

const Timeline = ({
  aria = {},
  className,
  children,
  data = {},
  htmlOptions = {},
  id,
  orientation = 'horizontal',
  showDate = false,
  itemGap = 'none',
  ...props
}: TimelineProps): React.ReactElement => {
  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const htmlProps = buildHtmlProps(htmlOptions)
  const dateStyle = showDate === true ? '_with_date' : ''
  const itemGapStyle = itemGap === 'none' ? '' : `gap_${itemGap}`
  const timelineCss = buildCss('pb_timeline_kit', `${orientation}`, dateStyle, itemGapStyle)

  return (
    <div
        {...ariaProps}
        {...dataProps}
        {...htmlProps}
        className={classnames(timelineCss, globalProps(props), className)}
        id={id}
    >
      {children}
    </div>
  )
}

Timeline.Item = TimelineItem
Timeline.Step = TimelineStep
Timeline.Label = TimelineLabel
Timeline.Detail = TimelineDetail

export default Timeline

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5341 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5340 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5339 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.12.0.pre.rc.3 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.12.0.pre.rc.2 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.12.0.pre.rc.1 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.12.0.pre.rc.0 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5315 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5314 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1750pbcontenttagkitbutton5308 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.11.1 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.11.0.pre.rc.17 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.11.0 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.11.0.pre.rc.16 app/pb_kits/playbook/pb_timeline/_timeline.tsx
playbook_ui-14.10.0.pre.alpha.play16825301 app/pb_kits/playbook/pb_timeline/_timeline.tsx