Sha256: e386aa342d221b98d2117ca0db627ccb4a945982d3ad98f4fa76e9be64939a27

Contents?: true

Size: 1.54 KB

Versions: 298

Compression:

Stored size: 1.54 KB

Contents

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

type CaptionProps = {
  aria?: {[key: string]: string},
  children?: React.ReactChild[] | React.ReactChild,
  className?: string,
  color?: "default" | "light" | "lighter" | "success" | "error" | "link",
  data?: {[key: string]: string},
  id?: string,
  size?: "xs" | "sm" | "md" | "lg" | "xl",
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "div" | "caption",
  text?: string,
  variant?: null | "link",
} & GlobalProps;

const Caption = (props: CaptionProps): React.ReactElement => {
  if (props.variant) deprecatedProps('Title', ['variant']) //variant prop is deprecated, use color instead
  const {
    aria = {},
    children,
    className,
    color,
    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, color),
    globalProps(props),
    className,
  )

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

export default Caption

Version data entries

298 entries across 298 versions & 1 rubygems

Version Path
playbook_ui-12.27.0.pre.alpha.expandednotworking853 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.27.0 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.1.pre.alpha.railsmultilevelimprovements842 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.1.pre.alpha.railsmultilevelimprovements837 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.1.pre.alpha.PLAY860PhoneNumInputOptions836 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.1.pre.alpha.railsmultilevelimprovements835 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.1.pre.alpha.play716popoverkitcloseonclickissue833 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.1.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown831 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.1 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.multiselectfixes825 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown822 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.multiselectfixes821 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown818 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown817 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown815 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown813 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.alphafix812 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.alphafix810 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.railsmultilevelimprovements805 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-12.26.0.pre.alpha.multiselectfixes798 app/pb_kits/playbook/pb_caption/_caption.tsx