UNPKG

@sikka/hawa

Version:

Modern UI Kit made with Tailwind

175 lines (170 loc) • 6.24 kB
"use client"; // layout/stats/Stats.tsx import React3 from "react"; // util/index.ts import { clsx } from "clsx"; import { twMerge } from "tailwind-merge"; function cn(...inputs) { return twMerge(clsx(inputs)); } // elements/card/Card.tsx import * as React from "react"; var Card = React.forwardRef( ({ className, variant = "default", clickable = false, asContainer = false, ...props }, ref) => { let variantStyles = { default: cn( "hawa-rounded-lg hawa-border hawa-bg-card hawa-text-card-foreground hawa-shadow-sm", clickable && "hawa-cursor-pointer hawa-transition-all hover:hawa-drop-shadow-md dark:hover:dark-shadow" ), neoBrutalism: cn( "neo-brutalism", // "hawa-transition-all hawa-uppercase hawa-font-mono dark:hawa-bg-black hawa-font-bold hawa-py-2 hawa-px-4 hawa-rounded hawa-border-2 hawa-border-primary hawa-shadow-color-primary hawa-transition-[hawa-transform_50ms, hawa-box-shadow_50ms] transition-all uppercase font-mono dark:bg-black font-bold py-2 px-4 rounded border-2 border-primary shadow-color-primary transition-[transform_50ms, box-shadow_50ms]", clickable && "hawa-cursor-pointer active:hawa-translate-x-0.5 active:hawa-translate-y-0.5 active:hawa-shadow-color-primary-active active:translate-x-0.5 active:translate-y-0.5 active:shadow-color-primary-active" ) }; return /* @__PURE__ */ React.createElement( "div", { ref, className: cn(className, !asContainer && variantStyles[variant]), ...props } ); } ); var CardHeader = React.forwardRef( ({ className, ...props }, ref) => /* @__PURE__ */ React.createElement("div", { className: "hawa-flex hawa-flex-row hawa-justify-between" }, /* @__PURE__ */ React.createElement( "div", { ref, className: cn( "hawa-flex hawa-flex-col hawa-space-y-1.5 hawa-p-6", className ), ...props } ), props.actions && /* @__PURE__ */ React.createElement("div", { className: "hawa-p-6" }, props.actions)) ); var CardTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement( "h3", { ref, className: cn("hawa-text-2xl hawa-font-semibold", className), ...props } )); var CardDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement( "p", { ref, className: cn("hawa-text-sm hawa-text-muted-foreground", className), ...props } )); var CardContent = React.forwardRef( ({ headless, noPadding, className, ...props }, ref) => /* @__PURE__ */ React.createElement( "div", { ref, className: cn( noPadding ? "hawa-p-0" : "hawa-p-6", headless ? "hawa-pt-6" : "hawa-pt-0", className ), ...props } ) ); var CardFooter = React.forwardRef(({ className, noPadding, ...props }, ref) => /* @__PURE__ */ React.createElement( "div", { ref, className: cn( noPadding ? "hawa-p-0" : "hawa-p-6", "hawa-flex hawa-items-center hawa-pt-0", className ), ...props } )); CardDescription.displayName = "CardDescription"; CardContent.displayName = "CardContent"; CardHeader.displayName = "CardHeader"; CardFooter.displayName = "CardFooter"; CardTitle.displayName = "CardTitle"; Card.displayName = "Card"; // elements/skeleton/Skeleton.tsx import React2 from "react"; function Skeleton({ className, content, animation = "pulse", fade, ...props }) { const animationStyles = { none: "hawa-rounded hawa-bg-muted", pulse: "hawa-animate-pulse hawa-rounded hawa-bg-muted", shimmer: "hawa-space-y-5 hawa-rounded hawa-bg-muted hawa-p-4 hawa-relative before:hawa-absolute before:hawa-inset-0 before:hawa--translate-x-full before:hawa-animate-[shimmer_2s_infinite] before:hawa-bg-gradient-to-r before:hawa-from-transparent before:hawa-via-gray-300/40 dark:before:hawa-via-white/10 before:hawa-to-transparent hawa-isolate hawa-overflow-hidden before:hawa-border-t before:hawa-border-rose-100/10" }; const fadeStyle = { bottom: "hawa-mask-fade-bottom", top: "hawa-mask-fade-top", right: "hawa-mask-fade-right", left: "hawa-mask-fade-left " }; return /* @__PURE__ */ React2.createElement( "div", { className: cn( animationStyles[animation], content && "hawa-flex hawa-flex-col hawa-items-center hawa-justify-center", fade && fadeStyle[fade], className ), ...props }, content && content ); } // layout/stats/Stats.tsx var Stats = ({ label, icon, isLoading, number, helperText, helperTextColor = "default", chart, clickable, variant = "default", ...props }) => { let helperTextColorStyles = { default: "", positive: "hawa-text-green-600 dark:hawa-text-green-500", negative: "hawa-text-red-600 dark:hawa-text-red-500", muted: "hawa-text-muted-foreground" }; return /* @__PURE__ */ React3.createElement(Card, { ...props, clickable }, /* @__PURE__ */ React3.createElement("div", { className: "hawa-flex hawa-flex-row hawa-items-center hawa-justify-between hawa-p-4 hawa-px-6" }, /* @__PURE__ */ React3.createElement(CardTitle, { className: "hawa-text-sm hawa-font-medium" }, label), icon && /* @__PURE__ */ React3.createElement("span", null, icon)), /* @__PURE__ */ React3.createElement(CardContent, { className: "hawa-transition-all" }, isLoading ? /* @__PURE__ */ React3.createElement(Skeleton, { className: "hawa-h-8 hawa-w-3/4" }) : /* @__PURE__ */ React3.createElement("div", { className: "hawa-text-2xl hawa-font-bold" }, number), helperText && /* @__PURE__ */ React3.createElement( "div", { className: cn( "hawa-my-0 hawa-text-start hawa-text-xs hawa-transition-all", helperTextColorStyles[helperTextColor], helperText ? "hawa-h-4 hawa-opacity-100" : "hawa-h-0 hawa-opacity-0" ) }, isLoading ? /* @__PURE__ */ React3.createElement(Skeleton, { className: "hawa-mt-2 hawa-h-4 hawa-w-1/2" }) : helperText ), chart && (isLoading ? /* @__PURE__ */ React3.createElement(Skeleton, { className: "hawa-mt-2 hawa-h-4 hawa-w-1/2" }) : chart))); }; export { Stats }; //# sourceMappingURL=index.mjs.map