Sha256: 4716e0928421eea48ed5a7c2faac1833da8d70d696aa0d9a18ce32c8d4070641

Contents?: true

Size: 1.22 KB

Versions: 105

Compression:

Stored size: 1.22 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { globalProps } from '../utilities/globalProps.js'

type CaptionProps = {
  aria?: object,
  className?: string,
  children: array<React.ReactNode> | React.ReactNode,
  data?: object,
  id?: string,
  size?: "xs" | "sm" | "md" | "lg" | "xl",
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "div" | "caption",
  text?: string,
  variant?: null | "link",
}

const Caption = (props: CaptionProps) => {
  const {
    aria = {},
    className,
    children,
    data = {},
    id,
    size = 'md',
    tag = 'div',
    text,
    variant = null,
  } = props
  const tagOptions = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span', 'div', 'caption']
  const Tag = tagOptions.includes(tag) ? tag : 'div'

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const css = classnames(
    buildCss('pb_caption_kit', size, variant),
    globalProps(props),
    className
  )

  return (
    <Tag
        {...ariaProps}
        {...dataProps}
        className={css}
        id={id}
    >
      {text || children}
    </Tag>
  )
}

export default Caption

Version data entries

105 entries across 105 versions & 1 rubygems

Version Path
playbook_ui-9.18.0.flow.bin.alpha app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.18.0 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.17.0 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.17.0.pre.decouple.website2 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.16.0 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.15.0 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.15.0.pre.decouple.website1 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.14.1.alpha.radio.alignment app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.14.1.alpha.highcharts9 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.14.1 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.13.0 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.12.0 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.12.0.pre.text.addon app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.11.0 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.10.0 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.10.0.pre.date.time.stacked.1 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.10.0.pre.alpha2 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.10.0.pre.alpha1 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.9.0.alpha.inline1 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-9.9.0 app/pb_kits/playbook/pb_caption/_caption.jsx