Sha256: 2613630c8850d05c3d8fcd1d00adf6efaf1da433472987d617f092eafaf7db8c

Contents?: true

Size: 1.96 KB

Versions: 72

Compression:

Stored size: 1.96 KB

Contents

import React from 'react'
import classnames from 'classnames'

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

import Highlight from '../pb_highlight/_highlight'

type BodyProps = {
  aria?: {[key: string]: string},
  className?: string,
  children?: React.ReactChild[] | React.ReactChild,
  color?: 'default' | 'light' | 'lighter' | 'link' | 'error' | 'success',
  dark?: boolean,
  data?: {[key: string]: string},
  highlightedText?: string[],
  highlighting?: boolean,
  id?: string,
  status?: 'neutral' | 'negative' | 'positive',
  tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
  text?: string,
  truncate?: null | '1' | '2' | '3' | '4' | '5',
  variant?: null | 'link',
} & GlobalProps

const Body = (props: BodyProps): React.ReactElement => {
  if (props.variant) deprecatedProps() //status prop is deprecated, use color instead please
  const {
    aria = {},
    children,
    className,
    color = '',
    data = {},
    highlightedText = [],
    highlighting = false,
    id = '',
    status = null,
    tag = 'div',
    text = '',
    truncate = null,
    variant = null,
  } = props

  const ariaProps: {[key: string]: any} = buildAriaProps(aria)
  const dataProps: {[key: string]: any} = buildDataProps(data)
  const isTruncated = truncate ? `truncate_${truncate}` : ''
  const classes = classnames(
    buildCss('pb_body_kit', color, variant, status, isTruncated),
    globalProps(props),
    className
  )
  const Tag: React.ReactElement | any = `${tag}`


  return (
    <Tag
        {...ariaProps}
        {...dataProps}
        className={classes}
        id={id}
    >
      { highlighting && (
        <Highlight
            highlightedText={highlightedText}
            text={text}
        >
          {children}
        </Highlight>
      ) }
      { !highlighting && (
        text || children
      ) }
    </Tag>
  )
}

export default Body

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
playbook_ui-13.12.0.pre.alpha.PLAY880cardkithighlightzindex1655 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exportingtypes1627 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exportingtypes1626 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1624 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1623 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1612 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1611 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1609 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1608 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1581 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1580 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1579 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1093typeaheadkitdocbug1577 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1574 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1567 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1558 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1556 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1051removinghighchartsdependency1551 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1550 app/pb_kits/playbook/pb_body/_body.tsx
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1543 app/pb_kits/playbook/pb_body/_body.tsx