{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "comp-310",
  "type": "registry:component",
  "title": "Comp 310",
  "description": "Comp 310",
  "files": [
    {
      "path": "registry/ui-basic/comp-310.tsx",
      "content": "\"use client\";\r\n\r\nimport { useEffect, useState } from \"react\";\r\n\r\nimport { Button } from \"@/components/ui/button\";\r\nimport { TicketPercent, XIcon } from \"lucide-react\";\r\n\r\n// Define the sale end date - eg: new Date('2024-12-31T23:59:59');\r\nconst saleEndDate = new Date(\r\n\tDate.now() + 9 * 60 * 60 * 1000 + 45 * 60 * 1000 + 24 * 1000\r\n); // Setting 9h 45m 24s from now for demo purposes\r\n\r\ninterface TimeLeft {\r\n\tdays: number;\r\n\thours: number;\r\n\tminutes: number;\r\n\tseconds: number;\r\n\tisExpired: boolean;\r\n}\r\n\r\nexport default function Component() {\r\n\tconst [isVisible, setIsVisible] = useState(true);\r\n\tconst [timeLeft, setTimeLeft] = useState<TimeLeft>({\r\n\t\tdays: 0,\r\n\t\thours: 0,\r\n\t\tminutes: 0,\r\n\t\tseconds: 0,\r\n\t\tisExpired: false,\r\n\t});\r\n\r\n\tuseEffect(() => {\r\n\t\tconst calculateTimeLeft = () => {\r\n\t\t\tconst now = new Date();\r\n\t\t\tconst difference = saleEndDate.getTime() - now.getTime();\r\n\r\n\t\t\tif (difference <= 0) {\r\n\t\t\t\tsetTimeLeft({\r\n\t\t\t\t\tdays: 0,\r\n\t\t\t\t\thours: 0,\r\n\t\t\t\t\tminutes: 0,\r\n\t\t\t\t\tseconds: 0,\r\n\t\t\t\t\tisExpired: true,\r\n\t\t\t\t});\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst days = Math.floor(difference / (1000 * 60 * 60 * 24));\r\n\t\t\tconst hours = Math.floor(\r\n\t\t\t\t(difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)\r\n\t\t\t);\r\n\t\t\tconst minutes = Math.floor(\r\n\t\t\t\t(difference % (1000 * 60 * 60)) / (1000 * 60)\r\n\t\t\t);\r\n\t\t\tconst seconds = Math.floor((difference % (1000 * 60)) / 1000);\r\n\r\n\t\t\tsetTimeLeft({\r\n\t\t\t\tdays,\r\n\t\t\t\thours,\r\n\t\t\t\tminutes,\r\n\t\t\t\tseconds,\r\n\t\t\t\tisExpired: false,\r\n\t\t\t});\r\n\t\t};\r\n\r\n\t\t// Calculate immediately and then every second\r\n\t\tcalculateTimeLeft();\r\n\t\tconst timer = setInterval(calculateTimeLeft, 1000);\r\n\r\n\t\treturn () => clearInterval(timer);\r\n\t}, []);\r\n\r\n\tif (!isVisible || timeLeft.isExpired) return null;\r\n\r\n\treturn (\r\n\t\t<div className=\"dark bg-muted text-foreground px-4 py-3\">\r\n\t\t\t<div className=\"flex gap-2 md:items-center\">\r\n\t\t\t\t<div className=\"flex grow gap-3 md:items-center\">\r\n\t\t\t\t\t<div\r\n\t\t\t\t\t\tclassName=\"bg-primary/15 flex size-9 shrink-0 items-center justify-center rounded-full max-md:mt-0.5\"\r\n\t\t\t\t\t\taria-hidden=\"true\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<TicketPercent className=\"opacity-80\" size={16} />\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div className=\"flex grow flex-col justify-between gap-3 md:flex-row md:items-center\">\r\n\t\t\t\t\t\t<div className=\"space-y-0.5\">\r\n\t\t\t\t\t\t\t<p className=\"text-sm font-medium\">Black Friday Sale!</p>\r\n\t\t\t\t\t\t\t<p className=\"text-muted-foreground text-sm\">\r\n\t\t\t\t\t\t\t\tIt kicks off today and is available for just 24\r\n\t\t\t\t\t\t\t\thours—don&lsquo;t miss out!\r\n\t\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div className=\"flex gap-3 max-md:flex-wrap\">\r\n\t\t\t\t\t\t\t<div className=\"divide-primary-foreground bg-primary/15 flex items-center divide-x rounded-md text-sm tabular-nums\">\r\n\t\t\t\t\t\t\t\t{timeLeft.days > 0 && (\r\n\t\t\t\t\t\t\t\t\t<span className=\"flex h-8 items-center justify-center p-2\">\r\n\t\t\t\t\t\t\t\t\t\t{timeLeft.days}\r\n\t\t\t\t\t\t\t\t\t\t<span className=\"text-muted-foreground\">d</span>\r\n\t\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t)}\r\n\t\t\t\t\t\t\t\t<span className=\"flex h-8 items-center justify-center p-2\">\r\n\t\t\t\t\t\t\t\t\t{timeLeft.hours.toString().padStart(2, \"0\")}\r\n\t\t\t\t\t\t\t\t\t<span className=\"text-muted-foreground\">h</span>\r\n\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t<span className=\"flex h-8 items-center justify-center p-2\">\r\n\t\t\t\t\t\t\t\t\t{timeLeft.minutes.toString().padStart(2, \"0\")}\r\n\t\t\t\t\t\t\t\t\t<span className=\"text-muted-foreground\">m</span>\r\n\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t\t<span className=\"flex h-8 items-center justify-center p-2\">\r\n\t\t\t\t\t\t\t\t\t{timeLeft.seconds.toString().padStart(2, \"0\")}\r\n\t\t\t\t\t\t\t\t\t<span className=\"text-muted-foreground\">s</span>\r\n\t\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<Button size=\"sm\" className=\"text-sm\">\r\n\t\t\t\t\t\t\t\tBuy now\r\n\t\t\t\t\t\t\t</Button>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t<Button\r\n\t\t\t\t\tvariant=\"ghost\"\r\n\t\t\t\t\tclassName=\"group -my-1.5 -me-2 size-8 shrink-0 p-0 hover:bg-transparent\"\r\n\t\t\t\t\tonClick={() => setIsVisible(false)}\r\n\t\t\t\t\taria-label=\"Close banner\"\r\n\t\t\t\t>\r\n\t\t\t\t\t<XIcon\r\n\t\t\t\t\t\tsize={16}\r\n\t\t\t\t\t\tclassName=\"opacity-60 transition-opacity group-hover:opacity-100\"\r\n\t\t\t\t\t\taria-hidden=\"true\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</Button>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t);\r\n}\r\n",
      "type": "registry:ui"
    },
    {
      "path": "components/ui/button.tsx",
      "content": "import * as React from \"react\";\r\n\r\nimport { cn } from \"@/registry/utilities/cn\";\r\nimport { Slot } from \"@radix-ui/react-slot\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\n\r\nconst buttonVariants = cva(\r\n\t\"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm text-white hover:text-gray-400 font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50\",\r\n\t{\r\n\t\tvariants: {\r\n\t\t\tvariant: {\r\n\t\t\t\tsimple:\r\n\t\t\t\t\t\"bg-secondary relative z-10 bg-transparent hover:border-secondary hover:bg-secondary/50  border border-transparent dark:text-white text-sm md:text-sm transition font-medium duration-200  rounded-md px-4 py-2  flex items-center justify-center\",\r\n\t\t\t\tdefault: \"bg-primary text-primary-foreground hover:bg-primary/90\",\r\n\t\t\t\tdestructive:\r\n\t\t\t\t\t\"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\r\n\t\t\t\toutline:\r\n\t\t\t\t\t\"border border-input bg-background hover:bg-accent hover:text-accent-foreground\",\r\n\t\t\t\tsecondary:\r\n\t\t\t\t\t\"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\r\n\t\t\t\tghost: \"hover:bg-accent hover:text-black hover:stroke-black dark:text-white text-black\",\r\n\t\t\t\tlink: \"text-primary underline-offset-4 hover:underline\",\r\n\t\t\t},\r\n\t\t\tsize: {\r\n\t\t\t\tdefault: \"h-10 px-4 py-2\",\r\n\t\t\t\tsm: \"h-9 rounded-md px-3\",\r\n\t\t\t\tlg: \"h-11 rounded-md px-8\",\r\n\t\t\t\ticon: \"h-10 w-10\",\r\n\t\t\t},\r\n\t\t},\r\n\t\tdefaultVariants: {\r\n\t\t\tvariant: \"default\",\r\n\t\t\tsize: \"default\",\r\n\t\t},\r\n\t}\r\n);\r\n\r\nexport interface ButtonProps\r\n\textends React.ButtonHTMLAttributes<HTMLButtonElement>,\r\n\t\tVariantProps<typeof buttonVariants> {\r\n\tasChild?: boolean;\r\n}\r\n\r\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\r\n\t({ className, variant, size, asChild = false, ...props }, ref) => {\r\n\t\tconst Comp = asChild ? Slot : \"button\";\r\n\t\treturn (\r\n\t\t\t<Comp\r\n\t\t\t\tclassName={cn(buttonVariants({ variant, size, className }))}\r\n\t\t\t\tref={ref}\r\n\t\t\t\t{...props}\r\n\t\t\t/>\r\n\t\t);\r\n\t}\r\n);\r\nButton.displayName = \"Button\";\r\n\r\nexport { Button, buttonVariants };\r\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/utilities/cn.ts",
      "content": "import { ClassValue, clsx } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n\treturn twMerge(clsx(inputs));\r\n}\r\n",
      "type": "registry:ui"
    }
  ]
}