Sha256: 8f46d24dee6ac0c3e2a58cc56baf6100a9e6dcb61e92831a592412cf2c141c91

Contents?: true

Size: 1.54 KB

Versions: 330

Compression:

Stored size: 1.54 KB

Contents

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

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

import Body from '../pb_body/_body'
import Title from '../pb_title/_title'

type LegendProps = {
  aria?: { [key: string]: string },
  className?: string,
  color?: string,
  dark?: boolean,
  data?: object,
  id?: string,
  prefixText?: string,
  text: string,
}

const Legend = (props: LegendProps) => {
  const {
    aria = {},
    className,
    color = 'data_1',
    dark = false,
    data = {},
    id,
    prefixText,
    text,
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)

  const customColor = color.charAt(0) === '#' && color

  const customColorStyle = {
  background: customColor
}

 
  const bodyCss = classnames(
    buildCss('pb_legend_kit', customColor ? "" : color),
    globalProps(props),
    className
  )

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={bodyCss}
        id={id}
    >
      <Body color={dark ? 'lighter' : 'light'}>
        <span className={`${customColor ? "pb_legend_indicator_circle_custom" : "pb_legend_indicator_circle"}`}
            style={customColorStyle} 
        />
        {
          prefixText && (
            <Title
              dark={dark}
              size={4}
              tag="span"
              text={` ${prefixText} `}
          />
          )
        }
        {` ${text} `}
      </Body>
    </div>
  )
}

export default Legend

Version data entries

330 entries across 330 versions & 1 rubygems

Version Path
playbook_ui-12.7.1.pre.alpha.menu2 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.7.1.pre.alpha.menu1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.7.1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.7.0 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.6.0.pre.alpha.sectionseparator1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.6.0.pre.alpha.menuyml1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.6.0.pre.alpha.collapsible1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.6.0.pre.alpha.cssphone1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.6.0 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.5.0.pre.alpha.datepickerinput1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.5.0.pre.alpha.phonerails1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.5.0.pre.alpha.datepicker1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.5.0.pre.alpha.filter1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.5.0 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.4.0.pre.alpha.map1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.4.0.pre.alpha.devdocstest1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.4.0 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.3.1.pre.alpha.phone1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.3.1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.3.0.pre.alpha.patchtest1 app/pb_kits/playbook/pb_legend/_legend.tsx