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-13.11.1.pre.alpha.play900startratingasinput1530 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.12.0 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.11.1 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.11.0 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.PLAY1051removinghighchartsdependency1465 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.webpackerregistercomponents1463 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.dependabotnpmandyarnfortawesomefontawesomepro6421439 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.play10561428 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.play1054tableheadersortconsolidation1416 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.play10561409 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.dependabotnpmandyarntiptapextensionlink21121407 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.PLAY1046multilevelsingleselectphase21365 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.PLAY1046multilevelsingleselectphase21358 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.play10481357 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.play845addswiftkitspage1332 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.PLAY978alphatesthighcharts41330 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.PLAY1046multilevelsingleselectphase21328 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.PLAY1046multilevelsingleselectphase21323 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0.pre.alpha.play978makehighchartsadevdependencypoc1322 app/pb_kits/playbook/pb_legend/_legend.tsx
playbook_ui-13.10.0 app/pb_kits/playbook/pb_legend/_legend.tsx