Sha256: 02bcb700a6241aacb382b0a779d3ec9b5b3752e11a0ef28589d3da5fcd488fe0

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

/* @flow */

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

type BodyProps = {
  aria?: object,
  className?: String,
  children?: Array<React.ReactChild>,
  color: 'dark' | 'default' | 'light' | 'lighter' | 'light_dark' | 'lighter_dark',
  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 = '',
    dark = false,
    data = {},
    highlightedText = [],
    highlighting = false,
    id,
    status = '',
    tag = 'div',
    text,
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(
    className,
    buildCss('pb_body_kit', color, status, {
      dark: dark,
    }),
    spacing(props)
  )
  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

2 entries across 2 versions & 1 rubygems

Version Path
playbook_ui-5.5.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-5.4.0 app/pb_kits/playbook/pb_body/_body.jsx