Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: added the iphone 15 pro with video in mdx

Arghya Das91a108042afa
diff --git a/content/docs/components/iphone-15-pro.mdx b/content/docs/components/iphone-15-pro.mdx
index 5cb5f79a..68dfa41b 100644
--- a/content/docs/components/iphone-15-pro.mdx
+++ b/content/docs/components/iphone-15-pro.mdx
@@ -46,12 +46,17 @@ npx shadcn@latest add "https://magicui.design/r/iphone-15-pro"
<ComponentPreview name="iphone-15-pro-demo-2" />
+### With Video
+
+<ComponentPreview name="iphone-15-pro-demo-3" />
+
## Props
-| Prop | Type | Description | Default |
-| ------ | ------ | -------------------------------------- | ------- |
-| width | number | The width of the iPhone 15 Pro window | 433 |
-| height | number | The height of the iPhone 15 Pro window | 882 |
-| src | string | The source of the image to display | |
+| Prop | Type | Description | Default |
+| -------- | ------ | -------------------------------------- | ------- |
+| width | number | The width of the iPhone 15 Pro window | 433 |
+| height | number | The height of the iPhone 15 Pro window | 882 |
+| src | string | The source of the image to display | |
+| videoSrc | string | The source of the video to display | |
The `Iphone15Pro` component also accepts all properties of the `SVGElement` type.
diff --git a/public/r/index.json b/public/r/index.json
index f15c95cc..95364329 100644
--- a/public/r/index.json
+++ b/public/r/index.json
@@ -475,7 +475,7 @@
"name": "hyper-text",
"type": "registry:ui",
"dependencies": [
- "framer-motion"
+ "motion"
],
"files": [
{
@@ -595,6 +595,9 @@
{
"name": "typing-animation",
"type": "registry:ui",
+ "dependencies": [
+ "motion"
+ ],
"files": [
{
"path": "magicui/typing-animation.tsx",
diff --git a/public/r/styles/default/confetti.json b/public/r/styles/default/confetti.json
index 49db4243..22172ee2 100644
--- a/public/r/styles/default/confetti.json
+++ b/public/r/styles/default/confetti.json
@@ -8,7 +8,7 @@
"files": [
{
"path": "magicui/confetti.tsx",
- "content": "import type { ReactNode } from \"react\";\nimport React, {\n createContext,\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type {\n GlobalOptions as ConfettiGlobalOptions,\n CreateTypes as ConfettiInstance,\n Options as ConfettiOptions,\n} from \"canvas-confetti\";\nimport confetti from \"canvas-confetti\";\n\nimport { Button, ButtonProps } from \"@/components/ui/button\";\n\ntype Api = {\n fire: (options?: ConfettiOptions) => void;\n};\n\ntype Props = React.ComponentPropsWithRef<\"canvas\"> & {\n options?: ConfettiOptions;\n globalOptions?: ConfettiGlobalOptions;\n manualstart?: boolean;\n children?: ReactNode;\n};\n\nexport type ConfettiRef = Api | null;\n\nconst ConfettiContext = createContext<Api>({} as Api);\n\nconst Confetti = forwardRef<ConfettiRef, Props>((props, ref) => {\n const {\n options,\n globalOptions = { resize: true, useWorker: true },\n manualstart = false,\n children,\n ...rest\n } = props;\n const instanceRef = useRef<ConfettiInstance | null>(null); // confetti instance\n\n const canvasRef = useCallback(\n // https://react.dev/reference/react-dom/components/common#ref-callback\n // https://reactjs.org/docs/refs-and-the-dom.html#callback-refs\n (node: HTMLCanvasElement) => {\n if (node !== null) {\n // <canvas> is mounted => create the confetti instance\n if (instanceRef.current) return; // if not already created\n instanceRef.current = confetti.create(node, {\n ...globalOptions,\n resize: true,\n });\n } else {\n // <canvas> is unmounted => reset and destroy instanceRef\n if (instanceRef.current) {\n instanceRef.current.reset();\n instanceRef.current = null;\n }\n }\n },\n [globalOptions],\n );\n\n // `fire` is a function that calls the instance() with `opts` merged with `options`\n const fire = useCallback(\n (opts = {}) => instanceRef.current?.({ ...options, ...opts }),\n [options],\n );\n\n const api = useMemo(\n () => ({\n fire,\n }),\n [fire],\n );\n\n useImperativeHandle(ref, () => api, [api]);\n\n useEffect(() => {\n if (!manualstart) {\n fire();\n }\n }, [manualstart, fire]);\n\n return (\n <ConfettiContext.Provider value={api}>\n <canvas ref={canvasRef} {...rest} />\n {children}\n </ConfettiContext.Provider>\n );\n});\n\ninterface ConfettiButtonProps extends ButtonProps {\n options?: ConfettiOptions &\n ConfettiGlobalOptions & { canvas?: HTMLCanvasElement };\n children?: React.ReactNode;\n}\n\nfunction ConfettiButton({ options, children, ...props }: ConfettiButtonProps) {\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n const rect = event.currentTarget.getBoundingClientRect();\n const x = rect.left + rect.width / 2;\n const y = rect.top + rect.height / 2;\n confetti({\n ...options,\n origin: {\n x: x / window.innerWidth,\n y: y / window.innerHeight,\n },\n });\n };\n\n return (\n <Button onClick={handleClick} {...props}>\n {children}\n </Button>\n );\n}\n\nConfetti.displayName = \"Confetti\";\n\nexport { Confetti, ConfettiButton };\n\nexport default Confetti;\n",
+ "content": "import type { ReactNode } from \"react\";\nimport React, {\n createContext,\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type {\n GlobalOptions as ConfettiGlobalOptions,\n CreateTypes as ConfettiInstance,\n Options as ConfettiOptions,\n} from \"canvas-confetti\";\nimport confetti from \"canvas-confetti\";\n\nimport { Button, ButtonProps } from \"@/components/ui/button\";\n\ntype Api = {\n fire: (options?: ConfettiOptions) => void;\n};\n\ntype Props = React.ComponentPropsWithRef<\"canvas\"> & {\n options?: ConfettiOptions;\n globalOptions?: ConfettiGlobalOptions;\n manualstart?: boolean;\n children?: ReactNode;\n};\n\nexport type ConfettiRef = Api | null;\n\nconst ConfettiContext = createContext<Api>({} as Api);\n\n// Define component first\nconst ConfettiComponent = forwardRef<ConfettiRef, Props>((props, ref) => {\n const {\n options,\n globalOptions = { resize: true, useWorker: true },\n manualstart = false,\n children,\n ...rest\n } = props;\n const instanceRef = useRef<ConfettiInstance | null>(null);\n\n const canvasRef = useCallback(\n (node: HTMLCanvasElement) => {\n if (node !== null) {\n if (instanceRef.current) return;\n instanceRef.current = confetti.create(node, {\n ...globalOptions,\n resize: true,\n });\n } else {\n if (instanceRef.current) {\n instanceRef.current.reset();\n instanceRef.current = null;\n }\n }\n },\n [globalOptions],\n );\n\n const fire = useCallback(\n async (opts = {}) => {\n try {\n await instanceRef.current?.({ ...options, ...opts });\n } catch (error) {\n console.error(\"Confetti error:\", error);\n }\n },\n [options],\n );\n\n const api = useMemo(\n () => ({\n fire,\n }),\n [fire],\n );\n\n useImperativeHandle(ref, () => api, [api]);\n\n useEffect(() => {\n if (!manualstart) {\n (async () => {\n try {\n await fire();\n } catch (error) {\n console.error(\"Confetti effect error:\", error);\n }\n })();\n }\n }, [manualstart, fire]);\n\n return (\n <ConfettiContext.Provider value={api}>\n <canvas ref={canvasRef} {...rest} />\n {children}\n </ConfettiContext.Provider>\n );\n});\n\n// Set display name immediately\nConfettiComponent.displayName = \"Confetti\";\n\n// Export as Confetti\nexport const Confetti = ConfettiComponent;\n\ninterface ConfettiButtonProps extends ButtonProps {\n options?: ConfettiOptions &\n ConfettiGlobalOptions & { canvas?: HTMLCanvasElement };\n children?: React.ReactNode;\n}\n\nconst ConfettiButtonComponent = ({\n options,\n children,\n ...props\n}: ConfettiButtonProps) => {\n const handleClick = async (event: React.MouseEvent<HTMLButtonElement>) => {\n try {\n const rect = event.currentTarget.getBoundingClientRect();\n const x = rect.left + rect.width / 2;\n const y = rect.top + rect.height / 2;\n await confetti({\n ...options,\n origin: {\n x: x / window.innerWidth,\n y: y / window.innerHeight,\n },\n });\n } catch (error) {\n console.error(\"Confetti button error:\", error);\n }\n };\n\n return (\n <Button onClick={handleClick} {...props}>\n {children}\n </Button>\n );\n};\n\nConfettiButtonComponent.displayName = \"ConfettiButton\";\n\nexport const ConfettiButton = ConfettiButtonComponent;\n\nexport default Confetti;\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/dock.json b/public/r/styles/default/dock.json
index 7688592b..4644bf28 100644
--- a/public/r/styles/default/dock.json
+++ b/public/r/styles/default/dock.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "magicui/dock.tsx",
- "content": "\"use client\";\n\nimport React, { PropsWithChildren, useRef } from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { motion, useMotionValue, useSpring, useTransform } from \"framer-motion\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface DockProps extends VariantProps<typeof dockVariants> {\n className?: string;\n magnification?: number;\n distance?: number;\n direction?: \"top\" | \"middle\" | \"bottom\";\n children: React.ReactNode;\n}\n\nconst DEFAULT_MAGNIFICATION = 60;\nconst DEFAULT_DISTANCE = 140;\n\nconst dockVariants = cva(\n \"supports-backdrop-blur:bg-white/10 supports-backdrop-blur:dark:bg-black/10 mx-auto mt-8 flex h-[58px] w-max gap-2 rounded-2xl border p-2 backdrop-blur-md\",\n);\n\nconst Dock = React.forwardRef<HTMLDivElement, DockProps>(\n (\n {\n className,\n children,\n magnification = DEFAULT_MAGNIFICATION,\n distance = DEFAULT_DISTANCE,\n direction = \"bottom\",\n ...props\n },\n ref,\n ) => {\n const mouseX = useMotionValue(Infinity);\n\n const renderChildren = () => {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.type === DockIcon) {\n return React.cloneElement(child, {\n ...child.props,\n mouseX: mouseX,\n magnification: magnification,\n distance: distance,\n });\n }\n return child;\n });\n };\n\n return (\n <motion.div\n ref={ref}\n onMouseMove={(e) => mouseX.set(e.pageX)}\n onMouseLeave={() => mouseX.set(Infinity)}\n {...props}\n className={cn(dockVariants({ className }), {\n \"items-start\": direction === \"top\",\n \"items-center\": direction === \"middle\",\n \"items-end\": direction === \"bottom\",\n })}\n >\n {renderChildren()}\n </motion.div>\n );\n },\n);\n\nDock.displayName = \"Dock\";\n\nexport interface DockIconProps {\n size?: number;\n magnification?: number;\n distance?: number;\n mouseX?: any;\n className?: string;\n children?: React.ReactNode;\n props?: PropsWithChildren;\n}\n\nconst DockIcon = ({\n size,\n magnification = DEFAULT_MAGNIFICATION,\n distance = DEFAULT_DISTANCE,\n mouseX,\n className,\n children,\n ...props\n}: DockIconProps) => {\n const ref = useRef<HTMLDivElement>(null);\n\n const distanceCalc = useTransform(mouseX, (val: number) => {\n const bounds = ref.current?.getBoundingClientRect() ?? { x: 0, width: 0 };\n\n return val - bounds.x - bounds.width / 2;\n });\n\n const widthSync = useTransform(\n distanceCalc,\n [-distance, 0, distance],\n [40, magnification, 40],\n );\n\n const width = useSpring(widthSync, {\n mass: 0.1,\n stiffness: 150,\n damping: 12,\n });\n\n return (\n <motion.div\n ref={ref}\n style={{ width }}\n className={cn(\n \"flex aspect-square cursor-pointer items-center justify-center rounded-full\",\n className,\n )}\n {...props}\n >\n {children}\n </motion.div>\n );\n};\n\nDockIcon.displayName = \"DockIcon\";\n\nexport { Dock, DockIcon, dockVariants };\n",
+ "content": "\"use client\";\n\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport {\n motion,\n MotionProps,\n useMotionValue,\n useSpring,\n useTransform,\n} from \"motion/react\";\nimport React, { useRef } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface DockProps extends VariantProps<typeof dockVariants> {\n className?: string;\n magnification?: number;\n distance?: number;\n direction?: \"top\" | \"middle\" | \"bottom\";\n children: React.ReactNode;\n}\n\nconst DEFAULT_MAGNIFICATION = 60;\nconst DEFAULT_DISTANCE = 140;\n\nconst dockVariants = cva(\n \"supports-backdrop-blur:bg-white/10 supports-backdrop-blur:dark:bg-black/10 mx-auto mt-8 flex h-[58px] w-max gap-2 rounded-2xl border p-2 backdrop-blur-md\",\n);\n\nconst Dock = React.forwardRef<HTMLDivElement, DockProps>(\n (\n {\n className,\n children,\n magnification = DEFAULT_MAGNIFICATION,\n distance = DEFAULT_DISTANCE,\n direction = \"bottom\",\n ...props\n },\n ref,\n ) => {\n const mouseX = useMotionValue(Infinity);\n\n const renderChildren = () => {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.type === DockIcon) {\n return React.cloneElement(child, {\n ...child.props,\n mouseX: mouseX,\n magnification: magnification,\n distance: distance,\n });\n }\n return child;\n });\n };\n\n return (\n <motion.div\n ref={ref}\n onMouseMove={(e) => mouseX.set(e.pageX)}\n onMouseLeave={() => mouseX.set(Infinity)}\n {...props}\n className={cn(dockVariants({ className }), {\n \"items-start\": direction === \"top\",\n \"items-center\": direction === \"middle\",\n \"items-end\": direction === \"bottom\",\n })}\n >\n {renderChildren()}\n </motion.div>\n );\n },\n);\n\nDock.displayName = \"Dock\";\nexport interface DockIconProps\n extends Omit<MotionProps & React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n size?: number;\n magnification?: number;\n distance?: number;\n mouseX?: any;\n className?: string;\n children?: React.ReactNode;\n}\n\nconst DockIcon = ({\n size,\n magnification = DEFAULT_MAGNIFICATION,\n distance = DEFAULT_DISTANCE,\n mouseX,\n className,\n children,\n ...props\n}: DockIconProps) => {\n const ref = useRef<HTMLDivElement>(null);\n\n const distanceCalc = useTransform(mouseX, (val: number) => {\n const bounds = ref.current?.getBoundingClientRect() ?? { x: 0, width: 0 };\n\n return val - bounds.x - bounds.width / 2;\n });\n\n const widthSync = useTransform(\n distanceCalc,\n [-distance, 0, distance],\n [40, magnification, 40],\n );\n\n const width = useSpring(widthSync, {\n mass: 0.1,\n stiffness: 150,\n damping: 12,\n });\n\n return (\n <motion.div\n ref={ref}\n style={{ width }}\n className={cn(\n \"flex aspect-square cursor-pointer items-center justify-center rounded-full\",\n className,\n )}\n {...props}\n >\n {children}\n </motion.div>\n );\n};\n\nDockIcon.displayName = \"DockIcon\";\n\nexport { Dock, DockIcon, dockVariants };\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/file-tree.json b/public/r/styles/default/file-tree.json
index 5968c473..0e2a4df5 100644
--- a/public/r/styles/default/file-tree.json
+++ b/public/r/styles/default/file-tree.json
@@ -4,7 +4,7 @@
"files": [
{
"path": "magicui/file-tree.tsx",
- "content": "\"use client\";\n\nimport React, {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\";\nimport { FileIcon, FolderIcon, FolderOpenIcon } from \"lucide-react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/components/ui/button\";\nimport { ScrollArea } from \"@/components/ui/scroll-area\";\n\ntype TreeViewElement = {\n id: string;\n name: string;\n isSelectable?: boolean;\n children?: TreeViewElement[];\n};\n\ntype TreeContextProps = {\n selectedId: string | undefined;\n expandedItems: string[] | undefined;\n indicator: boolean;\n handleExpand: (id: string) => void;\n selectItem: (id: string) => void;\n setExpandedItems?: React.Dispatch<React.SetStateAction<string[] | undefined>>;\n openIcon?: React.ReactNode;\n closeIcon?: React.ReactNode;\n direction: \"rtl\" | \"ltr\";\n};\n\nconst TreeContext = createContext<TreeContextProps | null>(null);\n\nconst useTree = () => {\n const context = useContext(TreeContext);\n if (!context) {\n throw new Error(\"useTree must be used within a TreeProvider\");\n }\n return context;\n};\n\ninterface TreeViewComponentProps extends React.HTMLAttributes<HTMLDivElement> {}\n\ntype Direction = \"rtl\" | \"ltr\" | undefined;\n\ntype TreeViewProps = {\n initialSelectedId?: string;\n indicator?: boolean;\n elements?: TreeViewElement[];\n initialExpandedItems?: string[];\n openIcon?: React.ReactNode;\n closeIcon?: React.ReactNode;\n} & TreeViewComponentProps;\n\nconst Tree = forwardRef<HTMLDivElement, TreeViewProps>(\n (\n {\n className,\n elements,\n initialSelectedId,\n initialExpandedItems,\n children,\n indicator = true,\n openIcon,\n closeIcon,\n dir,\n ...props\n },\n ref,\n ) => {\n const [selectedId, setSelectedId] = useState<string | undefined>(\n initialSelectedId,\n );\n const [expandedItems, setExpandedItems] = useState<string[] | undefined>(\n initialExpandedItems,\n );\n\n const selectItem = useCallback((id: string) => {\n setSelectedId(id);\n }, []);\n\n const handleExpand = useCallback((id: string) => {\n setExpandedItems((prev) => {\n if (prev?.includes(id)) {\n return prev.filter((item) => item !== id);\n }\n return [...(prev ?? []), id];\n });\n }, []);\n\n const expandSpecificTargetedElements = useCallback(\n (elements?: TreeViewElement[], selectId?: string) => {\n if (!elements || !selectId) return;\n const findParent = (\n currentElement: TreeViewElement,\n currentPath: string[] = [],\n ) => {\n const isSelectable = currentElement.isSelectable ?? true;\n const newPath = [...currentPath, currentElement.id];\n if (currentElement.id === selectId) {\n if (isSelectable) {\n setExpandedItems((prev) => [...(prev ?? []), ...newPath]);\n } else {\n if (newPath.includes(currentElement.id)) {\n newPath.pop();\n setExpandedItems((prev) => [...(prev ?? []), ...newPath]);\n }\n }\n return;\n }\n if (\n isSelectable &&\n currentElement.children &&\n currentElement.children.length > 0\n ) {\n currentElement.children.forEach((child) => {\n findParent(child, newPath);\n });\n }\n };\n elements.forEach((element) => {\n findParent(element);\n });\n },\n [],\n );\n\n useEffect(() => {\n if (initialSelectedId) {\n expandSpecificTargetedElements(elements, initialSelectedId);\n }\n }, [initialSelectedId, elements]);\n\n const direction = dir === \"rtl\" ? \"rtl\" : \"ltr\";\n\n return (\n <TreeContext.Provider\n value={{\n selectedId,\n expandedItems,\n handleExpand,\n selectItem,\n setExpandedItems,\n indicator,\n openIcon,\n closeIcon,\n direction,\n }}\n >\n <div className={cn(\"size-full\", className)}>\n <ScrollArea\n ref={ref}\n className=\"h-full relative px-2\"\n dir={dir as Direction}\n >\n <AccordionPrimitive.Root\n {...props}\n type=\"multiple\"\n defaultValue={expandedItems}\n value={expandedItems}\n className=\"flex flex-col gap-1\"\n onValueChange={(value) =>\n setExpandedItems((prev) => [...(prev ?? []), value[0]])\n }\n dir={dir as Direction}\n >\n {children}\n </AccordionPrimitive.Root>\n </ScrollArea>\n </div>\n </TreeContext.Provider>\n );\n },\n);\n\nTree.displayName = \"Tree\";\n\nconst TreeIndicator = forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const { direction } = useTree();\n\n return (\n <div\n dir={direction}\n ref={ref}\n className={cn(\n \"h-full w-px bg-muted absolute left-1.5 rtl:right-1.5 py-3 rounded-md hover:bg-slate-300 duration-300 ease-in-out\",\n className,\n )}\n {...props}\n />\n );\n});\n\nTreeIndicator.displayName = \"TreeIndicator\";\n\ninterface FolderComponentProps\n extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item> {}\n\ntype FolderProps = {\n expandedItems?: string[];\n element: string;\n isSelectable?: boolean;\n isSelect?: boolean;\n} & FolderComponentProps;\n\nconst Folder = forwardRef<\n HTMLDivElement,\n FolderProps & React.HTMLAttributes<HTMLDivElement>\n>(\n (\n {\n className,\n element,\n value,\n isSelectable = true,\n isSelect,\n children,\n ...props\n },\n ref,\n ) => {\n const {\n direction,\n handleExpand,\n expandedItems,\n indicator,\n setExpandedItems,\n openIcon,\n closeIcon,\n } = useTree();\n\n return (\n <AccordionPrimitive.Item\n {...props}\n value={value}\n className=\"relative overflow-hidden h-full \"\n >\n <AccordionPrimitive.Trigger\n className={cn(\n `flex items-center gap-1 text-sm rounded-md`,\n className,\n {\n \"bg-muted rounded-md\": isSelect && isSelectable,\n \"cursor-pointer\": isSelectable,\n \"cursor-not-allowed opacity-50\": !isSelectable,\n },\n )}\n disabled={!isSelectable}\n onClick={() => handleExpand(value)}\n >\n {expandedItems?.includes(value)\n ? (openIcon ?? <FolderOpenIcon className=\"size-4\" />)\n : (closeIcon ?? <FolderIcon className=\"size-4\" />)}\n <span>{element}</span>\n </AccordionPrimitive.Trigger>\n <AccordionPrimitive.Content className=\"text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down relative overflow-hidden h-full\">\n {element && indicator && <TreeIndicator aria-hidden=\"true\" />}\n <AccordionPrimitive.Root\n dir={direction}\n type=\"multiple\"\n className=\"flex flex-col gap-1 py-1 ml-5 rtl:mr-5 \"\n defaultValue={expandedItems}\n value={expandedItems}\n onValueChange={(value) => {\n setExpandedItems?.((prev) => [...(prev ?? []), value[0]]);\n }}\n >\n {children}\n </AccordionPrimitive.Root>\n </AccordionPrimitive.Content>\n </AccordionPrimitive.Item>\n );\n },\n);\n\nFolder.displayName = \"Folder\";\n\nconst File = forwardRef<\n HTMLButtonElement,\n {\n value: string;\n handleSelect?: (id: string) => void;\n isSelectable?: boolean;\n isSelect?: boolean;\n fileIcon?: React.ReactNode;\n } & React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>\n>(\n (\n {\n value,\n className,\n handleSelect,\n isSelectable = true,\n isSelect,\n fileIcon,\n children,\n ...props\n },\n ref,\n ) => {\n const { direction, selectedId, selectItem } = useTree();\n const isSelected = isSelect ?? selectedId === value;\n return (\n <AccordionPrimitive.Item value={value} className=\"relative\">\n <AccordionPrimitive.Trigger\n ref={ref}\n {...props}\n dir={direction}\n disabled={!isSelectable}\n aria-label=\"File\"\n className={cn(\n \"flex items-center gap-1 cursor-pointer text-sm pr-1 rtl:pl-1 rtl:pr-0 rounded-md duration-200 ease-in-out\",\n {\n \"bg-muted\": isSelected && isSelectable,\n },\n isSelectable ? \"cursor-pointer\" : \"opacity-50 cursor-not-allowed\",\n className,\n )}\n onClick={() => selectItem(value)}\n >\n {fileIcon ?? <FileIcon className=\"size-4\" />}\n {children}\n </AccordionPrimitive.Trigger>\n </AccordionPrimitive.Item>\n );\n },\n);\n\nFile.displayName = \"File\";\n\nconst CollapseButton = forwardRef<\n HTMLButtonElement,\n {\n elements: TreeViewElement[];\n expandAll?: boolean;\n } & React.HTMLAttributes<HTMLButtonElement>\n>(({ className, elements, expandAll = false, children, ...props }, ref) => {\n const { expandedItems, setExpandedItems } = useTree();\n\n const expendAllTree = useCallback((elements: TreeViewElement[]) => {\n const expandTree = (element: TreeViewElement) => {\n const isSelectable = element.isSelectable ?? true;\n if (isSelectable && element.children && element.children.length > 0) {\n setExpandedItems?.((prev) => [...(prev ?? []), element.id]);\n element.children.forEach(expandTree);\n }\n };\n\n elements.forEach(expandTree);\n }, []);\n\n const closeAll = useCallback(() => {\n setExpandedItems?.([]);\n }, []);\n\n useEffect(() => {\n console.log(expandAll);\n if (expandAll) {\n expendAllTree(elements);\n }\n }, [expandAll]);\n\n return (\n <Button\n variant={\"ghost\"}\n className=\"h-8 w-fit p-1 absolute bottom-1 right-2\"\n onClick={\n expandedItems && expandedItems.length > 0\n ? closeAll\n : () => expendAllTree(elements)\n }\n ref={ref}\n {...props}\n >\n {children}\n <span className=\"sr-only\">Toggle</span>\n </Button>\n );\n});\n\nCollapseButton.displayName = \"CollapseButton\";\n\nexport { CollapseButton, File, Folder, Tree, type TreeViewElement };\n",
+ "content": "\"use client\";\n\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\";\nimport { FileIcon, FolderIcon, FolderOpenIcon } from \"lucide-react\";\nimport React, {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\n\nimport { Button } from \"@/components/ui/button\";\nimport { ScrollArea } from \"@/components/ui/scroll-area\";\nimport { cn } from \"@/lib/utils\";\n\ntype TreeViewElement = {\n id: string;\n name: string;\n isSelectable?: boolean;\n children?: TreeViewElement[];\n};\n\ntype TreeContextProps = {\n selectedId: string | undefined;\n expandedItems: string[] | undefined;\n indicator: boolean;\n handleExpand: (id: string) => void;\n selectItem: (id: string) => void;\n setExpandedItems?: React.Dispatch<React.SetStateAction<string[] | undefined>>;\n openIcon?: React.ReactNode;\n closeIcon?: React.ReactNode;\n direction: \"rtl\" | \"ltr\";\n};\n\nconst TreeContext = createContext<TreeContextProps | null>(null);\n\nconst useTree = () => {\n const context = useContext(TreeContext);\n if (!context) {\n throw new Error(\"useTree must be used within a TreeProvider\");\n }\n return context;\n};\n\ninterface TreeViewComponentProps extends React.HTMLAttributes<HTMLDivElement> {}\n\ntype Direction = \"rtl\" | \"ltr\" | undefined;\n\ntype TreeViewProps = {\n initialSelectedId?: string;\n indicator?: boolean;\n elements?: TreeViewElement[];\n initialExpandedItems?: string[];\n openIcon?: React.ReactNode;\n closeIcon?: React.ReactNode;\n} & TreeViewComponentProps;\n\nconst Tree = forwardRef<HTMLDivElement, TreeViewProps>(\n (\n {\n className,\n elements,\n initialSelectedId,\n initialExpandedItems,\n children,\n indicator = true,\n openIcon,\n closeIcon,\n dir,\n ...props\n },\n ref,\n ) => {\n const [selectedId, setSelectedId] = useState<string | undefined>(\n initialSelectedId,\n );\n const [expandedItems, setExpandedItems] = useState<string[] | undefined>(\n initialExpandedItems,\n );\n\n const selectItem = useCallback((id: string) => {\n setSelectedId(id);\n }, []);\n\n const handleExpand = useCallback((id: string) => {\n setExpandedItems((prev) => {\n if (prev?.includes(id)) {\n return prev.filter((item) => item !== id);\n }\n return [...(prev ?? []), id];\n });\n }, []);\n\n const expandSpecificTargetedElements = useCallback(\n (elements?: TreeViewElement[], selectId?: string) => {\n if (!elements || !selectId) return;\n const findParent = (\n currentElement: TreeViewElement,\n currentPath: string[] = [],\n ) => {\n const isSelectable = currentElement.isSelectable ?? true;\n const newPath = [...currentPath, currentElement.id];\n if (currentElement.id === selectId) {\n if (isSelectable) {\n setExpandedItems((prev) => [...(prev ?? []), ...newPath]);\n } else {\n if (newPath.includes(currentElement.id)) {\n newPath.pop();\n setExpandedItems((prev) => [...(prev ?? []), ...newPath]);\n }\n }\n return;\n }\n if (\n isSelectable &&\n currentElement.children &&\n currentElement.children.length > 0\n ) {\n currentElement.children.forEach((child) => {\n findParent(child, newPath);\n });\n }\n };\n elements.forEach((element) => {\n findParent(element);\n });\n },\n [],\n );\n\n useEffect(() => {\n if (initialSelectedId) {\n expandSpecificTargetedElements(elements, initialSelectedId);\n }\n }, [initialSelectedId, elements]);\n\n const direction = dir === \"rtl\" ? \"rtl\" : \"ltr\";\n\n return (\n <TreeContext.Provider\n value={{\n selectedId,\n expandedItems,\n handleExpand,\n selectItem,\n setExpandedItems,\n indicator,\n openIcon,\n closeIcon,\n direction,\n }}\n >\n <div className={cn(\"size-full\", className)}>\n <ScrollArea\n ref={ref}\n className=\"relative h-full px-2\"\n dir={dir as Direction}\n >\n <AccordionPrimitive.Root\n {...props}\n type=\"multiple\"\n defaultValue={expandedItems}\n value={expandedItems}\n className=\"flex flex-col gap-1\"\n onValueChange={(value) =>\n setExpandedItems((prev) => [...(prev ?? []), value[0]])\n }\n dir={dir as Direction}\n >\n {children}\n </AccordionPrimitive.Root>\n </ScrollArea>\n </div>\n </TreeContext.Provider>\n );\n },\n);\n\nTree.displayName = \"Tree\";\n\nconst TreeIndicator = forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const { direction } = useTree();\n\n return (\n <div\n dir={direction}\n ref={ref}\n className={cn(\n \"absolute left-1.5 h-full w-px rounded-md bg-muted py-3 duration-300 ease-in-out hover:bg-slate-300 rtl:right-1.5\",\n className,\n )}\n {...props}\n />\n );\n});\n\nTreeIndicator.displayName = \"TreeIndicator\";\n\ninterface FolderComponentProps\n extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item> {}\n\ntype FolderProps = {\n expandedItems?: string[];\n element: string;\n isSelectable?: boolean;\n isSelect?: boolean;\n} & FolderComponentProps;\n\nconst Folder = forwardRef<\n HTMLDivElement,\n FolderProps & React.HTMLAttributes<HTMLDivElement>\n>(\n (\n {\n className,\n element,\n value,\n isSelectable = true,\n isSelect,\n children,\n ...props\n },\n ref,\n ) => {\n const {\n direction,\n handleExpand,\n expandedItems,\n indicator,\n setExpandedItems,\n openIcon,\n closeIcon,\n } = useTree();\n\n return (\n <AccordionPrimitive.Item\n {...props}\n value={value}\n className=\"relative h-full overflow-hidden\"\n >\n <AccordionPrimitive.Trigger\n className={cn(\n `flex items-center gap-1 rounded-md text-sm`,\n className,\n {\n \"bg-muted rounded-md\": isSelect && isSelectable,\n \"cursor-pointer\": isSelectable,\n \"cursor-not-allowed opacity-50\": !isSelectable,\n },\n )}\n disabled={!isSelectable}\n onClick={() => handleExpand(value)}\n >\n {expandedItems?.includes(value)\n ? (openIcon ?? <FolderOpenIcon className=\"size-4\" />)\n : (closeIcon ?? <FolderIcon className=\"size-4\" />)}\n <span>{element}</span>\n </AccordionPrimitive.Trigger>\n <AccordionPrimitive.Content className=\"relative h-full overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down\">\n {element && indicator && <TreeIndicator aria-hidden=\"true\" />}\n <AccordionPrimitive.Root\n dir={direction}\n type=\"multiple\"\n className=\"ml-5 flex flex-col gap-1 py-1 rtl:mr-5 \"\n defaultValue={expandedItems}\n value={expandedItems}\n onValueChange={(value) => {\n setExpandedItems?.((prev) => [...(prev ?? []), value[0]]);\n }}\n >\n {children}\n </AccordionPrimitive.Root>\n </AccordionPrimitive.Content>\n </AccordionPrimitive.Item>\n );\n },\n);\n\nFolder.displayName = \"Folder\";\n\nconst File = forwardRef<\n HTMLButtonElement,\n {\n value: string;\n handleSelect?: (id: string) => void;\n isSelectable?: boolean;\n isSelect?: boolean;\n fileIcon?: React.ReactNode;\n } & React.ButtonHTMLAttributes<HTMLButtonElement>\n>(\n (\n {\n value,\n className,\n handleSelect,\n isSelectable = true,\n isSelect,\n fileIcon,\n children,\n ...props\n },\n ref,\n ) => {\n const { direction, selectedId, selectItem } = useTree();\n const isSelected = isSelect ?? selectedId === value;\n return (\n <button\n ref={ref}\n type=\"button\"\n disabled={!isSelectable}\n className={cn(\n \"flex w-fit items-center gap-1 rounded-md pr-1 text-sm duration-200 ease-in-out rtl:pl-1 rtl:pr-0\",\n {\n \"bg-muted\": isSelected && isSelectable,\n },\n isSelectable ? \"cursor-pointer\" : \"cursor-not-allowed opacity-50\",\n direction === \"rtl\" ? \"rtl\" : \"ltr\",\n className,\n )}\n onClick={() => selectItem(value)}\n {...props}\n >\n {fileIcon ?? <FileIcon className=\"size-4\" />}\n {children}\n </button>\n );\n },\n);\n\nFile.displayName = \"File\";\n\nconst CollapseButton = forwardRef<\n HTMLButtonElement,\n {\n elements: TreeViewElement[];\n expandAll?: boolean;\n } & React.HTMLAttributes<HTMLButtonElement>\n>(({ className, elements, expandAll = false, children, ...props }, ref) => {\n const { expandedItems, setExpandedItems } = useTree();\n\n const expendAllTree = useCallback((elements: TreeViewElement[]) => {\n const expandTree = (element: TreeViewElement) => {\n const isSelectable = element.isSelectable ?? true;\n if (isSelectable && element.children && element.children.length > 0) {\n setExpandedItems?.((prev) => [...(prev ?? []), element.id]);\n element.children.forEach(expandTree);\n }\n };\n\n elements.forEach(expandTree);\n }, []);\n\n const closeAll = useCallback(() => {\n setExpandedItems?.([]);\n }, []);\n\n useEffect(() => {\n console.log(expandAll);\n if (expandAll) {\n expendAllTree(elements);\n }\n }, [expandAll]);\n\n return (\n <Button\n variant={\"ghost\"}\n className=\"absolute bottom-1 right-2 h-8 w-fit p-1\"\n onClick={\n expandedItems && expandedItems.length > 0\n ? closeAll\n : () => expendAllTree(elements)\n }\n ref={ref}\n {...props}\n >\n {children}\n <span className=\"sr-only\">Toggle</span>\n </Button>\n );\n});\n\nCollapseButton.displayName = \"CollapseButton\";\n\nexport { CollapseButton, File, Folder, Tree, type TreeViewElement };\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/hyper-text.json b/public/r/styles/default/hyper-text.json
index c043d103..00dd49b9 100644
--- a/public/r/styles/default/hyper-text.json
+++ b/public/r/styles/default/hyper-text.json
@@ -2,12 +2,12 @@
"name": "hyper-text",
"type": "registry:ui",
"dependencies": [
- "framer-motion"
+ "motion"
],
"files": [
{
"path": "magicui/hyper-text.tsx",
- "content": "\"use client\";\n\nimport { AnimatePresence, motion, Variants } from \"framer-motion\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\ninterface HyperTextProps {\n text: string;\n duration?: number;\n framerProps?: Variants;\n className?: string;\n animateOnLoad?: boolean;\n}\n\nconst alphabets = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".split(\"\");\n\nconst getRandomInt = (max: number) => Math.floor(Math.random() * max);\n\nexport default function HyperText({\n text,\n duration = 800,\n framerProps = {\n initial: { opacity: 0, y: -10 },\n animate: { opacity: 1, y: 0 },\n exit: { opacity: 0, y: 3 },\n },\n className,\n animateOnLoad = true,\n}: HyperTextProps) {\n const [displayText, setDisplayText] = useState(text.split(\"\"));\n const [trigger, setTrigger] = useState(false);\n const interations = useRef(0);\n const isFirstRender = useRef(true);\n\n const triggerAnimation = () => {\n interations.current = 0;\n setTrigger(true);\n };\n\n useEffect(() => {\n const interval = setInterval(\n () => {\n if (!animateOnLoad && isFirstRender.current) {\n clearInterval(interval);\n isFirstRender.current = false;\n return;\n }\n if (interations.current < text.length) {\n setDisplayText((t) =>\n t.map((l, i) =>\n l === \" \"\n ? l\n : i <= interations.current\n ? text[i]\n : alphabets[getRandomInt(26)],\n ),\n );\n interations.current = interations.current + 0.1;\n } else {\n setTrigger(false);\n clearInterval(interval);\n }\n },\n duration / (text.length * 10),\n );\n // Clean up interval on unmount\n return () => clearInterval(interval);\n }, [text, duration, trigger, animateOnLoad]);\n\n return (\n <div\n className=\"flex scale-100 cursor-default overflow-hidden py-2\"\n onMouseEnter={triggerAnimation}\n >\n <AnimatePresence mode=\"wait\">\n {displayText.map((letter, i) => (\n <motion.span\n key={i}\n className={cn(\"font-mono\", letter === \" \" ? \"w-3\" : \"\", className)}\n {...framerProps}\n >\n {letter.toUpperCase()}\n </motion.span>\n ))}\n </AnimatePresence>\n </div>\n );\n}\n",
+ "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { AnimatePresence, motion, MotionProps } from \"motion/react\";\nimport { useEffect, useRef, useState } from \"react\";\n\ntype CharacterSet = string[] | readonly string[];\n\ninterface HyperTextProps extends MotionProps {\n /** The text content to be animated */\n children: string;\n /** Optional className for styling */\n className?: string;\n /** Duration of the animation in milliseconds */\n duration?: number;\n /** Delay before animation starts in milliseconds */\n delay?: number;\n /** Component to render as - defaults to div */\n as?: React.ElementType;\n /** Whether to start animation when element comes into view */\n startOnView?: boolean;\n /** Whether to trigger animation on hover */\n animateOnHover?: boolean;\n /** Custom character set for scramble effect. Defaults to uppercase alphabet */\n characterSet?: CharacterSet;\n}\n\nconst DEFAULT_CHARACTER_SET = Object.freeze(\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".split(\"\"),\n) as readonly string[];\n\nconst getRandomInt = (max: number): number => Math.floor(Math.random() * max);\n\nexport default function HyperText({\n children,\n className,\n duration = 800,\n delay = 0,\n as: Component = \"div\",\n startOnView = false,\n animateOnHover = true,\n characterSet = DEFAULT_CHARACTER_SET,\n ...props\n}: HyperTextProps) {\n const MotionComponent = motion.create(Component, {\n forwardMotionProps: true,\n });\n\n const [displayText, setDisplayText] = useState<string[]>(() =>\n children.split(\"\"),\n );\n const [isAnimating, setIsAnimating] = useState(false);\n const iterationCount = useRef(0);\n const elementRef = useRef<HTMLElement>(null);\n\n const handleAnimationTrigger = () => {\n if (animateOnHover && !isAnimating) {\n iterationCount.current = 0;\n setIsAnimating(true);\n }\n };\n\n // Handle animation start based on view or delay\n useEffect(() => {\n if (!startOnView) {\n const startTimeout = setTimeout(() => {\n setIsAnimating(true);\n }, delay);\n return () => clearTimeout(startTimeout);\n }\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n setTimeout(() => {\n setIsAnimating(true);\n }, delay);\n observer.disconnect();\n }\n },\n { threshold: 0.1, rootMargin: \"-30% 0px -30% 0px\" },\n );\n\n if (elementRef.current) {\n observer.observe(elementRef.current);\n }\n\n return () => observer.disconnect();\n }, [delay, startOnView]);\n\n // Handle scramble animation\n useEffect(() => {\n if (!isAnimating) return;\n\n const intervalDuration = duration / (children.length * 10);\n const maxIterations = children.length;\n\n const interval = setInterval(() => {\n if (iterationCount.current < maxIterations) {\n setDisplayText((currentText) =>\n currentText.map((letter, index) =>\n letter === \" \"\n ? letter\n : index <= iterationCount.current\n ? children[index]\n : characterSet[getRandomInt(characterSet.length)],\n ),\n );\n iterationCount.current = iterationCount.current + 0.1;\n } else {\n setIsAnimating(false);\n clearInterval(interval);\n }\n }, intervalDuration);\n\n return () => clearInterval(interval);\n }, [children, duration, isAnimating, characterSet]);\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\"overflow-hidden py-2 text-4xl font-bold\", className)}\n onMouseEnter={handleAnimationTrigger}\n {...props}\n >\n <AnimatePresence>\n {displayText.map((letter, index) => (\n <motion.span\n key={index}\n className={cn(\"font-mono\", letter === \" \" ? \"w-3\" : \"\")}\n >\n {letter.toUpperCase()}\n </motion.span>\n ))}\n </AnimatePresence>\n </MotionComponent>\n );\n}\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/marquee.json b/public/r/styles/default/marquee.json
index aa2bfd50..10514cdc 100644
--- a/public/r/styles/default/marquee.json
+++ b/public/r/styles/default/marquee.json
@@ -4,7 +4,7 @@
"files": [
{
"path": "magicui/marquee.tsx",
- "content": "import { cn } from \"@/lib/utils\";\n\ninterface MarqueeProps {\n className?: string;\n reverse?: boolean;\n pauseOnHover?: boolean;\n children?: React.ReactNode;\n vertical?: boolean;\n repeat?: number;\n [key: string]: any;\n}\n\nexport default function Marquee({\n className,\n reverse,\n pauseOnHover = false,\n children,\n vertical = false,\n repeat = 4,\n ...props\n}: MarqueeProps) {\n return (\n <div\n {...props}\n className={cn(\n \"group flex overflow-hidden p-2 [--duration:40s] [--gap:1rem] [gap:var(--gap)]\",\n {\n \"flex-row\": !vertical,\n \"flex-col\": vertical,\n },\n className,\n )}\n >\n {Array(repeat)\n .fill(0)\n .map((_, i) => (\n <div\n key={i}\n className={cn(\"flex shrink-0 justify-around [gap:var(--gap)]\", {\n \"animate-marquee flex-row\": !vertical,\n \"animate-marquee-vertical flex-col\": vertical,\n \"group-hover:[animation-play-state:paused]\": pauseOnHover,\n \"[animation-direction:reverse]\": reverse,\n })}\n >\n {children}\n </div>\n ))}\n </div>\n );\n}\n",
+ "content": "import { cn } from \"@/lib/utils\";\nimport { ComponentPropsWithoutRef } from \"react\";\n\ninterface MarqueeProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Optional CSS class name to apply custom styles\n */\n className?: string;\n /**\n * Whether to reverse the animation direction\n * @default false\n */\n reverse?: boolean;\n /**\n * Whether to pause the animation on hover\n * @default false\n */\n pauseOnHover?: boolean;\n /**\n * Content to be displayed in the marquee\n */\n children: React.ReactNode;\n /**\n * Whether to animate vertically instead of horizontally\n * @default false\n */\n vertical?: boolean;\n /**\n * Number of times to repeat the content\n * @default 4\n */\n repeat?: number;\n}\n\nexport default function Marquee({\n className,\n reverse = false,\n pauseOnHover = false,\n children,\n vertical = false,\n repeat = 4,\n ...props\n}: MarqueeProps) {\n return (\n <div\n {...props}\n className={cn(\n \"group flex overflow-hidden p-2 [--duration:40s] [--gap:1rem] [gap:var(--gap)]\",\n {\n \"flex-row\": !vertical,\n \"flex-col\": vertical,\n },\n className,\n )}\n >\n {Array(repeat)\n .fill(0)\n .map((_, i) => (\n <div\n key={i}\n className={cn(\"flex shrink-0 justify-around [gap:var(--gap)]\", {\n \"animate-marquee flex-row\": !vertical,\n \"animate-marquee-vertical flex-col\": vertical,\n \"group-hover:[animation-play-state:paused]\": pauseOnHover,\n \"[animation-direction:reverse]\": reverse,\n })}\n >\n {children}\n </div>\n ))}\n </div>\n );\n}\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/retro-grid.json b/public/r/styles/default/retro-grid.json
index d7e373fc..1fb4689c 100644
--- a/public/r/styles/default/retro-grid.json
+++ b/public/r/styles/default/retro-grid.json
@@ -4,7 +4,7 @@
"files": [
{
"path": "magicui/retro-grid.tsx",
- "content": "import { cn } from \"@/lib/utils\";\n\nexport default function RetroGrid({\n className,\n angle = 65,\n}: {\n className?: string;\n angle?: number;\n}) {\n return (\n <div\n className={cn(\n \"pointer-events-none absolute size-full overflow-hidden opacity-50 [perspective:200px]\",\n className,\n )}\n style={{ \"--grid-angle\": `${angle}deg` } as React.CSSProperties}\n >\n {/* Grid */}\n <div className=\"absolute inset-0 [transform:rotateX(var(--grid-angle))]\">\n <div\n className={cn(\n \"animate-grid\",\n\n \"[background-repeat:repeat] [background-size:60px_60px] [height:300vh] [inset:0%_0px] [margin-left:-50%] [transform-origin:100%_0_0] [width:600vw]\",\n\n // Light Styles\n \"[background-image:linear-gradient(to_right,rgba(0,0,0,0.3)_1px,transparent_0),linear-gradient(to_bottom,rgba(0,0,0,0.3)_1px,transparent_0)]\",\n\n // Dark styles\n \"dark:[background-image:linear-gradient(to_right,rgba(255,255,255,0.2)_1px,transparent_0),linear-gradient(to_bottom,rgba(255,255,255,0.2)_1px,transparent_0)]\",\n )}\n />\n </div>\n\n {/* Background Gradient */}\n <div className=\"absolute inset-0 bg-gradient-to-t from-white to-transparent to-90% dark:from-black\" />\n </div>\n );\n}\n",
+ "content": "import { cn } from \"@/lib/utils\";\n\ninterface RetroGridProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Additional CSS classes to apply to the grid container\n */\n className?: string;\n /**\n * Rotation angle of the grid in degrees\n * @default 65\n */\n angle?: number;\n /**\n * Grid cell size in pixels\n * @default 60\n */\n cellSize?: number;\n /**\n * Grid opacity value between 0 and 1\n * @default 0.5\n */\n opacity?: number;\n /**\n * Grid line color in light mode\n * @default \"gray\"\n */\n lightLineColor?: string;\n /**\n * Grid line color in dark mode\n * @default \"gray\"\n */\n darkLineColor?: string;\n}\n\nexport default function RetroGrid({\n className,\n angle = 65,\n cellSize = 60,\n opacity = 0.5,\n lightLineColor = \"gray\",\n darkLineColor = \"gray\",\n ...props\n}: RetroGridProps) {\n const gridStyles = {\n \"--grid-angle\": `${angle}deg`,\n \"--cell-size\": `${cellSize}px`,\n \"--opacity\": opacity,\n \"--light-line\": lightLineColor,\n \"--dark-line\": darkLineColor,\n } as React.CSSProperties;\n\n return (\n <div\n className={cn(\n \"pointer-events-none absolute size-full overflow-hidden [perspective:200px]\",\n `opacity-[var(--opacity)]`,\n className,\n )}\n style={gridStyles}\n {...props}\n >\n <div className=\"absolute inset-0 [transform:rotateX(var(--grid-angle))]\">\n <div className=\"animate-grid [background-image:linear-gradient(to_right,var(--light-line)_1px,transparent_0),linear-gradient(to_bottom,var(--light-line)_1px,transparent_0)] [background-repeat:repeat] [background-size:var(--cell-size)_var(--cell-size)] [height:300vh] [inset:0%_0px] [margin-left:-200%] [transform-origin:100%_0_0] [width:600vw] dark:[background-image:linear-gradient(to_right,var(--dark-line)_1px,transparent_0),linear-gradient(to_bottom,var(--dark-line)_1px,transparent_0)]\" />\n </div>\n\n <div className=\"absolute inset-0 bg-gradient-to-t from-white to-transparent to-90% dark:from-black\" />\n </div>\n );\n}\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/typing-animation.json b/public/r/styles/default/typing-animation.json
index 699bb9a5..34bbcaad 100644
--- a/public/r/styles/default/typing-animation.json
+++ b/public/r/styles/default/typing-animation.json
@@ -1,10 +1,13 @@
{
"name": "typing-animation",
"type": "registry:ui",
+ "dependencies": [
+ "motion"
+ ],
"files": [
{
"path": "magicui/typing-animation.tsx",
- "content": "\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\ninterface TypingAnimationProps {\n text: string;\n duration?: number;\n className?: string;\n}\n\nexport default function TypingAnimation({\n text,\n duration = 200,\n className,\n}: TypingAnimationProps) {\n const [displayedText, setDisplayedText] = useState<string>(\"\");\n const [i, setI] = useState<number>(0);\n\n useEffect(() => {\n const typingEffect = setInterval(() => {\n if (i < text.length) {\n setDisplayedText(text.substring(0, i + 1));\n setI(i + 1);\n } else {\n clearInterval(typingEffect);\n }\n }, duration);\n\n return () => {\n clearInterval(typingEffect);\n };\n }, [duration, i]);\n\n return (\n <h1\n className={cn(\n \"font-display text-center text-4xl font-bold leading-[5rem] tracking-[-0.02em] drop-shadow-sm\",\n className,\n )}\n >\n {displayedText ? displayedText : text}\n </h1>\n );\n}\n",
+ "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { motion, MotionProps } from \"motion/react\";\nimport { useEffect, useRef, useState } from \"react\";\n\ninterface TypingAnimationProps extends MotionProps {\n children: string;\n className?: string;\n duration?: number;\n delay?: number;\n as?: React.ElementType;\n startOnView?: boolean;\n}\n\nexport default function TypingAnimation({\n children,\n className,\n duration = 100,\n delay = 0,\n as: Component = \"div\",\n startOnView = false,\n ...props\n}: TypingAnimationProps) {\n const MotionComponent = motion.create(Component, {\n forwardMotionProps: true,\n });\n\n const [displayedText, setDisplayedText] = useState<string>(\"\");\n const [started, setStarted] = useState(false);\n const elementRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n if (!startOnView) {\n const startTimeout = setTimeout(() => {\n setStarted(true);\n }, delay);\n return () => clearTimeout(startTimeout);\n }\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n setTimeout(() => {\n setStarted(true);\n }, delay);\n observer.disconnect();\n }\n },\n { threshold: 0.1 },\n );\n\n if (elementRef.current) {\n observer.observe(elementRef.current);\n }\n\n return () => observer.disconnect();\n }, [delay, startOnView]);\n\n useEffect(() => {\n if (!started) return;\n\n let i = 0;\n const typingEffect = setInterval(() => {\n if (i < children.length) {\n setDisplayedText(children.substring(0, i + 1));\n i++;\n } else {\n clearInterval(typingEffect);\n }\n }, duration);\n\n return () => {\n clearInterval(typingEffect);\n };\n }, [children, duration, started]);\n\n return (\n <MotionComponent\n ref={elementRef}\n className={cn(\n \"text-4xl font-bold leading-[5rem] tracking-[-0.02em]\",\n className,\n )}\n {...props}\n >\n {displayedText}\n </MotionComponent>\n );\n}\n",
"type": "registry:ui",
"target": ""
}