Sha256: c190488e042c5c9b682524bed3787579d8b4399ebdd5e7d980d8b12db1a1593c

Contents?: true

Size: 1.52 KB

Versions: 72

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[] | 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() //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

72 entries across 72 versions & 1 rubygems

Version Path
playbook_ui-13.9.0.pre.alpha.play978makehighchartsadevdependencypoc1292 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.verdaccioregistry1277 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.play845addswiftkitspage1273 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.play845addswiftkitspage1272 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.play845allkitsbytypes1271 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.play845allkitsbytypes1270 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.play845allkitsbytypes1268 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.play845allkitsbytypes1266 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.play845allkitsbytypes1264 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.play845allkitsbytypes1263 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.play845allkitsbytypes1262 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.PLAY962SingleSelect1261 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0.pre.alpha.play845allkitsbytypes1260 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.9.0 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.8.0.pre.alpha.play845allkitsbytypes1258 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.8.0.pre.alpha.play845allkitsbytypes1257 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.8.0.pre.alpha.PLAY962SingleSelect1256 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.8.0.pre.alpha.play845allkitsbytypes1255 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.8.0.pre.alpha.play845allkitsbytypes1254 app/pb_kits/playbook/pb_caption/_caption.tsx
playbook_ui-13.8.0.pre.alpha.PLAY962SingleSelect1246 app/pb_kits/playbook/pb_caption/_caption.tsx