Sha256: 0fe5fd3faeca92fa34d3c504b56b2b885392ea88688d363a8cbcf252debf64b3

Contents?: true

Size: 1.42 KB

Versions: 29

Compression:

Stored size: 1.42 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},
  children?: React.ReactChild[],
  className?: string,
  color?: "default" | "light" | "lighter" | "success" | "error" | "link",
  data?: {[key: string]: string},
  id?: string,
  size?: 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 = {},
    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 classes = classnames(
    buildCss('pb_title_kit', `size_${size}`, variant, color),
    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

29 entries across 29 versions & 1 rubygems

Version Path
playbook_ui-11.3.0.pre.alpha2 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.3.0.pre.alpha1 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.3.0 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.2.7 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.2.6 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.2.5 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.2.4 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.2.4.pre.alpha1 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.2.3 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.2.2 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.2.1 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.2.0 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.1.2 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.1.2.pre.alpha1 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.1.1 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.1.1.pre.alpha1 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.1.0 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.0.1 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.0.0 app/pb_kits/playbook/pb_title/_title.tsx
playbook_ui-11.0.0.pre.alpha.2 app/pb_kits/playbook/pb_title/_title.tsx