Sha256: 710b1f57762b175b3b99f8900dee88dff464e7965db6f938902feda68504c331

Contents?: true

Size: 1.47 KB

Versions: 19

Compression:

Stored size: 1.47 KB

Contents

/* @flow */

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

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

import Highlight from '../pb_highlight/_highlight'

type BodyProps = {
  aria?: object,
  className?: string,
  children?: array<React.ReactChild>,
  color?: 'default' | 'light' | 'lighter' | 'link',
  dark?: boolean,
  data?: object,
  highlightedText?: array<string>,
  highlighting?: boolean,
  id?: string,
  status?: 'negative' | 'neutral' | 'positive',
  tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
  text?: string,
  variant: null | 'link',
}

const Body = (props: BodyProps) => {
  const {
    aria = {},
    className,
    children,
    color = '',
    data = {},
    highlightedText = [],
    highlighting = false,
    id,
    status,
    tag = 'div',
    text,
    variant = null,
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(
    buildCss('pb_body_kit', color, variant, status),
    globalProps(props),
    className
  )
  const Tag = `${tag}`

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

export default Body

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
playbook_ui-10.25.0.pre.alpha3 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.25.0.pre.treeshaking1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.24.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.24.0.pre.alpha1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.23.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.23.0.pre.alpha2 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.23.0.pre.cachetest app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.23.0.pre.alpha1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.22.1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.22.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.21.1.pre.alpha1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.21.0.pre.alpha.lightbox.2 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.21.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.21.0.pre.alpha.lightbox app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.21.0.pre.alpha.rg1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.21.0.pre.alpha.jg1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.21.0.pre.alpha.na1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.21.0.pre.alpha.jd1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-10.20.0 app/pb_kits/playbook/pb_body/_body.jsx