Sha256: d0374dde1986ecefa221b2324f2ae3d53065554ab5f9271c7cc927825ae135c7

Contents?: true

Size: 1.54 KB

Versions: 95

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 TitleProps = {
  aria?: {[key: string]: string},
  bold?: boolean,
  children?: React.ReactChild[] | React.ReactChild,
  className?: string,
  color?: "default" | "light" | "lighter" | "success" | "error" | "link",
  data?: {[key: string]: string},
  id?: string,
  size?: 1 | 2| 3| 4 | "1" | "2" | "3" | "4",
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span",
  text?: string,
  variant?: null | "link",
} & GlobalProps

const Title = (props: TitleProps): React.ReactElement => {
  if (props.variant) deprecatedProps('Title', ['variant']) //variant prop is deprecated, use color instead
  const {
    aria = {},
    bold = true,
    children,
    className,
    color,
    data = {},
    id,
    size = 3,
    tag = 'h3',
    text,
    variant = null,
  } = props

  const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
  const dataProps: {[key: string]: string | number} = buildDataProps(data)
  const getBold = bold ? '' : 'thin'
  const classes = classnames(
    buildCss('pb_title_kit', `size_${size}`, variant, color, getBold),
    globalProps(props),
    className,
  )
  const Tag: React.ReactElement | any = `${tag}`

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

export default Title

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
playbook_ui-12.17.1 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.17.0.pre.alpha.lightboxcurrentPhotoIndex582 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.17.0 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.16.0.pre.alpha.tooltippositionprop566 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.16.0.pre.alpha.PLAY693tooltipwrongbg558 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.16.0.pre.alpha.PLAY693tooltipwrongbg547 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.16.0.pre.alpha.PLAY693tooltipwrongbg532 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.16.0.pre.alpha.lightboxcurrentphotoprop531 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.16.0.pre.alpha.tiptaptestingpart1528 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.16.0 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.15.0 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.14.0.pre.alpha.lightboxcurrentphotoprop460 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.14.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown457 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.14.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown456 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.14.0 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.13.0.pre.alpha.PLAY693tooltipwrongbg440 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.13.0.pre.alpha.addingProductTokens439 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.13.0.pre.alpha.PLAY705phonenumberkit438 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.13.0 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-12.12.0.pre.alpha.PLAY697sandpacklayoutstyles413 app/pb_kits/playbook/pb_title/_title.tsx