UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
fix: lint fix and button component updated
Arghya Dasafea8161c1cd
diff --git a/components/ui/button.tsx b/components/ui/button.tsxindex 25a56966..71b8142d 100644--- a/components/ui/button.tsx+++ b/components/ui/button.tsx@@ -1,11 +1,11 @@+import * as React from "react";import { Slot } from "@radix-ui/react-slot";import { cva, type VariantProps } from "class-variance-authority";-import * as React from "react";import { cn } from "@/lib/utils";const buttonVariants = cva(- "inline-flex items-center justify-center rounded-xl text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants: {variant: {@@ -38,7 +38,7 @@ const buttonVariants = cva(},);-interface ButtonProps+export interface ButtonPropsextends React.ButtonHTMLAttributes<HTMLButtonElement>,VariantProps<typeof buttonVariants> {asChild?: boolean;@@ -47,6 +47,7 @@ interface ButtonPropsconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(({ className, variant, size, asChild = false, ...props }, ref) => {const Comp = asChild ? Slot : "button";+return (<Compdata-slot="button"@@ -57,7 +58,6 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>();},);-Button.displayName = "Button";-export { Button, buttonVariants, type ButtonProps };+export { Button, buttonVariants };diff --git a/public/r/comic-text-demo.json b/public/r/comic-text-demo.jsonindex 7782df49..40aaca10 100644--- a/public/r/comic-text-demo.json+++ b/public/r/comic-text-demo.json@@ -10,7 +10,7 @@"files": [{"path": "registry/example/comic-text-demo.tsx",- "content": "import { ComicText } from \"@/registry/magicui/comic-text\";\n\nexport default function ComicTextDemo() {\n return (\n <div className=\"space-y-8 text-center\">\n <ComicText fontSize={5}> \n BOOM!\n </ComicText>\n </div>\n );\n}\n",+ "content": "import { ComicText } from \"@/registry/magicui/comic-text\";\n\nexport default function ComicTextDemo() {\n return (\n <div className=\"space-y-8 text-center\">\n <ComicText fontSize={5}>BOOM!</ComicText>\n </div>\n );\n}\n","type": "registry:example","target": "components/comic-text-demo.tsx"}diff --git a/public/r/comic-text.json b/public/r/comic-text.jsonindex e284fa7b..49895ab3 100644--- a/public/r/comic-text.json+++ b/public/r/comic-text.json@@ -10,7 +10,7 @@"files": [{"path": "registry/magicui/comic-text.tsx",- "content": "\"use client\";\nimport { cn } from \"@/lib/utils\";\nimport { motion } from \"motion/react\";\nimport { CSSProperties } from \"react\";\n\ntype ComicTextProps = {\n children: string;\n className?: string;\n style?: CSSProperties;\n fontSize?: number;\n};\n\nexport function ComicText({\n children,\n className,\n style,\n fontSize = 5,\n}: ComicTextProps) {\n if (typeof children !== \"string\") {\n throw new Error(\"children must be a string\");\n }\n\n return (\n <motion.div\n className={cn(\n \"select-none text-center\",\n className\n )}\n style={{\n fontSize: `${fontSize}rem`,\n fontFamily: \"'Bangers', 'Comic Sans MS', 'Impact', sans-serif\",\n fontWeight: \"900\",\n WebkitTextStroke: `${fontSize * 0.35}px #000000`, // Thick black outline\n transform: \"skewX(-10deg)\",\n textTransform: \"uppercase\",\n filter: `\n drop-shadow(5px 5px 0px #000000) \n drop-shadow(3px 3px 0px #B71C1C)\n `,\n backgroundColor: \"#FDE601\",\n backgroundImage:\n \"radial-gradient(circle at 1px 1px, #B71C1C 1px, transparent 0)\",\n backgroundSize: \"8px 8px\",\n backgroundClip: \"text\",\n WebkitBackgroundClip: \"text\",\n WebkitTextFillColor: \"transparent\",\n ...style,\n }}\n initial={{ opacity: 0, scale: 0.8, rotate: -2 }}\n animate={{ opacity: 1, scale: 1, rotate: 0 }}\n transition={{ \n duration: 0.6, \n ease: [0.175, 0.885, 0.32, 1.275],\n type: \"spring\"\n }}\n >\n {children}\n </motion.div>\n );\n}\n",+ "content": "\"use client\";\nimport { cn } from \"@/lib/utils\";\nimport { motion } from \"motion/react\";\nimport { CSSProperties } from \"react\";\n\ntype ComicTextProps = {\n children: string;\n className?: string;\n style?: CSSProperties;\n fontSize?: number;\n};\n\nexport function ComicText({\n children,\n className,\n style,\n fontSize = 5,\n}: ComicTextProps) {\n if (typeof children !== \"string\") {\n throw new Error(\"children must be a string\");\n }\n\n const dotColor = \"#EF4444\";\n const backgroundColor = \"#FACC15\";\n\n return (\n <motion.div\n className={cn(\"select-none text-center\", className)}\n style={{\n fontSize: `${fontSize}rem`,\n fontFamily: \"'Bangers', 'Comic Sans MS', 'Impact', sans-serif\",\n fontWeight: \"900\",\n WebkitTextStroke: `${fontSize * 0.35}px #000000`, // Thick black outline\n transform: \"skewX(-10deg)\",\n textTransform: \"uppercase\",\n filter: `\n drop-shadow(5px 5px 0px #000000) \n drop-shadow(3px 3px 0px ${dotColor})\n `,\n backgroundColor: backgroundColor,\n backgroundImage: `radial-gradient(circle at 1px 1px, ${dotColor} 1px, transparent 0)`,\n backgroundSize: \"8px 8px\",\n backgroundClip: \"text\",\n WebkitBackgroundClip: \"text\",\n WebkitTextFillColor: \"transparent\",\n ...style,\n }}\n initial={{ opacity: 0, scale: 0.8, rotate: -2 }}\n animate={{ opacity: 1, scale: 1, rotate: 0 }}\n transition={{\n duration: 0.6,\n ease: [0.175, 0.885, 0.32, 1.275],\n type: \"spring\",\n }}\n >\n {children}\n </motion.div>\n );\n}\n","type": "registry:ui","target": "components/magicui/comic-text.tsx"}diff --git a/public/r/pixel-image-demo.json b/public/r/pixel-image-demo.jsonindex 8b7559d0..4ac935a3 100644--- a/public/r/pixel-image-demo.json+++ b/public/r/pixel-image-demo.json@@ -10,7 +10,7 @@"files": [{"path": "registry/example/pixel-image-demo.tsx",- "content": "import PixelImage from \"@/registry/magicui/pixel-image\";\n\nexport default function Home() {\n return (\n <div>\n <PixelImage\n src=\"/pixel-image-demo.jpg\"\n customGrid={{ rows: 4, cols: 6 }}\n grayscaleAnimation={true}\n />\n </div>\n );\n}\n",+ "content": "import { PixelImage } from \"@/registry/magicui/pixel-image\";\n\nexport default function Home() {\n return (\n <PixelImage\n src=\"/pixel-image-demo.jpg\"\n customGrid={{ rows: 4, cols: 6 }}\n grayscaleAnimation\n />\n );\n}\n","type": "registry:example","target": "components/pixel-image-demo.tsx"}diff --git a/public/r/pixel-image.json b/public/r/pixel-image.jsonindex c2a1fe38..7f8bb34a 100644--- a/public/r/pixel-image.json+++ b/public/r/pixel-image.json@@ -7,7 +7,7 @@"files": [{"path": "registry/magicui/pixel-image.tsx",- "content": "\"use client\";\nimport { cn } from \"@/lib/utils\";\nimport Image from \"next/image\";\nimport { memo, useEffect, useMemo, useState } from \"react\";\n\ntype Grid = {\n rows: number;\n cols: number;\n};\n\nconst DEFAULT_GRIDS: Record<string, Grid> = {\n \"6x4\": { rows: 4, cols: 6 },\n \"8x8\": { rows: 8, cols: 8 },\n \"8x3\": { rows: 3, cols: 8 },\n \"4x6\": { rows: 6, cols: 4 },\n \"3x8\": { rows: 8, cols: 3 },\n};\n\ntype PredefinedGridKey = keyof typeof DEFAULT_GRIDS;\n\ninterface PixelImageProps {\n src: string;\n grid?: PredefinedGridKey;\n customGrid?: Grid;\n grayscaleAnimation?: boolean;\n pixelFadeInDuration?: number; // in ms\n maxAnimationDelay?: number; // in ms\n colorRevealDelay?: number; // in ms\n}\n\nconst PixelImage = ({\n src,\n grid = \"6x4\",\n grayscaleAnimation = true,\n pixelFadeInDuration = 1000,\n maxAnimationDelay = 1200,\n colorRevealDelay = 1300,\n customGrid,\n}: PixelImageProps) => {\n const [isVisible, setIsVisible] = useState(false);\n const [showColor, setShowColor] = useState(false);\n\n const MIN_GRID = 1;\n const MAX_GRID = 16;\n\n const { rows, cols } = useMemo(() => {\n const isValidGrid = (grid?: Grid) => {\n if (!grid) return false;\n const { rows, cols } = grid;\n return (\n Number.isInteger(rows) &&\n Number.isInteger(cols) &&\n rows >= MIN_GRID &&\n cols >= MIN_GRID &&\n rows <= MAX_GRID &&\n cols <= MAX_GRID\n );\n };\n\n return isValidGrid(customGrid) ? customGrid! : DEFAULT_GRIDS[grid];\n }, [customGrid, grid]);\n\n useEffect(() => {\n setIsVisible(true);\n const colorTimeout = setTimeout(() => {\n setShowColor(true);\n }, colorRevealDelay);\n return () => clearTimeout(colorTimeout);\n }, [colorRevealDelay]);\n\n const pieces = useMemo(() => {\n const total = rows * cols;\n return Array.from({ length: total }, (_, index) => {\n const row = Math.floor(index / cols);\n const col = index % cols;\n\n const clipPath = `polygon(\n ${col * (100 / cols)}% ${row * (100 / rows)}%,\n ${(col + 1) * (100 / cols)}% ${row * (100 / rows)}%,\n ${(col + 1) * (100 / cols)}% ${(row + 1) * (100 / rows)}%,\n ${col * (100 / cols)}% ${(row + 1) * (100 / rows)}%\n )`;\n\n const delay = Math.random() * maxAnimationDelay;\n return {\n clipPath,\n delay,\n };\n });\n }, [rows, cols, maxAnimationDelay]);\n\n return (\n <div className=\"relative h-72 w-72 select-none md:h-96 md:w-96\">\n {pieces.map((piece, index) => (\n <div\n key={index}\n className={cn(\n \"absolute inset-0 transition-all ease-out\",\n isVisible ? \"opacity-100\" : \"opacity-0\",\n )}\n style={{\n clipPath: piece.clipPath,\n transitionDelay: `${piece.delay}ms`,\n transitionDuration: `${pixelFadeInDuration}ms`,\n }}\n >\n <Image\n src={src}\n fill\n alt={`Pixel image piece ${index + 1}`}\n className={cn(\n \"z-1 object-cover rounded-[2.5rem]\",\n grayscaleAnimation && (showColor ? \"grayscale-0\" : \"grayscale\"),\n )}\n style={{\n transition: grayscaleAnimation\n ? `filter ${pixelFadeInDuration}ms cubic-bezier(0.4, 0, 0.2, 1)`\n : \"none\",\n }}\n draggable={false}\n />\n </div>\n ))}\n </div>\n );\n};\n\nexport default memo(PixelImage);\n",+ "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { useEffect, useMemo, useState } from \"react\";\n\ntype Grid = {\n rows: number;\n cols: number;\n};\n\nconst DEFAULT_GRIDS: Record<string, Grid> = {\n \"6x4\": { rows: 4, cols: 6 },\n \"8x8\": { rows: 8, cols: 8 },\n \"8x3\": { rows: 3, cols: 8 },\n \"4x6\": { rows: 6, cols: 4 },\n \"3x8\": { rows: 8, cols: 3 },\n};\n\ntype PredefinedGridKey = keyof typeof DEFAULT_GRIDS;\n\ninterface PixelImageProps {\n src: string;\n grid?: PredefinedGridKey;\n customGrid?: Grid;\n grayscaleAnimation?: boolean;\n pixelFadeInDuration?: number; // in ms\n maxAnimationDelay?: number; // in ms\n colorRevealDelay?: number; // in ms\n}\n\nexport const PixelImage = ({\n src,\n grid = \"6x4\",\n grayscaleAnimation = true,\n pixelFadeInDuration = 1000,\n maxAnimationDelay = 1200,\n colorRevealDelay = 1300,\n customGrid,\n}: PixelImageProps) => {\n const [isVisible, setIsVisible] = useState(false);\n const [showColor, setShowColor] = useState(false);\n\n const MIN_GRID = 1;\n const MAX_GRID = 16;\n\n const { rows, cols } = useMemo(() => {\n const isValidGrid = (grid?: Grid) => {\n if (!grid) return false;\n const { rows, cols } = grid;\n return (\n Number.isInteger(rows) &&\n Number.isInteger(cols) &&\n rows >= MIN_GRID &&\n cols >= MIN_GRID &&\n rows <= MAX_GRID &&\n cols <= MAX_GRID\n );\n };\n\n return isValidGrid(customGrid) ? customGrid! : DEFAULT_GRIDS[grid];\n }, [customGrid, grid]);\n\n useEffect(() => {\n setIsVisible(true);\n const colorTimeout = setTimeout(() => {\n setShowColor(true);\n }, colorRevealDelay);\n return () => clearTimeout(colorTimeout);\n }, [colorRevealDelay]);\n\n const pieces = useMemo(() => {\n const total = rows * cols;\n return Array.from({ length: total }, (_, index) => {\n const row = Math.floor(index / cols);\n const col = index % cols;\n\n const clipPath = `polygon(\n ${col * (100 / cols)}% ${row * (100 / rows)}%,\n ${(col + 1) * (100 / cols)}% ${row * (100 / rows)}%,\n ${(col + 1) * (100 / cols)}% ${(row + 1) * (100 / rows)}%,\n ${col * (100 / cols)}% ${(row + 1) * (100 / rows)}%\n )`;\n\n const delay = Math.random() * maxAnimationDelay;\n return {\n clipPath,\n delay,\n };\n });\n }, [rows, cols, maxAnimationDelay]);\n\n return (\n <div className=\"relative h-72 w-72 select-none md:h-96 md:w-96\">\n {pieces.map((piece, index) => (\n <div\n key={index}\n className={cn(\n \"absolute inset-0 transition-all ease-out\",\n isVisible ? \"opacity-100\" : \"opacity-0\",\n )}\n style={{\n clipPath: piece.clipPath,\n transitionDelay: `${piece.delay}ms`,\n transitionDuration: `${pixelFadeInDuration}ms`,\n }}\n >\n <img\n src={src}\n alt={`Pixel image piece ${index + 1}`}\n className={cn(\n \"z-1 object-cover rounded-[2.5rem]\",\n grayscaleAnimation && (showColor ? \"grayscale-0\" : \"grayscale\"),\n )}\n style={{\n transition: grayscaleAnimation\n ? `filter ${pixelFadeInDuration}ms cubic-bezier(0.4, 0, 0.2, 1)`\n : \"none\",\n }}\n draggable={false}\n />\n </div>\n ))}\n </div>\n );\n};\n","type": "registry:ui","target": "components/magicui/pixel-image.tsx"}