UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

107 lines (102 loc) 4.62 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _chunkTN3AYOMVjs = require('./chunk-TN3AYOMV.js'); // src/components/Badge/Badge.tsx var _Bell = require('@phosphor-icons/react/dist/csr/Bell'); var _jsxruntime = require('react/jsx-runtime'); var VARIANT_ACTION_CLASSES = { solid: { error: "bg-error-background text-error-700 focus-visible:outline-none", warning: "bg-warning text-warning-800 focus-visible:outline-none", success: "bg-success text-success-800 focus-visible:outline-none", info: "bg-info text-info-800 focus-visible:outline-none", muted: "bg-background-muted text-background-800 focus-visible:outline-none", orange: "bg-orange-100 text-orange-700 focus-visible:outline-none", neutral: "bg-black text-white focus-visible:outline-none" }, outlined: { error: "bg-error text-error-700 border border-error-300 focus-visible:outline-none", warning: "bg-warning text-warning-800 border border-warning-300 focus-visible:outline-none", success: "bg-success text-success-800 border border-success-300 focus-visible:outline-none", info: "bg-info text-info-800 border border-info-300 focus-visible:outline-none", muted: "bg-background-muted text-background-800 border border-border-300 focus-visible:outline-none" }, exams: { exam1: "bg-exam-1 text-info-700 focus-visible:outline-none", exam2: "bg-exam-2 text-typography-1 focus-visible:outline-none", exam3: "bg-exam-3 text-typography-2 focus-visible:outline-none", exam4: "bg-exam-4 text-success-700 focus-visible:outline-none" }, examsOutlined: { exam1: "bg-exam-1 text-info-700 border border-info-700 focus-visible:outline-none", exam2: "bg-exam-2 text-typography-1 border border-typography-1 focus-visible:outline-none", exam3: "bg-exam-3 text-typography-2 border border-typography-2 focus-visible:outline-none", exam4: "bg-exam-4 text-success-700 border border-success-700 focus-visible:outline-none" }, resultStatus: { negative: "bg-error text-error-800 focus-visible:outline-none", positive: "bg-success text-success-800 focus-visible:outline-none" }, notification: "text-primary" }; var SIZE_CLASSES = { small: "text-2xs px-2 py-1", medium: "text-xs px-2 py-1", large: "text-sm px-2 py-1" }; var SIZE_CLASSES_ICON = { small: "size-3", medium: "size-3.5", large: "size-4" }; var Badge = ({ children, iconLeft, iconRight, size = "medium", variant = "solid", action = "error", className = "", notificationActive = false, ...props }) => { const sizeClasses = SIZE_CLASSES[size]; const sizeClassesIcon = SIZE_CLASSES_ICON[size]; const variantActionMap = VARIANT_ACTION_CLASSES[variant] || {}; const variantClasses = typeof variantActionMap === "string" ? variantActionMap : _nullishCoalesce(_nullishCoalesce(variantActionMap[action], () => ( variantActionMap.muted)), () => ( "")); const baseClasses = "inline-flex items-center justify-center rounded-xs font-normal gap-1 relative"; const baseClassesIcon = "flex items-center"; if (variant === "notification") { return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkTN3AYOMVjs.cn.call(void 0, baseClasses, variantClasses, sizeClasses, className), ...props, children: [ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Bell.BellIcon, { size: 24, className: "text-current", "aria-hidden": "true" }), notificationActive && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "data-testid": "notification-dot", className: "absolute top-[2px] right-[2px] block h-2 w-2 rounded-full bg-indicator-error ring-2 ring-white" } ) ] } ); } return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkTN3AYOMVjs.cn.call(void 0, baseClasses, variantClasses, sizeClasses, className), ...props, children: [ iconLeft && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _chunkTN3AYOMVjs.cn.call(void 0, baseClassesIcon, sizeClassesIcon), children: iconLeft }), children, iconRight && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _chunkTN3AYOMVjs.cn.call(void 0, baseClassesIcon, sizeClassesIcon), children: iconRight }) ] } ); }; var Badge_default = Badge; exports.Badge_default = Badge_default; //# sourceMappingURL=chunk-BJMKBBN3.js.map