### Installing Underline To Background Component (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/underline-to-background.mdx This command installs the 'underline-to-background' component using the shadcn/ui CLI (`npx shadcn@latest add`). It fetches the component definition from the provided URL and integrates it into the current project. Requires npm or yarn installed and a compatible project setup. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/underline-to-background.json" ``` -------------------------------- ### Installing Circling Elements Component via CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/circling-elements.mdx This command provides a quick way to install the CirclingElements component into your project using the shadcn/ui CLI. It fetches the component code from a remote URL and adds it to your components directory, simplifying the setup process. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/circling-elements.json" ``` -------------------------------- ### Install Component using shadcn CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/element-along-svg-path.mdx This bash command uses the shadcn/ui CLI (`npx shadcn add`) to fetch and install the 'element-along-svg-path' component directly into your project. It downloads the component configuration from the specified URL and adds the necessary files to your components directory. Requires Node.js and a shadcn/ui project setup. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/element-along-path.json" ``` -------------------------------- ### Installing Parallax Floating Component via CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/image/parallax-floating.mdx Use this command-line instruction to add the parallax floating component to your project using a CLI utility, likely based on the shadcn/ui installation pattern. This simplifies setup. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/parallax-floating.json" ``` -------------------------------- ### Install Media Between Text Component using shadcn/ui CLI - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/media-between-text.mdx This command installs the Media Between Text component using the shadcn/ui command-line interface. It fetches the component configuration from a remote JSON file and adds it to your project, including necessary dependencies and code. Ensure you have the shadcn/ui CLI installed and configured before running this command. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/media-between-text.json ``` -------------------------------- ### Install Typewriter Component using shadcn CLI - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/typewriter.mdx This snippet provides the command to install the Typewriter component using the shadcn/ui CLI. It uses `npx` to execute the `shadcn@latest add` command, pointing to the component's configuration JSON file hosted on `fancycomponents.dev`. This is the recommended CLI installation method. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/typewriter.json" ``` -------------------------------- ### Installing Core Dependencies (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/installation.mdx Installs the primary dependencies for the components, including Tailwind CSS (latest version) and Motion (formerly Framer Motion), using the npm package manager. This step is required before using any Fancy components in your project. ```bash npm install tailwindcss@latest motion ``` -------------------------------- ### Adding Component via CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/installation.mdx Uses the npx command with the shadcn-like CLI tool to add a specific Fancy component to your project by fetching its source code and dependencies from a provided URL. After running this, you must manually install any *additional* dependencies listed in the updated package.json file. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/component-name.json" ``` -------------------------------- ### Building Component Registry and Sources (Bash) Source: https://github.com/danielpetho/fancy/blob/main/CONTRIBUTING.md This command executes the 'build:registry' script defined in the project's `package.json`. This script is essential for generating the necessary files (registry index, source files) that allow components to be referenced in documentation and installed via the CLI. It must be run before referencing components in documentation or using the CLI installer. ```bash npm run build:registry ``` -------------------------------- ### Install Dependencies - Matter.js - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/physics/cursor-attractor-and-gravity.mdx Installs the necessary npm packages required for the manual setup of the Cursor Attractor & Gravity components. This includes `matter-js` for the physics engine, its TypeScript types (`@types/matter-js`), and `poly-decomp` for complex shape decomposition, particularly useful for SVG bodies. ```bash npm install matter-js @types/matter-js poly-decomp ``` -------------------------------- ### Installing Project Dependencies (Bash) Source: https://github.com/danielpetho/fancy/blob/main/CONTRIBUTING.md This command uses the npm package manager to read the `package.json` file in the current directory and install all required project dependencies. It is a crucial step after cloning the repository to ensure all necessary libraries and tools are available for development. ```bash npm install ``` -------------------------------- ### Installing Screensaver Component via CLI (shadcn/ui) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/screensaver.mdx This command uses the shadcn/ui CLI utility to automatically fetch and add the Screensaver component code to your project from the specified URL. It's the recommended quick installation method compared to manual copy-pasting. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/screensaver.json" ``` -------------------------------- ### Installing Underline Center Component CLI Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/underline.mdx This command uses npx to run the latest shadcn/ui CLI, adding the 'underline-center' component from the specified URL to the project. This is the recommended method for quick installation of the center-growing underline variant. It requires shadcn/ui CLI and Node.js/npm/npx to be installed. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/underline-center.json" ``` -------------------------------- ### Install Scramble In Component with shadcn CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/scramble-in.mdx This snippet demonstrates how to install the 'Scramble In' component using the shadcn/ui CLI. It fetches the component's configuration from a remote JSON file and adds it to your project. This requires having the shadcn/ui CLI installed and configured in your project. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/scramble-in.json" ``` -------------------------------- ### Installing Manual Gravity dependencies (bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/physics/gravity.mdx This npm command installs the core dependencies required for the manual setup of the Gravity component. It includes matter-js for the physics engine, @types/matter-js for TypeScript typings, poly-decomp for polygon decomposition, and svg-path-commander for parsing SVG paths. ```bash npm install matter-js @types/matter-js poly-decomp svg-path-commander ``` -------------------------------- ### Installing Stacking Cards Component via CLI Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/stacking-cards.mdx Use this bash command with npx and the shadcn CLI to automatically add the Stacking Cards component and its dependencies to your project from the specified component definition URL. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/stacking-cards.json" ``` -------------------------------- ### Install Component - Shadcn CLI - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/physics/cursor-attractor-and-gravity.mdx Installs the Cursor Attractor & Gravity component using the `shadcn/ui` CLI. This command fetches the component definition from a remote URL and adds it to your project, managing dependencies automatically. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/cursor-attractor-and-gravity.json" ``` -------------------------------- ### Installing Scroll and Swap Text Component using shadcn CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/scroll-and-swap.mdx Installs the Scroll and Swap Text component using the shadcn/ui CLI utility. This command fetches the component definition from a remote JSON file and adds it to your project directory, making it available for use. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/scroll-and-swap-text.json" ``` -------------------------------- ### Install Vertical Cut Reveal Component using CLI - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/vertical-cut-reveal.mdx This snippet provides the command-line interface (CLI) command to add the 'Vertical Cut Reveal' component to your project using the `shadcn/ui` CLI tool. This command fetches the component's definition from a specified URL and integrates it into your codebase, offering a quick installation method. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/vertical-cut-reveal.json" ``` -------------------------------- ### Install Text Rotate Component via CLI | Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/text-rotate.mdx Use this Bash command with npx to automatically add the Text Rotate component to your project using the shadcn/ui CLI mechanism. This command fetches the component configuration from the specified URL and integrates it into your existing setup. Prerequisites: Node.js with npx, and a project configured for shadcn/ui components. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/text-rotate.json" ``` -------------------------------- ### Installing Underline Comes In Goes Out Component CLI Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/underline.mdx This command uses npx to run the latest shadcn/ui CLI, adding the 'underline-comes-in-goes-out' component from the specified URL. This installs the variant where the underline enters from one side and exits from the other. It requires shadcn/ui CLI and Node.js/npm/npx to be installed. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/underline-comes-in-goes-out.json" ``` -------------------------------- ### Installing VariableFontAndCursor Component CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/variable-font-and-cursor.mdx This command demonstrates how to install the VariableFontAndCursor component using the shadcn/ui CLI. It fetches the component configuration from the specified URL and adds it to your project. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/variable-font-and-cursor.json" ``` -------------------------------- ### Installing Animated Gradient Component via CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/background/animated-gradient-with-svg.mdx Provides the command-line interface command to add the animated gradient component to a project using the `shadcn@latest` CLI tool. This is the simplest installation method. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/animated-gradient-with-svg.json" ``` -------------------------------- ### Installing Lodash Dependency (Manual Installation) | Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/random-letter-swap.mdx Explains the command to install the lodash JavaScript utility library using npm. Lodash is listed as a required dependency for the manual installation method of the Random Letter Swap Hover component. ```bash npm install lodash ``` -------------------------------- ### Installing Gravity component using CLI (bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/physics/gravity.mdx This command demonstrates how to install the Gravity component and its related files using the shadcn/ui command-line interface, referencing a specific package URL. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/gravity.json" ``` -------------------------------- ### Install TextCursorProximity Component via CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/text-cursor-proximity.mdx This snippet provides the bash command to install the TextCursorProximity component directly into a project using the shadcn/ui CLI tool. It fetches the component definition from a specific URL provided by fancycomponents.dev. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/text-cursor-proximity.json" ``` -------------------------------- ### Installing Underline Goes Out Comes In Component CLI Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/underline.mdx This command uses npx to run the latest shadcn/ui CLI, adding the 'underline-goes-out-comes-in' component from the specified URL. This installs the variant where the underline exits from one side and re-enters from the opposite side. It requires shadcn/ui CLI and Node.js/npm/npx to be installed. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/underline-goes-out-comes-in.json" ``` -------------------------------- ### Install DragElements Component using CLI Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/drag-elements.mdx This command uses the `npx` utility and the shadcn CLI to add the DragElements component to your project directly from a remote JSON configuration file. This requires the shadcn CLI to be installed and configured. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/drag-elements.json" ``` -------------------------------- ### Installing 3D CSS Box Component via shadcn/ui CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/css-box.mdx This command demonstrates how to add the 3D CSS Box component to your project using the `npx shadcn@latest add` utility. It fetches the component definition from the specified remote URL and integrates it into your project's component structure. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/3d-css-box.json" ``` -------------------------------- ### Installing SimpleMarquee Component via CLI Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx Provides the command-line interface instruction to add the `simple-marquee` component to a project using the shadcn/ui CLI utility. This command fetches the component definition and code from a remote URL to integrate it into the project structure. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/simple-marquee.json" ``` -------------------------------- ### Installing Elastic Line Component CLI Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/physics/elastic-line.mdx This bash command uses the shadcn/ui CLI helper (`npx shadcn@latest add`) to automatically add the Elastic Line component configuration from the provided JSON URL to your project, simplifying the installation process. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/elastic-line.json" ``` -------------------------------- ### Installing UUID Dependency (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/background/pixel-trail.mdx This npm command installs the necessary dependencies for the Pixel Trail component when performing a manual installation. It adds the 'uuid' package and its TypeScript type definitions ('@types/uuid') to your project's dependencies. The 'uuid' package is used internally by the component to generate unique IDs for each trail instance. ```bash npm install --save @types/uuid uuid ``` -------------------------------- ### Install Basic Number Ticker Component via CLI Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/basic-number-ticker.mdx This command uses the shadcn/ui CLI tool to add the Basic Number Ticker component to your project. It fetches the component definition from the specified URL, automating the process of copying the necessary code files into your project structure. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/basic-number-ticker.json" ``` -------------------------------- ### Install Breathing Text Component using CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/breathing-text.mdx This command uses npx and the shadcn CLI to automatically add the Breathing Text component and its dependencies to your project by fetching it from the specified URL. It's the recommended method for quick installation. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/breathing-text.json" ``` -------------------------------- ### Installing Text Along Path Component using shadcn/ui CLI Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/text-along-path.mdx This command-line instruction adds the Text Along Path component to your project using the shadcn/ui CLI tool. It requires npx and a pre-configured shadcn/ui environment in your project. The command fetches the component definition from the specified URL and integrates the necessary code files into your project structure. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/text-along-path.json" ``` -------------------------------- ### Install Gooey SVG Filter with CLI - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/filter/gooey-svg-filter.mdx Installs the Gooey SVG Filter component using the `shadcn/ui` CLI extension for fancycomponents.dev. This command adds the component source code to your project. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/gooey-svg-filter.json" ``` -------------------------------- ### Navigating into Project Directory (Bash) Source: https://github.com/danielpetho/fancy/blob/main/CONTRIBUTING.md This command changes the current working directory in the terminal to the 'fancy' folder, which is the root directory of the cloned repository. This is necessary before running subsequent project-specific commands like installing dependencies. ```bash cd fancy ``` -------------------------------- ### Installing Required Dependency Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/variable-font-hover-by-letter.mdx Install the lodash library, which is used by the component for debouncing to prevent animation issues during rapid hover changes. ```bash npm install lodash ``` -------------------------------- ### Install Float Component using shadcn/ui CLI - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/float.mdx This command utilizes the npx utility to run the latest version of the shadcn/ui CLI's 'add' command. It fetches the configuration and code for the 'Float' component from a specific URL hosted on fancycomponents.dev, integrating it into your project's components directory. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/float.json" ``` -------------------------------- ### Install Scramble Hover Component using CLI - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/scramble-hover.mdx This command uses npx with the shadcn CLI to add the Scramble Hover component to your project by fetching its definition from a remote URL. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/scramble-hover.json" ``` -------------------------------- ### Install Lodash Dependency - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/letter-swap.mdx Installs the lodash library via npm, which is required for the ping-pong animation version of the component. Lodash is used for debouncing rapid hover events to prevent animation issues. ```bash npm install lodash ``` -------------------------------- ### Installing VariableFontCursorProximity with CLI (bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/variable-font-cursor-proximity.mdx This bash command uses the shadcn/ui CLI to automatically add the VariableFontCursorProximity component and its dependencies to your project. It fetches the component definition from the specified URL and integrates it into your codebase. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/variable-font-cursor-proximity.json" ``` -------------------------------- ### Example Font Variation Settings Prop Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/variable-font-hover-by-letter.mdx An example of how to specify the 'from' or 'to' font variation settings using a string format compatible with CSS font-variation-settings, showing weight ('wght') and slant ('slnt') axes. ```javascript fromFontVariationSettings="'wght' 100, 'slnt' 0" ``` -------------------------------- ### Install Forward Animation Component (CLI) - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/letter-swap.mdx Uses the shadcn/ui CLI to automatically add the Letter Swap Hover component with forward animation from a remote JSON configuration file. This command fetches the component code and integrates it into your project structure. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/letter-swap-forward-anim.json" ``` -------------------------------- ### Install MarqueeAlongSvgPath CLI - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/marquee-along-svg-path.mdx Use the shadcn/ui CLI to automatically add the MarqueeAlongSvgPath component and its dependencies to your project. This command fetches the component configuration from the specified URL and integrates it. ```Bash npx shadcn@latest add "https://fancycomponents.dev/r/marquee-along-svg-path.json" ``` -------------------------------- ### Installing Component via CLI Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/variable-font-hover-by-letter.mdx Use this command with the shadcn/ui CLI to automatically add the variable-font-hover-by-letter component to your project. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/variable-font-hover-by-letter.json" ``` -------------------------------- ### Example Font Variation Settings Prop - JavaScript Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/variable-font-hover-by-random-letter.mdx This snippet shows an example string value for the 'fromFontVariationSettings' prop. It defines the initial state of the font variations by specifying values for the 'wght' (weight) and 'slnt' (slant) axes, compatible with variable fonts supporting these axes. ```javascript fromFontVariationSettings="'wght' 100, 'slnt' 0" ``` -------------------------------- ### Install Ping Pong Animation Component (CLI) - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/letter-swap.mdx Uses the shadcn/ui CLI to automatically add the Letter Swap Hover component with ping-pong animation from a remote JSON configuration file. This command fetches the component code and integrates it into your project structure. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/letter-swap-pingpong-anim.json" ``` -------------------------------- ### Adding Pixel Trail Component via CLI (Bash) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/background/pixel-trail.mdx This bash command uses a CLI tool (similar to shadcn/ui's) to automatically add the Pixel Trail component to your project by fetching its definition from a remote URL. It simplifies the integration process, requiring the specific CLI tool to be installed and configured. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/pixel-trail.json" ``` -------------------------------- ### Installing Forward Animation Component (CLI) | Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/random-letter-swap.mdx Explains the command to add the random letter swap component with the forward animation using the shadcn/ui CLI. This command fetches the component configuration from the specified URL and adds it to the project. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/random-letter-swap-forward-anim.json" ``` -------------------------------- ### Installing Ping Pong Animation Component (CLI) | Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/random-letter-swap.mdx Explains the command to add the random letter swap component with the ping pong animation using the shadcn/ui CLI. This command fetches the component configuration from the specified URL and adds it to the project. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/random-letter-swap-pingpong-anim.json" ``` -------------------------------- ### Installing Component via CLI - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/variable-font-hover-by-random-letter.mdx This command uses the shadcn CLI tool via npx to automatically add the 'variable-font-hover-by-random-letter' component to your project. It fetches the component definition from the specified URL and integrates it. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/variable-font-hover-by-random-letter.json" ``` -------------------------------- ### Apply CSS Interpolation with Prop - React/JSX Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/marquee-along-svg-path.mdx Shows an example of using the `cssVariableInterpolation` prop to animate CSS properties based on path progress. The example interpolates `opacity` from 0 to 1.5 and `scale` from 0.1 to 1 as elements move along the specified SVG path. ```JSX {/* Your content */} ``` -------------------------------- ### Initializing Drag State and Handling Pointer Events (JSX) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx Sets up refs for tracking the marquee's dragging state, velocity, and the last known pointer position. Implements `handlePointerDown` to initiate dragging, capture the pointer, optionally change the cursor, and record the starting position. Defines `handlePointerMove` to calculate the movement delta, project it based on `dragAngle`, and update the `dragVelocity` ref. ```jsx // State for tracking dragging const isDragging = useRef(false) const dragVelocity = useRef(0) const lastPointerPosition = useRef({ x: 0, y: 0 }) const handlePointerDown = (e: React.PointerEvent) => { if (!draggable) return // Capture pointer events (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId) if (grabCursor) { (e.currentTarget as HTMLElement).style.cursor = "grabbing" } isDragging.current = true lastPointerPosition.current = { x: e.clientX, y: e.clientY } // Pause automatic animation dragVelocity.current = 0 } const handlePointerMove = (e: React.PointerEvent) => { if (!draggable || !isDragging.current) return const currentPosition = { x: e.clientX, y: e.clientY } // Calculate movement delta const deltaX = currentPosition.x - lastPointerPosition.current.x const deltaY = currentPosition.y - lastPointerPosition.current.y // Support for angled dragging const angleInRadians = (dragAngle * Math.PI) / 180 const directionX = Math.cos(angleInRadians) const directionY = Math.sin(angleInRadians) // Project movement along angle direction const projectedDelta = deltaX * directionX + deltaY * directionY // Set drag velocity dragVelocity.current = projectedDelta * dragSensitivity lastPointerPosition.current = currentPosition } ``` -------------------------------- ### Add Pixelate SVG Filter Component via CLI - Bash Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/filter/pixelate-svg-filter.mdx Uses the `npx shadcn@latest` command to add the PixelateSvgFilter component to your project by fetching its configuration from a specified URL. This is the recommended installation method for users of the shadcn/ui CLI or similar tools. ```bash npx shadcn@latest add "https://fancycomponents.dev/r/pixelate-svg-filter.json" ``` -------------------------------- ### Customizing MatterBody physics options (TypeScript) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/physics/gravity.mdx This example demonstrates how to use the `matterBodyOptions` prop on the MatterBody component to customize physics properties. It shows common options like friction, restitution (bounciness), density (weight), `isStatic` (immovable), and initial force. ```typescript
I'm bouncy!
``` -------------------------------- ### Using 3D CSS Box Component with React Ref (TSX) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/css-box.mdx This TypeScript React snippet shows a high-level example of rendering the CSSBox component. It demonstrates configuring dimensions, adding faces, enabling drag, and using a React ref to access imperative methods like `showTop` on button click. ```tsx import { useRef } from "react" import CSSBox, { CSSBoxRef } from "@/components/blocks/css-box" export default function CubeExample() { const cubeRef = useRef(null) return ( <> , back: Back, left: Left, right: Right, top: Top, bottom: Bottom, }} /> ) } ``` -------------------------------- ### Basic Gravity and MatterBody Usage (TypeScript) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/physics/gravity.mdx This example shows the fundamental structure for using the Gravity and MatterBody components. The Gravity component wraps the physics scene, and individual elements intended to be physics bodies are wrapped with MatterBody, specifying their initial x and y positions. ```typescript
Hello world!
fancy!
``` -------------------------------- ### Using the Floating and FloatingElement Components (TypeScript) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/image/parallax-floating.mdx This example demonstrates the basic usage structure for the parallax floating effect. Wrap the elements you want to float with `FloatingElement` components inside a `Floating` wrapper. Adjust the `depth` prop on each `FloatingElement` to control its movement intensity, while positioning and styling are handled by the child elements (e.g., using Tailwind classes). ```typescript
``` -------------------------------- ### Defining CSS Keyframes for Circling Animation (TSX/CSS) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/circling-elements.mdx This code snippet defines the necessary CSS keyframes for the circling animation effect. It's part of the manual installation steps and should be added to your global CSS file or configuration. The keyframes use CSS variables (`--offset`, `--radius`) and `calc()` to enable dynamic calculation of the transform properties, creating a circular path while maintaining element orientation. ```css { // ... @theme: { --animate-circling: circling; @keyframes circling { 0% { transform: rotate(calc(var(--offset) * 1deg)) translate(calc(var(--radius) * 1px), 0) rotate(calc(var(--offset) * -1deg)); } 100% { transform: rotate(calc(360deg + (var(--offset) * 1deg))) translate(calc(var(--radius) * 1px), 0) rotate(calc(-360deg + (var(--offset) * -1deg))); } } } }; ``` -------------------------------- ### Implementing Scroll-Based Marquee Velocity and Direction JavaScript/JSX Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx Integrates scroll interaction to influence marquee animation. It uses Framer Motion hooks (`useScroll`, `useVelocity`, `useSpring`) to get and smooth scroll velocity. `useTransform` converts this into a factor applied to the marquee's speed, and `scrollAwareDirection` logic allows scroll direction to potentially reverse the marquee. ```jsx const { scrollY } = useScroll({ container: (scrollContainer as RefObject) || innerContainer.current, }) const scrollVelocity = useVelocity(scrollY) const smoothVelocity = useSpring(scrollVelocity, scrollSpringConfig) // Transform scroll velocity into a factor for marquee speed const velocityFactor = useTransform( useScrollVelocity ? smoothVelocity : defaultVelocity, [0, 1000], [0, 5], { clamp: false } ) // In animation frame // Adjust movement based on scroll velocity moveBy += directionFactor.current * moveBy * velocityFactor.get() // Change direction based on scroll if enabled if (scrollAwareDirection && !isDragging.current) { if (velocityFactor.get() < 0) { directionFactor.current = -1 } else if (velocityFactor.get() > 0) { directionFactor.current = 1 } } ``` -------------------------------- ### Cloning Fancy Components Git Repository (Bash) Source: https://github.com/danielpetho/fancy/blob/main/CONTRIBUTING.md This command clones the 'fancy' Git repository from GitHub to the user's local machine. It is the second step in setting up the development environment after forking the repository. The user should replace 'your-username' with their actual GitHub username. ```bash git clone https://github.com/your-username/fancy.git ``` -------------------------------- ### Creating and Switching to New Git Branch (Bash) Source: https://github.com/danielpetho/fancy/blob/main/CONTRIBUTING.md This command creates a new Git branch named 'my-new-branch' and immediately switches the user's working directory to this new branch. This is a standard practice for feature development or bug fixes to isolate changes from the main branch. The user should replace 'my-new-branch' with a descriptive name for their contribution. ```bash git checkout -b my-new-branch ``` -------------------------------- ### Basic Usage - Gravity & MatterBody - Typescript Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/physics/cursor-attractor-and-gravity.mdx Demonstrates how to wrap content with the `Gravity` component to enable physics and how to make individual HTML elements interactive physics bodies using `MatterBody`. It shows configuring attractor points and cursor forces, and setting initial positions for bodies using percentage values. ```typescript
Hello world!
fancy!
``` -------------------------------- ### Basic Usage of Stacking Cards Component (TSX) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/stacking-cards.mdx Wrap your content within the StackingCards component and individual card elements within StackingCardItem components to enable the stacking and scroll animation effect. Replace the comment with your actual card content. ```tsx {/* Your card go here */} ``` -------------------------------- ### Initializing Motion Values for Position JavaScript Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx Initializes `baseX` and `baseY` using Framer Motion's `useMotionValue` hook. These values are the core drivers of the animation, tracking the fundamental horizontal and vertical position that will be transformed to create the continuous scrolling effect. ```jsx const baseX = useMotionValue(0) const baseY = useMotionValue(0) ``` -------------------------------- ### Positioning MatterBody component (TypeScript) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/physics/gravity.mdx This snippet illustrates how to set the initial position of a MatterBody component using the `x` and `y` props. Positions can be specified using percentage values relative to the container or as absolute pixel values. ```typescript
I'm physics-enabled!
``` -------------------------------- ### Transforming Marquee Position with Wrapping and Easing JavaScript Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx Uses Framer Motion's `useTransform` to map the continuously changing `baseX` value. It applies a `wrap` function to keep the value within a specific range (e.g., 0 to -100) and then optionally applies a custom `easing` function before converting it to a percentage string for CSS positioning. ```jsx const x = useTransform(baseX, (v) => { // wrap it between 0 and -100 const wrappedValue = wrap(0, -100, v) // Apply easing if provided, otherwise use linear return `${easing ? easing(wrappedValue / -100) * -100 : wrappedValue}%` }) ``` -------------------------------- ### Applying Custom Easing to Marquee Position Transformation JavaScript Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx Demonstrates applying a custom easing function to the marquee's position transformation using Framer Motion's `useTransform`. After the `baseX` value is wrapped within the animation range, the provided `easing` function is applied to the normalized value before converting it back to a percentage string for CSS. ```jsx const x = useTransform(baseX, (v) => { // Apply easing if provided, otherwise use linear const wrappedValue = wrap(0, -100, v) return `${easing ? easing(wrappedValue / -100) * -100 : wrappedValue}%` }) ``` -------------------------------- ### Rendering Repeated Marquee Content with Motion JSX Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx This JSX snippet maps over a range determined by the `repeat` prop to render the component's `children` multiple times. Each child set is wrapped in a `motion.div` which applies styles (like position via `x` or `y`) and dynamic class names based on orientation and drag state, enabling continuous scrolling. ```jsx { Array.from({ length: repeat }, (_, i) => i).map((i) => ( 0} > {children} )) } ``` -------------------------------- ### Updating 3D Box Rotation from Drag Input (TypeScript) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/css-box.mdx This TypeScript snippet illustrates how pointer movement deltas (`deltaX`, `deltaY`) are used to update the target rotation values (`baseRotateX`, `baseRotateY`) during a drag interaction. The deltas are scaled to control drag sensitivity. ```ts baseRotateX.set(startRotation.current.x - deltaY / 2) baseRotateY.set(startRotation.current.y + deltaX / 2) ``` -------------------------------- ### Combining Motion Values into CSS Transform (TypeScript) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/css-box.mdx This snippet shows how `useTransform` from framer-motion combines two spring-driven motion values (`springX`, `springY`) into a single CSS `transform` string. This transform is applied to the box element, handling rotation and positioning based on the animated values. ```ts const transform = useTransform([springX, springY], ([x, y]) => `translateZ(-${depth / 2}px) rotateX(${x}deg) rotateY(${y}deg)` ) ``` -------------------------------- ### Implementing Marquee Slowdown on Hover JavaScript/JSX Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx This code block demonstrates implementing a slowdown effect when the mouse hovers over the marquee. It uses `useRef` to track hover state, `useMotionValue` for the target speed factor, and `useSpring` for a smooth transition between speeds. The resulting `smoothHoverFactor` modifies the movement calculation in the animation loop. ```jsx // Track hover state const isHovered = useRef(false) const hoverFactorValue = useMotionValue(1) const smoothHoverFactor = useSpring(hoverFactorValue, slowDownSpringConfig) // In component JSX (isHovered.current = true)} onHoverEnd={() => (isHovered.current = false)} // ...other props > {/* ... */} // In animation frame if (isHovered.current) { hoverFactorValue.set(slowdownOnHover ? slowDownFactor : 1) } else { hoverFactorValue.set(1) } // Apply the hover factor to movement calculation let moveBy = directionFactor.current * actualBaseVelocity * (delta / 1000) * smoothHoverFactor.get() ``` -------------------------------- ### Calculating Angled Drag Projection (JSX) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx This snippet demonstrates the mathematical calculation used to project the raw horizontal (`deltaX`) and vertical (`deltaY`) pointer movement onto a specific `dragAngle`. It converts the `dragAngle` from degrees to radians and uses cosine and sine to find the components of the angle's direction, then projects the delta onto that direction. ```jsx // Convert dragAngle from degrees to radians const angleInRadians = (dragAngle * Math.PI) / 180 // Calculate the projection of the movement along the angle direction const directionX = Math.cos(angleInRadians) const directionY = Math.sin(angleInRadians) // Project the movement onto the angle direction const projectedDelta = deltaX * directionX + deltaY * directionY ``` -------------------------------- ### Defining FontVariationMapping Interface (TypeScript) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/text/variable-font-and-cursor.mdx This TypeScript interface defines the structure required for the `fontVariationMapping` prop. It specifies how the horizontal (`x`) and vertical (`y`) cursor positions are mapped to specific font variation axes, including their names and corresponding minimum and maximum values. ```typescript interface FontVariationMapping { x: { name: string; min: number; max: number }; y: { name: string; min: number; max: number }; } ``` -------------------------------- ### Apply Pixelate SVG Filter to Element - React/TypeScript & CSS Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/filter/pixelate-svg-filter.mdx Demonstrates how to include the `PixelateSvgFilter` component in a React application and apply the visual effect to an HTML element by referencing the filter's ID in the element's CSS `filter` property using the `url(#id)` syntax. Requires the component to be imported and rendered. ```typescript
filter will be applied here
``` -------------------------------- ### Helper Function for Wrapping Value within Range TypeScript Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx A utility function written in TypeScript that takes a numerical `value` and constraints (`min`, `max`). It calculates the range and uses the modulo operator to cycle the value, ensuring it always falls within the inclusive `min` and exclusive `max` bounds. ```typescript const wrap = (min: number, max: number, value: number): number => { const range = max - min return ((((value - min) % range) + range) % range) + min } ``` -------------------------------- ### Defining Background Gradient Animation Keyframes (CSS) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/background/animated-gradient-with-svg.mdx Defines the `@keyframes` rule for the `background-gradient` animation within a theme object structure. It specifies the movement path of elements (SVG circles) using `transform: translate` based on custom CSS variables (`--tx`, `--ty`) at different percentages of the animation duration. ```css @theme: { --animate-background-gradient: background-gradient; @keyframes: background-gradient { 0%, 100% { transform: translate(0, 0); animationDelay: var(--background-gradient-delay, 0s); } 20% { transform: translate(calc(100% * var(--tx-1, 1)), calc(100% * var(--ty-1, 1))); } 40% { transform: translate(calc(100% * var(--tx-2, -1)), calc(100% * var(--ty-2, 1))); } 60% { transform: translate(calc(100% * var(--tx-3, 1)), calc(100% * var(--ty-3, -1))); } 80% { transform: translate(calc(100% * var(--tx-4, -1)), calc(100% * var(--ty-4, -1))); } } }, ``` -------------------------------- ### Apply Gooey SVG Filter - React/TypeScript Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/filter/gooey-svg-filter.mdx Demonstrates how to use the `GooeySvgFilter` component in a React application. It shows adding the filter component with an optional ID and then applying it to a HTML element using the CSS `filter` property with `url(#filter-id)`. ```typescript
filter will be applied here
``` -------------------------------- ### Applying CSS Offset Properties - JSX Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/marquee-along-svg-path.mdx This JSX snippet shows how the core CSS properties `offsetPath` and `offsetDistance` are applied to an element's style within the component. `offsetPath` defines the SVG path to follow, while `offsetDistance` controls the element's position along that path. ```JSX style={{ ... offsetPath: `path('${path}')`, offsetDistance: itemOffset, }} ``` -------------------------------- ### Calculate Item Offset with useTransform - React/Framer Motion Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/marquee-along-svg-path.mdx Uses Framer Motion's `useTransform` hook to calculate each item's `offsetDistance`. It distributes items evenly along the path (0-100%) by combining a base offset with the item's index, wrapping the value as needed and optionally applying an easing function. ```JSX const itemOffset = useTransform(baseOffset, (v) => { // evenly distribute items along the path (0-100%) const position = (itemIndex * 100) / items.length const wrappedValue = wrap(0, 100, v + position) return `${easing ? easing(wrappedValue / 100) * 100 : wrappedValue}%` }) ``` -------------------------------- ### Adjusting Marquee Velocity based on Direction JavaScript Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx Calculates the effective base velocity for the marquee animation based on the desired direction. It negates the provided `baseVelocity` if the `direction` prop specifies movement to the "left" or "up", ensuring the animation proceeds correctly. ```jsx // Convert baseVelocity to the correct direction const actualBaseVelocity = direction === "left" || direction === "up" ? -baseVelocity : baseVelocity ``` -------------------------------- ### Updating Marquee Position on Animation Frame JavaScript Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx This code snippet, typically executed within Framer Motion's `useAnimationFrame` hook, calculates the displacement (`moveBy`) for the current frame. It updates either the `baseX` (horizontal) or `baseY` (vertical) motion value by adding this displacement, driving the animation forward. ```jsx // Inside useAnimationFrame let moveBy = directionFactor.current * baseVelocity * (delta / 1000) if (isHorizontal) { baseX.set(baseX.get() + moveBy) } else { baseY.set(baseY.get() + moveBy) } ``` -------------------------------- ### Assigning Random CSS Variable Values (TypeScript/React) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/background/animated-gradient-with-svg.mdx Demonstrates how to dynamically assign random values between -0.5 and 0.5 to CSS variables (`--tx-1` through `--ty-4`) within a React `style` object. These variables are used by the `background-gradient` keyframes to define the target positions for the animated SVG circles, contributing to the random movement effect. ```typescript ...\nstyle={ { ... "--tx-1": (Math.random() - 0.5), "--ty-1": (Math.random() - 0.5), "--tx-2": (Math.random() - 0.5), "--ty-2": (Math.random() - 0.5), "--tx-3": (Math.random() - 0.5), "--ty-3": (Math.random() - 0.5), "--tx-4": (Math.random() - 0.5), "--ty-4": (Math.random() - 0.5), } as React.CSSProperties } ... ``` -------------------------------- ### Calculate Rolling Z-Index - React/Framer Motion Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/marquee-along-svg-path.mdx Implements a function to calculate an element's z-index based on its position (offset distance) along the path, useful for self-crossing paths. The z-index is interpolated between `zIndexBase` and `zIndexRange` based on the normalized distance (0-1). The `useTransform` hook applies this calculation dynamically. ```JSX // Function to calculate z-index based on offset distance const calculateZIndex = useCallback( (offsetDistance: number) => { if (!enableRollingZIndex) { return undefined; } // Simple progress-based z-index const normalizedDistance = offsetDistance / 100; return Math.floor(zIndexBase + normalizedDistance * zIndexRange); }, [enableRollingZIndex, zIndexBase, zIndexRange] ); // ... // Inside an element: const zIndex = useTransform( currentOffsetDistance, (value) => calculateZIndex(value) ); ``` -------------------------------- ### Applying Drag Velocity in Animation Loop (JSX) Source: https://github.com/danielpetho/fancy/blob/main/src/content/docs/components/blocks/simple-marquee.mdx This code snippet is typically placed within an animation frame loop (like `useAnimationFrame`). When the marquee is being dragged (`isDragging.current` is true), it applies the current `dragVelocity` to update the horizontal (`baseX`) or vertical (`baseY`) position. It also includes logic to apply decay to the drag velocity while dragging and stop it if it becomes negligible, ensuring dragging movement takes precedence. ```jsx // Inside useAnimationFrame if (isDragging.current && draggable) { if (isHorizontal) { baseX.set(baseX.get() + dragVelocity.current) } else { baseY.set(baseY.get() + dragVelocity.current) } // Add decay to dragVelocity when not moving dragVelocity.current *= 0.9 // Stop completely if velocity is very small if (Math.abs(dragVelocity.current) < 0.01) { dragVelocity.current = 0 } return } ```