Sha256: 672b196bf2a7806e7c683fb4b278dc9a4c4a1ffbb57067d6a6b1ba4d334cd2bb

Contents?: true

Size: 1.53 KB

Versions: 21

Compression:

Stored size: 1.53 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { globalProps } from '../utilities/globalProps.js'
import { Icon } from '../'

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

type BadgeProps = {
  aria?: object,
  className?: string,
  closeProps?: {
    onClick?: EventHandler,
    onMouseDown?: EventHandler,
    onTouchEnd?: EventHandler,
  },
  data?: object,
  id?: string,
  removeIcon?: Boolean,
  removeOnClick?: EventHandler,
  rounded?: boolean,
  text?: string,
  variant?: "error" | "info" | "neutral" | "primary" | "success" | "warning",
}
const Badge = (props: BadgeProps) => {
  const {
    aria = {},
    className,
    closeProps = {},
    data = {},
    id,
    removeIcon = false,
    removeOnClick = () => {},
    rounded = false,
    text,
    variant = 'neutral',
  } = props
  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const css = classnames(
    buildCss('pb_badge_kit', variant, { rounded }),
    globalProps(props),
    className
  )

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={css}
        id={id}
    >
      <span>
        {text}
        <If condition={removeIcon}>
          <span
              onClick={removeOnClick}
              style={{ cursor: 'pointer' }}
              {...closeProps}
          >
            <Icon
                fixedWidth
                icon="times"
            />
          </span>
        </If>
      </span>
    </div>
  )
}

export default Badge

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
playbook_ui-9.19.0 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.19.0.pre.alphafonts app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.18.0.flow.bin.alpha app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.18.0 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.17.0 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.17.0.pre.decouple.website2 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.16.0 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.15.0 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.15.0.pre.decouple.website1 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.14.1.alpha.radio.alignment app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.14.1.alpha.highcharts9 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.14.1 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.13.0 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.9.0.alpha.inline1 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.3.0.alpha.inline3 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.3.0.alpha.inline2 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-9.3.0.alpha.inline1 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-8.2.1.pre.alpha5 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-8.2.1.pre.alpha4 app/pb_kits/playbook/pb_badge/_badge.jsx
playbook_ui-8.2.1.pre.alpha3 app/pb_kits/playbook/pb_badge/_badge.jsx