Sha256: ec31bee149ec45c6c31b386b04b81341254dc090641168c1dc0b3e51992278fb

Contents?: true

Size: 1.52 KB

Versions: 10

Compression:

Stored size: 1.52 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[],
  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

10 entries across 10 versions & 1 rubygems

Version Path
playbook_ui-11.0.0.pre.alpha.2 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-11.0.0.pre.alpha.1 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-10.26.1 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-10.27.0.pre.lazysizes1 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-10.27.0.pre.datepicker1 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-10.26.0 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-10.26.0.pre.alpha5 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-10.26.0.pre.rc1 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-10.26.0.pre.alpha.display1 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-10.26.0.pre.alpha1 app/pb_kits/playbook/pb_caption/_caption.tsx