UNPKG

@codeworker.br/govbr-tw-react

Version:

Biblioteca de componentes React usando Tailwind CSS que implementa o Padrão Digital de Governo.

61 lines (60 loc) 2.46 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import { cva } from "class-variance-authority"; /** * Skeleton – placeholder carregando, inspirado no shadcn/ui. * * Agora com props para customizar a **cor que pulsa** e a **animação**: * - `toneClassName`: classes Tailwind para a base/cor do skeleton (ex.: `bg-emerald-200`). * - `animateClassName`: classes Tailwind para a animação (ex.: `animate-pulse`, `motion-safe:animate-[pulse_1.5s_ease_infinite]`). * * Dica: se quiser somente trocar a cor, basta `toneClassName`. Se quiser * customizar a animação, passe `animate={false}` e use apenas `animateClassName`. */ const skeletonVariants = cva("block select-none bg-govbr-gray-10 dark:bg-white/10", { variants: { theme: { light: "bg-govbr-gray-10", normal: "bg-govbr-gray-10", dark: "bg-white/15", }, animate: { true: "animate-pulse", false: "", }, radius: { none: "rounded-none", sm: "rounded", md: "rounded-md", lg: "rounded-lg", full: "rounded-full", }, }, defaultVariants: { theme: "light", animate: true, radius: "md", }, }); function cx(...cls) { return cls.filter(Boolean).join(" "); } const Skeleton = forwardRef(function Skeleton(_a, ref) { var { className, theme, animate, radius, toneClassName, animateClassName } = _a, rest = __rest(_a, ["className", "theme", "animate", "radius", "toneClassName", "animateClassName"]); const variantClasses = skeletonVariants({ theme, animate, radius }); // toneClassName e animateClassName entram por último para permitir override via Tailwind const classes = cx(variantClasses, toneClassName, animateClassName, className); return _jsx("div", Object.assign({ ref: ref, className: classes }, rest)); }); export default Skeleton;