# Integrate `Sigil` from Motion Garden

You are helping me add the **Sigil** component to an existing project.
Everything you need is below — full source, dependencies, props and the
behavioural contract. Read it all before writing anything.

- **Component:** Sigil
- **Category:** Micro-interactions
- **Summary:** An SVG crest that traces itself in when it scrolls into view, stroke by stroke.
- **Reference:** https://motion-garden.netlify.app/components/sigil
- **Full catalog (for you, the agent):** https://motion-garden.netlify.app/llms.txt

## Stack this source assumes

- React 19 with the Next.js App Router (never the `pages/` directory)
- TypeScript, strict
- Tailwind CSS v4, CSS-first config (utilities are inline; no `tailwind.config` needed)

If my project differs, adapt the integration — but do not rewrite the animation math to suit a different stack. Ask me first.

## Dependencies

```bash
bun add clsx tailwind-merge
```

## Files to create

2 files — all of them are required. Paths are as shipped; the component may live anywhere in my project, but keep every peer file at the exact path shown so the import aliases resolve.

### 1. `components/registry/sigil/sigil.tsx`

```tsx
"use client";

import { useEffect, useRef, useState } from "react";
import { cn } from "@/lib/utils";

export interface SigilProps {
  className?: string;
  paths?: string[];
  viewBox?: string;
  duration?: number;
  delay?: number;
  strokeWidth?: number;
  glow?: number;
  replayOnLeave?: boolean;
  easing?: "ease-out" | "linear" | "ease-in-out" | "dramatic";
  strokeColor?: string;
  reducedMotion?: boolean;
}

const CREST: string[] = [
  "M 100 12 A 88 88 0 1 1 99.9 12",
  "M 100 12 L 100 42 M 100 158 L 100 188 M 12 100 L 42 100 M 158 100 L 188 100",
  "M 100 38 L 162 100 L 100 162 L 38 100 Z",
  "M 56 56 A 62 62 0 0 1 144 56",
  "M 100 66 A 34 34 0 1 1 99.9 66",
  "M 88 92 L 100 116 L 112 92 M 92 104 L 108 104",
];

const EASING: Record<NonNullable<SigilProps["easing"]>, string> = {
  "ease-out": "cubic-bezier(0.22, 1, 0.36, 1)",
  linear: "linear",
  "ease-in-out": "cubic-bezier(0.65, 0, 0.35, 1)",
  dramatic: "cubic-bezier(0.83, 0, 0.17, 1)",
};

const SIGIL_CSS = `
@keyframes sg-sigil-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  [data-sg-sigil] path { animation: none !important; stroke-dashoffset: 0 !important; }
}
`;

export default function Sigil({
  className,
  paths = CREST,
  viewBox = "0 0 200 200",
  duration = 1800,
  delay = 0,
  strokeWidth = 1.5,
  glow = 0.5,
  replayOnLeave = true,
  easing = "ease-out",
  strokeColor = "#a855f7",
  reducedMotion = false,
}: SigilProps) {
  const rootRef = useRef<HTMLDivElement>(null);
  const [drawn, setDrawn] = useState(false);

  useEffect(() => {
    const el = rootRef.current;
    if (!el) return;
    const observer = new IntersectionObserver(
      ([hit]) => {
        if (hit?.isIntersecting) setDrawn(true);
        else if (replayOnLeave) setDrawn(false);
      },
      { threshold: 0.25 },
    );
    observer.observe(el);
    return () => observer.disconnect();
  }, [replayOnLeave]);

  const step = duration * 0.42;
  const still = reducedMotion || !drawn;

  return (
    <div ref={rootRef} className={cn("relative", className)}>
      <style>{SIGIL_CSS}</style>
      <svg
        data-sg-sigil
        viewBox={viewBox}
        fill="none"
        aria-hidden
        className="h-full w-full overflow-visible"
        style={{
          filter:
            glow > 0 && !reducedMotion
              ? `drop-shadow(0 0 ${(glow * 10).toFixed(1)}px ${strokeColor})`
              : undefined,
        }}
      >
        {paths.map((d, i) => (
          <path
            key={d}
            d={d}
            pathLength={1}
            stroke={strokeColor}
            strokeWidth={strokeWidth}
            strokeLinecap="round"
            strokeLinejoin="round"
            strokeDasharray={1}
            strokeDashoffset={reducedMotion ? 0 : drawn ? undefined : 1}
            style={
              still
                ? undefined
                : {
                    strokeDashoffset: 1,
                    animation: `sg-sigil-draw ${duration}ms ${EASING[easing]} ${delay + i * step}ms forwards`,
                  }
            }
          />
        ))}
      </svg>
    </div>
  );
}
```

### 2. `lib/utils.ts` — peer util, required

```tsx
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}
```


## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `duration` | `number` | `1800` | Time for a single stroke to draw. Range 400–5000 ms. |
| `delay` | `number` | `0` | Wait after entering view before the first stroke. Range 0–2000 ms. |
| `strokeWidth` | `number` | `1.5` | Stroke width in viewBox units. Range 0.5–6. |
| `glow` | `number` | `0.5` | Bloom trailing the stroke. Range 0–1. |
| `replayOnLeave` | `boolean` | `true` | Re-arm on exit so the crest redraws on the way back. |
| `easing` | `"ease-out" | "linear" | "ease-in-out" | "dramatic"` | `"ease-out"` | Curve the stroke advances on. |
| `strokeColor` | `string (hex)` | `"#a855f7"` | Amethyst stroke. |

## Usage

```tsx
import Sigil from "@/components/registry/sigil/sigil";

<Sigil
  duration={1800}
  delay={0}
  strokeWidth={1.5}
  glow={0.5}
  replayOnLeave={true}
  easing="ease-out"
  strokeColor="#a855f7"
/>
```

The import path matches the file path above; change it if you move the component. Every value shown is the documented default — pass only what you actually want to change. The snippet lists the tunable props only: if the component's props type in the source requires others (content, handlers, data), pass those too.

## Integration rules

- Keep the `"use client"` directive. This is a client component and will not render as a Server Component.
- It fills its parent. Give the wrapper an explicit height (or a definite grid area) — against a height-auto parent it collapses to nothing.
- It takes a `reducedMotion` prop and quiesces when true. Wire it to a `prefers-reduced-motion` listener rather than hardcoding `false`.
- `lib/utils.ts` is required, not optional. It exports the `cn` helper the component imports from `@/lib/utils` — keep it at that path, or rewrite every `cn` import to wherever you already keep yours. If your project is shadcn-based you almost certainly have this file already; keep yours and drop mine.

## Your task

1. Tell me where in my project this should live and why.
2. Create the files above verbatim.
3. Wire the component into the place I point you at, with sensible props for that context.
4. Flag anything in my setup that conflicts with the stack assumptions above.

Do not restyle the component or alter the animation math unless I ask.
