@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
44 lines (43 loc) • 1.96 kB
JavaScript
"use client";
import React from "react";
import cx from "clsx";
import BadgePrimitive from "../primitives/BadgePrimitive";
import { TYPE_OPTIONS } from "./consts";
const getTypeToken = type => {
const tokens = {
[]: "bg-badge-neutral-background text-badge-neutral-foreground",
[]: "bg-badge-info-subtle-background text-badge-info-subtle-foreground",
[]: "bg-badge-success-subtle-background text-badge-success-subtle-foreground",
[]: "bg-badge-warning-subtle-background text-badge-warning-subtle-foreground",
[]: "bg-badge-critical-subtle-background text-badge-critical-subtle-foreground",
[]: "bg-badge-dark-background text-badge-dark-foreground",
[]: "bg-badge-white-background text-badge-white-foreground",
[]: "bg-badge-info-background text-badge-info-foreground",
[]: "bg-badge-critical-background text-badge-critical-foreground",
[]: "bg-badge-success-background text-badge-success-foreground",
[]: "bg-badge-warning-background text-badge-warning-foreground",
[]: "bg-badge-bundle-basic-background text-badge-bundle-basic-foreground",
[]: "bg-badge-bundle-medium-background text-badge-bundle-medium-foreground",
[]: "bg-badge-bundle-top-background text-badge-bundle-top-foreground"
};
return tokens[type];
};
const Badge = ({
type = TYPE_OPTIONS.NEUTRAL,
icon,
children,
ariaLabel,
dataTest,
id,
carriers
}) => {
return /*#__PURE__*/React.createElement(BadgePrimitive, {
carriers: carriers,
className: cx("orbit-badge", getTypeToken(type)),
icon: icon,
id: id,
ariaLabel: ariaLabel,
dataTest: dataTest
}, children);
};
export default Badge;