Sha256: 7fe6addda118fe934381ca186defcab97e06a1adde088b0b5b2a91a75bc3a267

Contents?: true

Size: 1.4 KB

Versions: 15

Compression:

Stored size: 1.4 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { Highlight } from '../'
import { globalProps } from '../utilities/globalProps.js'

type BodyProps = {
  aria?: object,
  className?: string,
  children?: array<React.ReactChild>,
  color?: 'default' | 'light' | 'lighter',
  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,
}

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

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(
    buildCss('pb_body_kit', color, 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

15 entries across 15 versions & 1 rubygems

Version Path
playbook_ui-7.0.1.pre.alpha8 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.1.pre.alpha7 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.1.pre.alpha6 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.1.pre.alpha5 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.1.pre.alpha4 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.1.pre.alpha3 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.1.pre.alpha2 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.1.pre.alpha1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.0.pre.alpha7 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.0.pre.alpha6 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.0.pre.alpha5 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.0.pre.alpha4 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.0.pre.alpha3 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-7.0.0.pre.alpha2 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-6.3.0 app/pb_kits/playbook/pb_body/_body.jsx