// @flow strict import * as React from 'react'; import { colorDanger, colorDangerLightest, colorGrayLightest, colorInformation, colorInformationLightest, colorNeutral, colorNeutralLightest, colorSuccess, colorSuccessLightest, colorWarning, colorWarningLightest, } from '../../styles/variables/_color'; import classify from '../../utils/classify'; import type {IconSize, IconType} from '../Icon'; import {Icon} from '../Icon'; import {ButtonTextSmall} from '../Text'; import css from './Badge.module.css'; type ClassNames = $ReadOnly<{wrapper?: string, text?: string, icon?: string}>; export const BADGE_COLOR = Object.freeze({ gray: colorGrayLightest, red: colorDangerLightest, redDark: colorDanger, orange: colorWarningLightest, orangeDark: colorWarning, green: colorSuccessLightest, greenDark: colorSuccess, blue: colorInformationLightest, blueDark: colorInformation, indigo: colorNeutralLightest, indigoDark: colorNeutral, }); export type BadgeColorType = $Keys; export type BaseBadgeProps = { classNames?: ClassNames, fill?: BadgeColorType, }; export type BadgeProps = { ...BaseBadgeProps, text: string, }; export type IconBadgeProps = { ...BaseBadgeProps, iconName: string, iconType?: IconType, iconSize?: IconSize, onClick?: ?(SyntheticEvent) => mixed, ariaLabel?: string, }; export const Badge: React$AbstractComponent = React.forwardRef( ({classNames, text, fill = 'gray'}: BadgeProps, ref): React.Node => { const isDark = fill.includes('Dark'); return (
{text}
); }, ); export const IconBadge: React$AbstractComponent< IconBadgeProps, HTMLDivElement, > = React.forwardRef( ( { classNames, fill = 'gray', iconName, iconSize = 'small', iconType = 'solid', ariaLabel, onClick, }: IconBadgeProps, ref, ): React.Node => { const isDark = fill.includes('Dark'); return (
); }, );