Sha256: 0ca35692789adbfa00989515942ee556034f18d44715c90d3e419f8a6be17237

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 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",
  text?: String,
}

const Caption = (props: CaptionProps) => {
  const {
    aria = {},
    className,
    children,
    data = {},
    id,
    size = 'md',
    tag = 'div',
    text,
  } = props
  const Tag = `${tag}`

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

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

export default Caption

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
playbook_ui-6.1.0.pre.alpha5 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-6.1.0.pre.alpha4 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-6.1.0.pre.alpha3 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-6.1.0.pre.alpha2 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-6.1.0.pre.alpha1 app/pb_kits/playbook/pb_caption/_caption.jsx
playbook_ui-6.1.0 app/pb_kits/playbook/pb_caption/_caption.jsx