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.10.0 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.9.1.pre.alpha.play664tiptapinvestigation353 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.9.1.pre.alpha.PLAY689bugtxtinputlabel346 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.9.1.pre.alpha.menucleanup345 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.9.1.pre.alpha.menucleanup342 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.9.1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.9.0 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.8.0.pre.alpha.PLAY625phonenumberdark301 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.8.0.pre.alpha.PLAY625phonenumberdark300 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.8.0.pre.alpha.PLAY649mapkitstyles299 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.8.0.pre.alpha.PLAY645typescriptprogresstep298 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.8.0.pre.alpha.PLAY645typescriptprogresstep297 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.8.0.pre.alpha.rubyandnpmalpharelease296 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.8.0.pre.alpha.rubyandnpmalpharelease295 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.8.0.pre.alpha.rubyandnpmalpharelease294 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.8.0 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.7.1.pre.alpha.rubyandnpmalpharelease293 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.7.1.pre.alpha.rubyandnpmalpharelease292 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.7.1.pre.alpha.rubyandnpmalpharelease291 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-12.7.1.pre.alpha.alpharubyrelease281 app/pb_kits/playbook/pb_legend/_legend.tsx