UNPKG

@sikka/hawa

Version:

Modern UI Kit made with Tailwind

181 lines (177 loc) • 5.96 kB
"use client"; // elements/destroyableCard/DestroyableCard.tsx import React2, { useRef, useState } 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/destroyableCard/DestroyableCard.tsx var DestroyableCard = ({ position = "bottom-right", fixed, direction, ...props }) => { const [closed, setClosed] = useState(false); const popUpRef = useRef(null); const boxPosition = { "bottom-right": "hawa-right-4 hawa-bottom-4", "bottom-left": "hawa-left-4 hawa-bottom-4" }; return /* @__PURE__ */ React2.createElement( "div", { className: cn( "hawa-transition-all", closed ? "hawa-opacity-0" : "hawa-opacity-100" ), ref: popUpRef }, /* @__PURE__ */ React2.createElement( Card, { className: cn( fixed ? "hawa-fixed" : "hawa-relative", fixed && position && boxPosition[position] ), dir: direction }, /* @__PURE__ */ React2.createElement( "button", { type: "button", className: cn( direction === "rtl" ? "hawa-left-2" : "hawa-right-2", "hawa-absolute hawa-top-2 hawa-inline-flex hawa-h-8 hawa-w-8 hawa-rounded hawa-p-1.5 hawa-text-gray-400 hawa-transition-all hover:hawa-bg-gray-100 hover:hawa-text-gray-900 focus:hawa-ring-2 focus:hawa-ring-gray-300 dark:hawa-bg-gray-800 dark:hawa-text-gray-500 dark:hover:hawa-bg-gray-700 dark:hover:hawa-text-white" ), "data-dismiss-target": "#destroyable-card", "aria-label": "Close", onClick: () => { setClosed(true); setTimeout(() => { if (popUpRef == null ? void 0 : popUpRef.current) { popUpRef == null ? void 0 : popUpRef.current.removeChild(popUpRef == null ? void 0 : popUpRef.current.children[0]); } }, 200); } }, /* @__PURE__ */ React2.createElement( "svg", { "aria-hidden": "true", className: "hawa-h-5 hawa-w-5", fill: "currentColor", viewBox: "0 0 20 20" }, /* @__PURE__ */ React2.createElement( "path", { fillRule: "evenodd", d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z", clipRule: "evenodd" } ) ) ), /* @__PURE__ */ React2.createElement(CardContent, { headless: true }, props.children) ) ); }; export { DestroyableCard }; //# sourceMappingURL=index.mjs.map