UNPKG

analytica-frontend-lib

Version:

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

136 lines (133 loc) 3.81 kB
// src/components/Alert/Alert.tsx import { CheckCircle, Info, WarningCircle, XCircle } from "phosphor-react"; // src/utils/utils.ts import { clsx } from "clsx"; import { twMerge } from "tailwind-merge"; function cn(...inputs) { return twMerge(clsx(inputs)); } // src/components/Text/Text.tsx import { jsx } from "react/jsx-runtime"; var Text = ({ children, size = "md", weight = "normal", color = "text-text-950", as, className = "", ...props }) => { let sizeClasses = ""; let weightClasses = ""; const sizeClassMap = { "2xs": "text-2xs", xs: "text-xs", sm: "text-sm", md: "text-md", lg: "text-lg", xl: "text-xl", "2xl": "text-2xl", "3xl": "text-3xl", "4xl": "text-4xl", "5xl": "text-5xl", "6xl": "text-6xl" }; sizeClasses = sizeClassMap[size] ?? sizeClassMap.md; const weightClassMap = { hairline: "font-hairline", light: "font-light", normal: "font-normal", medium: "font-medium", semibold: "font-semibold", bold: "font-bold", extrabold: "font-extrabold", black: "font-black" }; weightClasses = weightClassMap[weight] ?? weightClassMap.normal; const baseClasses = "font-primary"; const Component = as ?? "p"; return /* @__PURE__ */ jsx( Component, { className: cn(baseClasses, sizeClasses, weightClasses, color, className), ...props, children } ); }; var Text_default = Text; // src/components/Alert/Alert.tsx import { jsx as jsx2, jsxs } from "react/jsx-runtime"; var VARIANT_ACTION_CLASSES = { solid: { default: "bg-background-50 border-transparent", info: "bg-info border-transparent", success: "bg-success border-transparent", warning: "bg-warning border-transparent", error: "bg-error border-transparent" }, outline: { default: "bg-background border border-border-100", info: "bg-background border border-border-100", success: "bg-background border border-border-100", warning: "bg-background border border-border-100", error: "bg-background border border-border-100" } }; var COLOR_CLASSES = { default: "text-text-950", info: "text-info-800", success: "text-success-800", warning: "text-warning-800", error: "text-error-800" }; var ICONS = { default: /* @__PURE__ */ jsx2(CheckCircle, { size: 18 }), info: /* @__PURE__ */ jsx2(Info, { size: 18 }), success: /* @__PURE__ */ jsx2(CheckCircle, { size: 18 }), warning: /* @__PURE__ */ jsx2(WarningCircle, { size: 18 }), error: /* @__PURE__ */ jsx2(XCircle, { size: 18 }) }; var Alert = ({ variant = "solid", title, description, action = "default", className, ...props }) => { const baseClasses = "alert-wrapper flex items-start gap-2 w-[384px] py-3 px-4 font-inherit rounded-md"; const variantClasses = VARIANT_ACTION_CLASSES[variant][action]; const variantColor = COLOR_CLASSES[action]; const variantIcon = ICONS[action]; const hasHeading = Boolean(title); return /* @__PURE__ */ jsxs("div", { className: cn(baseClasses, variantClasses, className), ...props, children: [ /* @__PURE__ */ jsx2("span", { className: cn("mt-0.5", variantColor), children: variantIcon }), /* @__PURE__ */ jsxs("div", { children: [ hasHeading && /* @__PURE__ */ jsx2( Text_default, { size: "md", weight: "medium", color: variantColor, className: "mb-0.5", children: title } ), /* @__PURE__ */ jsx2( Text_default, { size: hasHeading ? "sm" : "md", weight: "normal", color: !hasHeading ? variantColor : "text-text-700", children: description } ) ] }) ] }); }; var Alert_default = Alert; export { Alert_default as default }; //# sourceMappingURL=index.mjs.map