Sha256: c669ed87b4443ebd04be17074ecbd0c6e19964802ba9ebe7f7835b8c1c85f27c

Contents?: true

Size: 1.13 KB

Versions: 28

Compression:

Stored size: 1.13 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { Highlight } from '../'

type BodyProps = {
  className?: String,
  children?: Array<React.ReactChild>,
  color: 'light' | 'lighter',
  dark?: Boolean,
  status?: 'negative' | 'positive',
  tag: String,
  text?: String,
  highlighting?: Boolean,
  highlightedText?: Array<String>
}

const bodyCSS = ({
  color = '',
  dark = false,
  status = '',

}: BodyProps) => {
  const colorStyle = color !== '' ? `_${color}` : ''

  const themeStyle = dark === true ? '_dark' : ''

  const statusStyle = status !== '' ? `_${status}` : ''

  return 'pb_body_kit' + colorStyle + themeStyle + statusStyle
}

const Body = (props: BodyProps) => {
  const {
    className,
    children,
    text,
    tag = 'div',
    highlightedText,
    highlighting = false,
  } = props

  const Tag = `${tag}`

  return (
    <Tag className={classnames(bodyCSS(props), className)}>
      <If condition={highlighting}>
        <Highlight highlightedText={highlightedText}>{text || children}</Highlight>
        <Else />
        { text || children }
      </If>
    </Tag>
  )
}

export default Body

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
playbook_ui-4.17.0.pre.alpha1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.16.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.15.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.14.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.15.1.alpha1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.13.1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.13.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.12.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.11.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.11.0.pre.alpha3 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.11.0.pre.alpha.pre.2 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.10.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.10.0.pre.alpha1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.9.0.pre.alpha1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.9.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.8.2 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.8.1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.7.1 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.7.0 app/pb_kits/playbook/pb_body/_body.jsx
playbook_ui-4.6.1 app/pb_kits/playbook/pb_body/_body.jsx