diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8cad4b5..a85d50e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,31 @@ jobs: e2e: name: End-to-end runs-on: ubuntu-latest + # Every docs page loads the session, favorites and comments, which are backed by Postgres. Run + # against a real throwaway database so those calls succeed instead of returning 500. + services: + postgres: + image: postgres:16 + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: modus_ui + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U postgres" + --health-interval 5s + --health-timeout 5s + --health-retries 10 + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/modus_ui?schema=modus_ui + DIRECT_URL: postgresql://postgres:postgres@localhost:5432/modus_ui?schema=modus_ui + # Throwaway values: nothing in CI signs anyone in, but Better Auth needs them to start. + BETTER_AUTH_SECRET: ci-only-secret-0123456789abcdef0123456789abcdef + BETTER_AUTH_URL: http://localhost:3100 + GOOGLE_OAUTH_CLIENT_ID: ci-client-id + GOOGLE_OAUTH_CLIENT_SECRET: ci-client-secret + # One machine loads ~1,700 pages; Better Auth's per-IP limit would answer some with 429. + AUTH_RATE_LIMIT: "off" steps: - uses: actions/checkout@v5 - uses: pnpm/action-setup@v4 @@ -69,6 +94,7 @@ jobs: cache: pnpm - run: pnpm install --frozen-lockfile - run: pnpm exec playwright install --with-deps chromium + - run: pnpm db:migrate - run: pnpm test:e2e - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} diff --git a/AGENTS.md b/AGENTS.md index e4d40b3..ef8320c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,7 +10,7 @@ When working in this repository, you MUST follow these rules: 1. **Tech Stack**: Use TypeScript (`.tsx`), Tailwind CSS variables (e.g. `bg-background`, `text-primary`), and `framer-motion` for all animations. Do NOT use `gsap`. 2. **Utilities**: Always use the `cn()` utility from `@/lib/utils` for class name merging. -3. **CLI**: Documentation must instruct users to use `npx @modus-ui/cli add `. Do NOT use `npx shadcn`, `npx react-ui-component` or the unscoped `npx modus-ui` (that npm package belongs to someone else). +3. **CLI**: Documentation must instruct users to use `npx @modus-ui/cli add `; write the npm form in the docs and the site shows pnpm, yarn and bun tabs for it (`src/lib/install.ts`). Do NOT use `npx shadcn`, `npx react-ui-component` or the unscoped `npx modus-ui` (that npm package belongs to someone else). 4. **Registration**: Start new components with `pnpm new:component --name --category `. Register a component in exactly two places: its entry (name, title, category, dependencies, files) in `src/registry/index.ts` and its demo in `src/registry/demos.ts`. The sidebar, components index and previews are derived from these; never hand-edit lists there. 5. **Theme colors**: Tokens are bare HSL channels, so use `hsl(var(--primary))`, never `var(--primary)`. On a ``, resolve colors through `getComputedStyle` first. -6. **Native components**: Components in the `Native` category are React Native (Expo), with `platform: "native"` and `dependencies: []` in the registry. Import only from `react-native`; use `Animated` and `PanResponder`, not `framer-motion`, `className` or `cn()`. Take colors through a `colors?: Partial<...>` prop with plain defaults (there are no CSS variables in React Native), and read the system setting with `AccessibilityInfo.isReduceMotionEnabled()`. Use `NATIVE_DRIVER = Platform.OS !== "web"` and `userSelect: "none"` on draggable surfaces so the docs preview works with a mouse. The demo wraps its content in `NativeStage` (`src/registry/native-stage.tsx`) and is registered with `dynamic(..., { ssr: false })` in `demos.ts`. +6. **React Native components**: Components in the `React Native` category are React Native (Expo), with `platform: "native"` and `dependencies: []` in the registry. Import only from `react-native`; use `Animated` and `PanResponder`, not `framer-motion`, `className` or `cn()`. Take colors through a `colors?: Partial<...>` prop with plain defaults (there are no CSS variables in React Native), and read the system setting with `AccessibilityInfo.isReduceMotionEnabled()`. Use `NATIVE_DRIVER = Platform.OS !== "web"` and `userSelect: "none"` on draggable surfaces so the docs preview works with a mouse. The demo wraps its content in `NativeStage` (`src/registry/native-stage.tsx`), which draws a phone frame around it; its `height` is the screen area between the status bar and the home indicator and is registered with `dynamic(..., { ssr: false })` in `demos.ts`. diff --git a/README.md b/README.md index 8289dce..8be0d8d 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,15 @@ Modus UI is **not** a package you import from. You own the code: add a component npx @modus-ui/cli add blur-text ``` +Use whichever package manager you prefer. Each component page has a tab for each: + +| Package manager | Command | +| :-------------- | :------------------------------------- | +| npm | `npx @modus-ui/cli add blur-text` | +| pnpm | `pnpm dlx @modus-ui/cli add blur-text` | +| yarn | `yarn dlx @modus-ui/cli add blur-text` | +| bun | `bunx @modus-ui/cli add blur-text` | + The CLI writes the component into your project and lists the npm packages it needs. Every component page shows its own command. To copy and paste instead, open the **Code** tab on any component page and save the file as `components/ui/.tsx`. Components import `cn()` from `@/lib/utils`: @@ -83,17 +92,17 @@ For Cursor, Windsurf or VS Code setup, see [`packages/mcp`](packages/mcp). The d ## Components -| Category | Components | -| ---------------- | ----------------------------------------------------------------------------------------------------------------------------- | -| **Navigation** | Liquid Tabs, Flowing Menu, Morphing Navbar, Floating Dock, Notch Footer, Process Stepper | -| **Actions** | Magnet, Magic Button, Animated Button, Pulse Button | -| **Data Display** | Bounce Cards, Masonry Grid, Animated List, Kinetic Carousel, Expandable Showcase, Focus Card, Rotating Card, Tilt Card | -| **Backgrounds** | Cursor Grid, Waves, Letter Glitch, Aurora Background, Circuit Background, Grid Motion | -| **Typography** | Scroll Velocity, Text Pressure, True Focus, Gradient Text, Blur Text, Split Text, Decrypted Text, Shimmer Text, Floating Text | -| **Components** | Scratch to Reveal, Stack, Star Border, Tilted Card, Pixel Card, Click Spark, Spotlight Card, Border Glow | -| **Native** | Swipe Actions, Snap Sheet, Glide Segments, Swipe Deck, Fan Menu, Pin Pad | - -**Native** components are React Native (Expo) files that import only `react-native`, so they need no extra packages. Install them the same way (`npx @modus-ui/cli add swipe-actions`); the docs preview them live in the browser through react-native-web. +| Category | Components | +| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| **Navigation** | Liquid Tabs, Flowing Menu, Morphing Navbar, Floating Dock, Notch Footer, Process Stepper | +| **Actions** | Magnet, Magic Button, Animated Button, Pulse Button | +| **Data Display** | Bounce Cards, Masonry Grid, Animated List, Kinetic Carousel, Expandable Showcase, Focus Card, Rotating Card, Tilt Card | +| **Backgrounds** | Cursor Grid, Waves, Letter Glitch, Aurora Background, Circuit Background, Grid Motion | +| **Typography** | Scroll Velocity, Text Pressure, True Focus, Gradient Text, Blur Text, Split Text, Decrypted Text, Shimmer Text, Floating Text | +| **Components** | Scratch to Reveal, Stack, Star Border, Tilted Card, Pixel Card, Click Spark, Spotlight Card, Border Glow | +| **React Native** | Swipe Actions, Snap Sheet, Glide Segments, Swipe Deck, Fan Menu, Pin Pad, Flick Toast, Fold Panel, Snap Carousel, Slide Switch, Shimmer Block, Parallax Header, Bubble Tab Bar, Roll Number, Star Rating, Value Slider, Expand Search, Intro Pager, Drag List, Long Press Menu, Slide Confirm, Calendar Strip, Step Tracker, Chip Input, Typing Dots, Marquee Ticker, Choice Chips, Hold Stepper | + +**React Native** components are Expo files that import only `react-native`, so they need no extra packages. Install them the same way (`npx @modus-ui/cli add swipe-actions`); the docs preview them live in the browser through react-native-web. ## Documentation diff --git a/packages/cli/README.md b/packages/cli/README.md index aae5241..0b8553b 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -9,6 +9,8 @@ npx @modus-ui/cli add blur-text magnet npx @modus-ui/cli list ``` +With another package manager, swap `npx` for its runner: `pnpm dlx`, `yarn dlx` or `bunx`. + ## Commands ### `add ` diff --git a/public/registry/bubble-tab-bar.json b/public/registry/bubble-tab-bar.json new file mode 100644 index 0000000..18a02f1 --- /dev/null +++ b/public/registry/bubble-tab-bar.json @@ -0,0 +1,15 @@ +{ + "name": "bubble-tab-bar", + "title": "Bubble Tab Bar", + "category": "React Native", + "type": "components:ui", + "platform": "native", + "added": "2026-11-02", + "dependencies": [], + "files": [ + { + "path": "registry/bubble-tab-bar.tsx", + "content": "import { useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport {\n AccessibilityInfo,\n Animated,\n Platform,\n Pressable,\n StyleSheet,\n Text,\n View,\n type LayoutChangeEvent,\n type StyleProp,\n type ViewStyle,\n} from \"react-native\";\n\nconst NATIVE_DRIVER = Platform.OS !== \"web\";\nconst PAD = 6;\nconst TAB_HEIGHT = 52;\nconst INACTIVE_WIDTH = 56;\nconst STRETCH = 16;\n\nexport interface BubbleTab {\n id: string;\n label: string;\n /** The tab's icon, or a function that receives the tab's current color and returns it. */\n icon: ReactNode | ((color: string) => ReactNode);\n}\n\nexport interface BubbleTabBarColors {\n bar: string;\n pill: string;\n active: string;\n inactive: string;\n}\n\nconst DEFAULT_COLORS: BubbleTabBarColors = {\n bar: \"#ffffff\",\n pill: \"#4f46e5\",\n active: \"#ffffff\",\n inactive: \"#6b7280\",\n};\n\nfunction useReduceMotion() {\n const [reduce, setReduce] = useState(false);\n useEffect(() => {\n AccessibilityInfo.isReduceMotionEnabled().then(setReduce);\n const sub = AccessibilityInfo.addEventListener(\"reduceMotionChanged\", setReduce);\n return () => sub.remove();\n }, []);\n return reduce;\n}\n\nexport interface BubbleTabBarProps {\n tabs: BubbleTab[];\n /** The `id` of the selected tab. */\n value: string;\n onChange: (id: string) => void;\n colors?: Partial;\n style?: StyleProp;\n}\n\ninterface TabValues {\n width: Animated.Value;\n label: Animated.Value;\n}\n\n/**\n * A bottom tab bar where a rounded pill slides behind the selected tab, stretching a little as it\n * travels. The selected tab opens up to show its label next to the icon; the others stay icon-only.\n * Every tab is at least 44 points tall and wide, and the bar is a tablist to screen readers.\n */\nexport function BubbleTabBar({ tabs, value, onChange, colors, style }: BubbleTabBarProps) {\n const palette = { ...DEFAULT_COLORS, ...colors };\n const reduceMotion = useReduceMotion();\n const [barWidth, setBarWidth] = useState(0);\n\n const index = Math.max(\n 0,\n tabs.findIndex((tab) => tab.id === value),\n );\n const count = tabs.length;\n const inner = Math.max(0, barWidth - PAD * 2);\n const activeWidth = Math.max(INACTIVE_WIDTH, inner - (count - 1) * INACTIVE_WIDTH);\n\n const pillLeft = useRef(new Animated.Value(PAD)).current;\n const pillWidth = useRef(new Animated.Value(INACTIVE_WIDTH)).current;\n const stretch = useRef(new Animated.Value(0)).current;\n const perTab = useRef(new Map()).current;\n // The last layout the animated values were set for; a change of width jumps instead of animating.\n const settled = useRef({ width: 0, index: -1 });\n\n const valuesFor = (id: string): TabValues => {\n let values = perTab.get(id);\n if (!values) {\n values = { width: new Animated.Value(INACTIVE_WIDTH), label: new Animated.Value(0) };\n perTab.set(id, values);\n }\n return values;\n };\n\n const ids = tabs.map((tab) => tab.id).join(\"|\");\n\n useEffect(() => {\n if (barWidth === 0) return;\n const jump = reduceMotion || settled.current.width !== barWidth || settled.current.index === -1;\n settled.current = { width: barWidth, index };\n\n const leftTarget = PAD + index * INACTIVE_WIDTH;\n const items = ids.split(\"|\").map((id, i) => ({\n values: valuesFor(id),\n width: i === index ? activeWidth : INACTIVE_WIDTH,\n label: i === index ? 1 : 0,\n }));\n\n if (jump) {\n pillLeft.setValue(leftTarget);\n pillWidth.setValue(activeWidth);\n stretch.setValue(0);\n items.forEach((item) => {\n item.values.width.setValue(item.width);\n item.values.label.setValue(item.label);\n });\n return;\n }\n\n // Layout properties (left, width) cannot use the native driver.\n const spring = (value: Animated.Value, toValue: number) =>\n Animated.spring(value, {\n toValue,\n stiffness: 320,\n damping: 26,\n mass: 1,\n useNativeDriver: false,\n });\n const animation = Animated.parallel([\n spring(pillLeft, leftTarget),\n spring(pillWidth, activeWidth),\n Animated.sequence([\n Animated.timing(stretch, { toValue: 1, duration: 110, useNativeDriver: false }),\n Animated.spring(stretch, {\n toValue: 0,\n stiffness: 260,\n damping: 18,\n mass: 1,\n useNativeDriver: false,\n }),\n ]),\n ...items.map((item) => spring(item.values.width, item.width)),\n ...items.map((item) =>\n Animated.timing(item.values.label, {\n toValue: item.label,\n duration: 180,\n useNativeDriver: NATIVE_DRIVER,\n }),\n ),\n ]);\n animation.start();\n return () => animation.stop();\n // valuesFor only reads refs, and the animated values are stable.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [index, barWidth, activeWidth, ids, reduceMotion]);\n\n const animatedPillWidth = useMemo(\n () =>\n Animated.add(\n pillWidth,\n stretch.interpolate({ inputRange: [0, 1], outputRange: [0, STRETCH] }),\n ),\n [pillWidth, stretch],\n );\n const pillStyle = useMemo(\n () => [\n styles.pill,\n { backgroundColor: palette.pill, left: pillLeft, width: animatedPillWidth },\n ],\n [palette.pill, pillLeft, animatedPillWidth],\n );\n\n return (\n setBarWidth(event.nativeEvent.layout.width)}\n style={[styles.bar, { backgroundColor: palette.bar }, style]}\n >\n \n {tabs.map((tab) => (\n onChange(tab.id)}\n />\n ))}\n \n );\n}\n\nfunction TabItem({\n tab,\n selected,\n values,\n colors,\n onPress,\n}: {\n tab: BubbleTab;\n selected: boolean;\n values: TabValues;\n colors: BubbleTabBarColors;\n onPress: () => void;\n}) {\n const color = selected ? colors.active : colors.inactive;\n const boxStyle = useMemo(() => [styles.tab, { width: values.width }], [values.width]);\n const labelStyle = useMemo(() => [styles.label, { opacity: values.label }], [values.label]);\n\n return (\n \n [styles.press, pressed && styles.pressed]}\n >\n {typeof tab.icon === \"function\" ? tab.icon(color) : tab.icon}\n \n {tab.label}\n \n \n \n );\n}\n\nconst styles = StyleSheet.create({\n bar: {\n flexDirection: \"row\",\n alignItems: \"center\",\n padding: PAD,\n borderRadius: (TAB_HEIGHT + PAD * 2) / 2,\n userSelect: \"none\",\n boxShadow: \"0 6px 22px rgba(0, 0, 0, 0.14)\",\n },\n pill: {\n position: \"absolute\",\n top: PAD,\n height: TAB_HEIGHT,\n borderRadius: TAB_HEIGHT / 2,\n },\n tab: { height: TAB_HEIGHT, borderRadius: TAB_HEIGHT / 2, overflow: \"hidden\" },\n press: {\n flex: 1,\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 8,\n paddingHorizontal: 10,\n },\n pressed: { opacity: 0.7 },\n label: { fontSize: 14, fontWeight: \"700\" },\n});\n" + } + ] +} \ No newline at end of file diff --git a/public/registry/calendar-strip.json b/public/registry/calendar-strip.json new file mode 100644 index 0000000..88eaed0 --- /dev/null +++ b/public/registry/calendar-strip.json @@ -0,0 +1,15 @@ +{ + "name": "calendar-strip", + "title": "Calendar Strip", + "category": "React Native", + "type": "components:ui", + "platform": "native", + "added": "2026-11-02", + "dependencies": [], + "files": [ + { + "path": "registry/calendar-strip.tsx", + "content": "import { useEffect, useMemo, useRef, useState, type ElementRef } from \"react\";\nimport {\n AccessibilityInfo,\n Animated,\n Platform,\n Pressable,\n ScrollView,\n StyleSheet,\n Text,\n View,\n type LayoutChangeEvent,\n type StyleProp,\n type ViewStyle,\n} from \"react-native\";\n\nconst NATIVE_DRIVER = Platform.OS !== \"web\";\nconst CELL = 52;\nconst CELL_HEIGHT = 76;\nconst PILL_INSET = 4;\n\nexport interface CalendarStripColors {\n pill: string;\n text: string;\n selectedText: string;\n mutedText: string;\n dot: string;\n}\n\nconst DEFAULT_COLORS: CalendarStripColors = {\n pill: \"#4f46e5\",\n text: \"#111827\",\n selectedText: \"#ffffff\",\n mutedText: \"#6b7280\",\n dot: \"#f59e0b\",\n};\n\nfunction useReduceMotion() {\n const [reduce, setReduce] = useState(false);\n useEffect(() => {\n AccessibilityInfo.isReduceMotionEnabled().then(setReduce);\n const sub = AccessibilityInfo.addEventListener(\"reduceMotionChanged\", setReduce);\n return () => sub.remove();\n }, []);\n return reduce;\n}\n\nconst pad = (n: number) => String(n).padStart(2, \"0\");\n\n/** YYYY-MM-DD for a local date. Dates here are always local, never UTC, so a day never shifts. */\nfunction toISO(date: Date) {\n return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;\n}\n\n/** Builds a local date from YYYY-MM-DD. `new Date(\"YYYY-MM-DD\")` would be UTC and can land on the day before. */\nfunction fromISO(iso: string) {\n const [year, month, day] = iso.split(\"-\").map(Number);\n return new Date(year, month - 1, day);\n}\n\nexport interface CalendarStripProps {\n /** The selected day, as YYYY-MM-DD. */\n selected: string;\n onSelect: (date: string) => void;\n /** First day shown, as YYYY-MM-DD. Defaults to today in local time. */\n startDate?: string;\n /** How many days the strip covers. */\n days?: number;\n /** Days (YYYY-MM-DD) that show a small dot, for example days with events. */\n marked?: string[];\n colors?: Partial;\n style?: StyleProp;\n}\n\n/**\n * A horizontal strip of days. A pill glides behind the selected day on a spring, and the strip\n * scrolls to keep that day centred. Dates are local dates in YYYY-MM-DD form, so nothing shifts a\n * day near midnight or across time zones. Each day is a button that reads out its full date.\n */\nexport function CalendarStrip({\n selected,\n onSelect,\n startDate,\n days = 21,\n marked,\n colors,\n style,\n}: CalendarStripProps) {\n const palette = { ...DEFAULT_COLORS, ...colors };\n const reduceMotion = useReduceMotion();\n const [width, setWidth] = useState(0);\n const scroll = useRef>(null);\n const pillX = useRef(new Animated.Value(0)).current;\n const placed = useRef(false);\n\n const start = startDate ?? toISO(new Date());\n const list = useMemo(() => {\n const first = fromISO(start);\n return Array.from({ length: days }, (_, i) => {\n const date = new Date(first.getFullYear(), first.getMonth(), first.getDate() + i);\n return { iso: toISO(date), date };\n });\n }, [start, days]);\n\n const weekday = useMemo(() => new Intl.DateTimeFormat(undefined, { weekday: \"short\" }), []);\n const spoken = useMemo(\n () => new Intl.DateTimeFormat(undefined, { weekday: \"long\", day: \"numeric\", month: \"long\" }),\n [],\n );\n const markedSet = useMemo(() => new Set(marked), [marked]);\n\n const index = list.findIndex((day) => day.iso === selected);\n\n useEffect(() => {\n if (index < 0 || width === 0) return;\n const target = index * CELL;\n const offset = Math.max(0, target - (width - CELL) / 2);\n if (!placed.current || reduceMotion) {\n placed.current = true;\n pillX.setValue(target);\n scroll.current?.scrollTo({ x: offset, animated: false });\n return;\n }\n Animated.spring(pillX, {\n toValue: target,\n stiffness: 420,\n damping: 30,\n mass: 1,\n useNativeDriver: NATIVE_DRIVER,\n }).start();\n scroll.current?.scrollTo({ x: offset, animated: true });\n }, [index, width, reduceMotion, pillX]);\n\n return (\n setWidth(event.nativeEvent.layout.width)}\n style={style}\n >\n \n {index >= 0 ? (\n \n ) : null}\n {list.map(({ iso, date }) => {\n const isSelected = iso === selected;\n const hasEvents = markedSet.has(iso);\n return (\n onSelect(iso)}\n style={({ pressed }) => [styles.cell, pressed && styles.pressed]}\n >\n \n {weekday.format(date)}\n \n \n {date.getDate()}\n \n \n \n );\n })}\n \n \n );\n}\n\nconst styles = StyleSheet.create({\n pill: {\n position: \"absolute\",\n top: 0,\n bottom: 0,\n left: PILL_INSET,\n width: CELL - PILL_INSET * 2,\n borderRadius: (CELL - PILL_INSET * 2) / 2,\n },\n cell: {\n width: CELL,\n height: CELL_HEIGHT,\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 4,\n userSelect: \"none\",\n },\n pressed: { opacity: 0.7 },\n weekday: { fontSize: 11, fontWeight: \"600\", letterSpacing: 0.4, textTransform: \"uppercase\" },\n day: { fontSize: 19, fontWeight: \"700\" },\n dot: { width: 5, height: 5, borderRadius: 3 },\n});\n" + } + ] +} \ No newline at end of file diff --git a/public/registry/chip-input.json b/public/registry/chip-input.json new file mode 100644 index 0000000..acdef3a --- /dev/null +++ b/public/registry/chip-input.json @@ -0,0 +1,15 @@ +{ + "name": "chip-input", + "title": "Chip Input", + "category": "React Native", + "type": "components:ui", + "platform": "native", + "added": "2026-11-02", + "dependencies": [], + "files": [ + { + "path": "registry/chip-input.tsx", + "content": "import { useEffect, useMemo, useRef, useState, type ComponentRef } from \"react\";\nimport {\n AccessibilityInfo,\n Animated,\n Platform,\n Pressable,\n StyleSheet,\n Text,\n TextInput,\n View,\n type StyleProp,\n type TextInputKeyPressEvent,\n type ViewStyle,\n} from \"react-native\";\n\nconst NATIVE_DRIVER = Platform.OS !== \"web\";\n\nexport interface ChipInputColors {\n field: string;\n chip: string;\n chipText: string;\n text: string;\n placeholder: string;\n border: string;\n focus: string;\n}\n\nconst DEFAULT_COLORS: ChipInputColors = {\n field: \"#ffffff\",\n chip: \"#eef2ff\",\n chipText: \"#3730a3\",\n text: \"#111827\",\n placeholder: \"#9ca3af\",\n border: \"#d1d5db\",\n focus: \"#4f46e5\",\n};\n\nfunction useReduceMotion() {\n const [reduce, setReduce] = useState(false);\n useEffect(() => {\n AccessibilityInfo.isReduceMotionEnabled().then(setReduce);\n const sub = AccessibilityInfo.addEventListener(\"reduceMotionChanged\", setReduce);\n return () => sub.remove();\n }, []);\n return reduce;\n}\n\nexport interface ChipInputProps {\n value: string[];\n onChange: (next: string[]) => void;\n placeholder?: string;\n /** No more chips are added once there are this many. */\n maxChips?: number;\n /** Return false to reject a chip. It receives the trimmed text. */\n validate?: (text: string) => boolean;\n /** Allow the same chip twice. Without it a repeat, in any letter case, is ignored. */\n allowDuplicates?: boolean;\n colors?: Partial;\n style?: StyleProp;\n}\n\n/**\n * A tag input. Type and press Enter or comma to turn the text into a chip; chips pop in, wrap onto\n * new lines, and each has its own remove button. Backspace on an empty field removes the last chip,\n * and leaving the field keeps whatever was typed. Additions and removals are announced.\n */\nexport function ChipInput({\n value,\n onChange,\n placeholder = \"Add a tag\",\n maxChips = 8,\n validate,\n allowDuplicates = false,\n colors,\n style,\n}: ChipInputProps) {\n const palette = { ...DEFAULT_COLORS, ...colors };\n const reduceMotion = useReduceMotion();\n const inputRef = useRef>(null);\n const [text, setText] = useState(\"\");\n const [focused, setFocused] = useState(false);\n const [status, setStatus] = useState(\"\");\n\n // Chips accepted from `raw`, in order, on top of `list`. Rejected text is dropped.\n const accept = (list: string[], raw: string[]) => {\n const next = [...list];\n const added: string[] = [];\n for (const piece of raw) {\n const chip = piece.trim();\n if (!chip || next.length >= maxChips) continue;\n if (!allowDuplicates && next.some((item) => item.toLowerCase() === chip.toLowerCase()))\n continue;\n if (validate && !validate(chip)) continue;\n next.push(chip);\n added.push(chip);\n }\n return { next, added };\n };\n\n const commit = (raw: string[]) => {\n const { next, added } = accept(value, raw);\n if (added.length > 0) {\n onChange(next);\n setStatus(`Added ${added.join(\", \")}`);\n }\n return added.length > 0;\n };\n\n const handleChangeText = (incoming: string) => {\n if (!incoming.includes(\",\")) {\n setText(incoming);\n return;\n }\n // Typing or pasting \"a,b,c\" adds a and b; c stays in the field as the next chip.\n const pieces = incoming.split(\",\");\n const rest = pieces.pop() ?? \"\";\n commit(pieces);\n setText(rest);\n };\n\n const handleSubmit = () => {\n if (commit([text])) setText(\"\");\n };\n\n const handleKeyPress = (event: TextInputKeyPressEvent) => {\n if (event.nativeEvent.key === \"Backspace\" && text === \"\" && value.length > 0) {\n removeAt(value.length - 1);\n }\n };\n\n const handleBlur = () => {\n setFocused(false);\n // Leaving the field keeps a half-typed chip instead of silently losing it.\n if (commit([text]) || text.trim() === \"\") setText(\"\");\n };\n\n const removeAt = (index: number) => {\n setStatus(`Removed ${value[index]}`);\n onChange(value.filter((_, i) => i !== index));\n };\n\n return (\n \n inputRef.current?.focus()}\n style={[\n styles.field,\n { backgroundColor: palette.field, borderColor: focused ? palette.focus : palette.border },\n ]}\n >\n {value.map((chip, index) => (\n removeAt(index)}\n />\n ))}\n setFocused(true)}\n onBlur={handleBlur}\n submitBehavior=\"submit\"\n returnKeyType=\"done\"\n autoCapitalize=\"none\"\n autoCorrect={false}\n placeholder={value.length >= maxChips ? \"\" : placeholder}\n placeholderTextColor={palette.placeholder}\n accessibilityLabel={placeholder}\n selectionColor={palette.focus}\n style={[styles.input, { color: palette.text }]}\n />\n \n \n {status}\n \n \n );\n}\n\nfunction Chip({\n label,\n palette,\n reduceMotion,\n onRemove,\n}: {\n label: string;\n palette: ChipInputColors;\n reduceMotion: boolean;\n onRemove: () => void;\n}) {\n const pop = useRef(new Animated.Value(reduceMotion ? 1 : 0)).current;\n\n useEffect(() => {\n if (reduceMotion) {\n pop.setValue(1);\n return;\n }\n Animated.spring(pop, {\n toValue: 1,\n stiffness: 380,\n damping: 16,\n mass: 1,\n useNativeDriver: NATIVE_DRIVER,\n }).start();\n }, [reduceMotion, pop]);\n\n const popStyle = useMemo(\n () => ({\n opacity: pop.interpolate({ inputRange: [0, 0.6, 1], outputRange: [0, 1, 1] }),\n transform: [{ scale: pop.interpolate({ inputRange: [0, 1], outputRange: [0.6, 1] }) }],\n }),\n [pop],\n );\n\n return (\n \n \n {label}\n \n [styles.remove, pressed && styles.pressed]}\n >\n ×\n \n \n );\n}\n\nconst styles = StyleSheet.create({\n field: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n alignItems: \"center\",\n gap: 6,\n minHeight: 48,\n padding: 8,\n borderWidth: 1.5,\n borderRadius: 14,\n },\n chip: {\n flexDirection: \"row\",\n alignItems: \"center\",\n gap: 4,\n maxWidth: \"100%\",\n paddingLeft: 12,\n paddingRight: 6,\n height: 30,\n borderRadius: 15,\n },\n chipText: { flexShrink: 1, fontSize: 14, fontWeight: \"600\" },\n remove: {\n width: 22,\n height: 22,\n borderRadius: 11,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n removeText: { fontSize: 18, lineHeight: 20, fontWeight: \"600\" },\n pressed: { opacity: 0.6 },\n input: {\n flexGrow: 1,\n flexBasis: 90,\n minWidth: 90,\n height: 30,\n paddingVertical: 0,\n paddingHorizontal: 4,\n fontSize: 15,\n // On the web the browser draws its own focus outline; the field's border is the focus ring here.\n outlineWidth: 0,\n },\n // Present for screen readers only: one pixel, fully transparent.\n status: { position: \"absolute\", width: 1, height: 1, opacity: 0 },\n});\n" + } + ] +} \ No newline at end of file diff --git a/public/registry/choice-chips.json b/public/registry/choice-chips.json new file mode 100644 index 0000000..20c9623 --- /dev/null +++ b/public/registry/choice-chips.json @@ -0,0 +1,15 @@ +{ + "name": "choice-chips", + "title": "Choice Chips", + "category": "React Native", + "type": "components:ui", + "platform": "native", + "added": "2026-11-02", + "dependencies": [], + "files": [ + { + "path": "registry/choice-chips.tsx", + "content": "import { useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n AccessibilityInfo,\n Animated,\n Platform,\n Pressable,\n StyleSheet,\n View,\n type StyleProp,\n type ViewStyle,\n} from \"react-native\";\n\nconst NATIVE_DRIVER = Platform.OS !== \"web\";\n// Width reserved for the check mark, which opens up as a chip is selected.\nconst CHECK_WIDTH = 20;\n\nexport interface ChoiceChipOption {\n value: string;\n label: string;\n}\n\nexport interface ChoiceChipsColors {\n chip: string;\n selectedChip: string;\n text: string;\n selectedText: string;\n border: string;\n}\n\nconst DEFAULT_COLORS: ChoiceChipsColors = {\n chip: \"#f3f4f6\",\n selectedChip: \"#4f46e5\",\n text: \"#374151\",\n selectedText: \"#ffffff\",\n border: \"#d1d5db\",\n};\n\nfunction useReduceMotion() {\n const [reduce, setReduce] = useState(false);\n useEffect(() => {\n AccessibilityInfo.isReduceMotionEnabled().then(setReduce);\n const sub = AccessibilityInfo.addEventListener(\"reduceMotionChanged\", setReduce);\n return () => sub.remove();\n }, []);\n return reduce;\n}\n\nexport interface ChoiceChipsProps {\n options: ChoiceChipOption[];\n /** The selected values. */\n value: string[];\n onChange: (next: string[]) => void;\n /** Allow more than one chip to be selected. Otherwise it behaves like a radio group. */\n multiple?: boolean;\n /** The fewest chips that may stay selected. With 1, the last selected chip cannot be turned off. */\n min?: number;\n /** The most chips that may be selected at once, in multiple mode. Further chips dim until one is removed. */\n max?: number;\n colors?: Partial;\n style?: StyleProp;\n}\n\n/**\n * Selectable chips for a single choice or several. Selecting blends the chip to its selected color\n * and opens a check mark in front of the label, the chip pushes in while pressed, and everything\n * wraps onto as many lines as it needs. Each chip is at least 44pt tall and reads as a radio button\n * or checkbox to screen readers.\n */\nexport function ChoiceChips({\n options,\n value,\n onChange,\n multiple = false,\n min = 0,\n max,\n colors,\n style,\n}: ChoiceChipsProps) {\n const palette = { ...DEFAULT_COLORS, ...colors };\n const reduceMotion = useReduceMotion();\n const atMax = multiple && max !== undefined && value.length >= max;\n\n const toggle = (option: string) => {\n const selected = value.includes(option);\n if (!multiple) {\n if (selected) {\n if (min < 1) onChange([]);\n return;\n }\n onChange([option]);\n return;\n }\n if (selected) {\n if (value.length > min) onChange(value.filter((item) => item !== option));\n return;\n }\n if (!atMax) onChange([...value, option]);\n };\n\n return (\n \n {options.map((option) => {\n const selected = value.includes(option.value);\n return (\n toggle(option.value)}\n />\n );\n })}\n \n );\n}\n\ninterface ChipProps {\n label: string;\n selected: boolean;\n multiple: boolean;\n disabled: boolean;\n reduceMotion: boolean;\n palette: ChoiceChipsColors;\n onPress: () => void;\n}\n\nfunction Chip({ label, selected, multiple, disabled, reduceMotion, palette, onPress }: ChipProps) {\n // 0 = off, 1 = on. Everything that changes with selection reads from this one value.\n const progress = useRef(new Animated.Value(selected ? 1 : 0)).current;\n const press = useRef(new Animated.Value(1)).current;\n\n useEffect(() => {\n if (reduceMotion) {\n progress.setValue(selected ? 1 : 0);\n return;\n }\n Animated.spring(progress, {\n toValue: selected ? 1 : 0,\n stiffness: 380,\n damping: 26,\n mass: 1,\n // Width and color are layout and paint properties, so this one runs on the JS driver.\n useNativeDriver: false,\n }).start();\n }, [selected, reduceMotion, progress]);\n\n // Built once per palette so the animated styles keep their identity between renders.\n const animated = useMemo(() => {\n const clamp = { extrapolate: \"clamp\" as const };\n return {\n fill: progress.interpolate({ inputRange: [0, 1], outputRange: [0, 1], ...clamp }),\n checkWidth: progress.interpolate({\n inputRange: [0, 1],\n outputRange: [0, CHECK_WIDTH],\n ...clamp,\n }),\n checkScale: progress.interpolate({ inputRange: [0, 1], outputRange: [0.4, 1], ...clamp }),\n textColor: progress.interpolate({\n inputRange: [0, 1],\n outputRange: [palette.text, palette.selectedText],\n ...clamp,\n }),\n borderColor: progress.interpolate({\n inputRange: [0, 1],\n outputRange: [palette.border, palette.selectedChip],\n ...clamp,\n }),\n };\n }, [progress, palette.text, palette.selectedText, palette.border, palette.selectedChip]);\n\n const pressTo = (toValue: number) => {\n if (reduceMotion) return;\n Animated.spring(press, {\n toValue,\n stiffness: 520,\n damping: 28,\n mass: 1,\n useNativeDriver: NATIVE_DRIVER,\n }).start();\n };\n\n return (\n \n pressTo(0.95)}\n onPressOut={() => pressTo(1)}\n >\n \n \n \n \n ✓\n \n \n \n {label}\n \n \n \n \n );\n}\n\nconst styles = StyleSheet.create({\n row: { flexDirection: \"row\", flexWrap: \"wrap\", gap: 10 },\n // userSelect keeps a quick double press on the web from selecting the label.\n chip: {\n minHeight: 44,\n paddingHorizontal: 16,\n borderRadius: 22,\n borderWidth: 1,\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n userSelect: \"none\",\n },\n fill: { position: \"absolute\", top: 0, right: 0, bottom: 0, left: 0 },\n check: { overflow: \"hidden\", alignItems: \"flex-start\", justifyContent: \"center\" },\n checkGlyph: { fontSize: 14, fontWeight: \"700\" },\n label: { fontSize: 15, fontWeight: \"600\" },\n});\n" + } + ] +} \ No newline at end of file diff --git a/public/registry/curved-carousel-hero.json b/public/registry/curved-carousel-hero.json index 613c280..d9249f4 100644 --- a/public/registry/curved-carousel-hero.json +++ b/public/registry/curved-carousel-hero.json @@ -11,7 +11,7 @@ "files": [ { "path": "registry/curved-carousel-hero.tsx", - "content": "\"use client\";\n\nimport { motion, useAnimationFrame, useReducedMotion } from \"framer-motion\";\nimport {\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent,\n type PointerEvent,\n} from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface CurvedCarouselCard {\n /** Looping clip, muted and cover-fitted. */\n video?: string;\n /** Still image, also the clip's poster. */\n image?: string;\n}\n\nconst PITCH = 196;\nconst STYLES = `\n.cch, .cch *, .cch *::before, .cch *::after { box-sizing: border-box; }\n.cch { position: relative; width: 100%; height: 100%; min-height: 0; overflow: hidden; container-type: size; color: hsl(var(--foreground)); background: var(--cch-bg, hsl(var(--background))); font-family: var(--font-body), ui-sans-serif, system-ui, sans-serif; }\n.cch-frame { --u: min(calc(100cqw / 1440), calc(100cqh / 1080)); --cch-units: 1440; position: absolute; top: 50%; left: 50%; width: calc(1440 * var(--u)); height: calc(1080 * var(--u)); transform: translate(-50%, -50%); }\n.cch-badge { position: absolute; top: calc(115 * var(--u)); left: 50%; translate: -50% 0; display: inline-flex; align-items: center; height: calc(37 * var(--u)); padding: 0 calc(18 * var(--u)); border-radius: 999px; background: hsl(var(--primary) / 0.14); color: hsl(var(--primary)); font-size: calc(16.6 * var(--u)); font-weight: 500; white-space: nowrap; }\n.cch-title { position: absolute; top: calc(176 * var(--u)); left: 0; right: 0; margin: 0; padding: 0; border: 0; color: inherit; text-align: center; font-family: var(--font-heading), ui-sans-serif, system-ui, sans-serif; font-size: calc(88 * var(--u)); font-weight: 700; line-height: calc(92 * var(--u)); letter-spacing: -0.035em; }\n.cch-title > span { display: block; }\n.cch-title > span + span { letter-spacing: -0.022em; }\n.cch-lede { position: absolute; top: calc(394 * var(--u)); left: 50%; width: calc(560 * var(--u)); translate: -50% 0; margin: 0; text-align: center; color: hsl(var(--muted-foreground)); font-size: calc(20.8 * var(--u)); line-height: calc(32 * var(--u)); }\n.cch-track-band { position: absolute; top: calc(495 * var(--u)); left: 50%; width: 100cqw; height: calc(390 * var(--u)); translate: -50% 0; overflow: hidden; --cch-cy: 192; }\n.cch-cta { position: absolute; top: calc(901 * var(--u)); left: calc(626 * var(--u)); width: calc(190 * var(--u)); height: calc(74 * var(--u)); display: grid; place-items: center; border: 1.5px dashed hsl(var(--primary) / 0.6); border-radius: 999px; }\n.cch-cta a { display: grid; place-items: center; width: calc(172 * var(--u)); height: calc(58 * var(--u)); border-radius: 999px; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-size: calc(17 * var(--u)); font-weight: 500; text-decoration: none; }\n.cch-ink { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; color: hsl(var(--primary)); }\n.cch-note { position: absolute; margin: 0; color: hsl(var(--primary)); font-family: Caveat, \"Bradley Hand\", \"Segoe Print\", cursive; font-size: calc(30 * var(--u)); font-weight: 600; line-height: 1; white-space: pre; transform-origin: left top; pointer-events: none; }\n.cch-track { position: relative; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; user-select: none; }\n.cch-track[data-dragging] { cursor: grabbing; }\n.cch-card { position: absolute; top: 0; left: 0; overflow: hidden; will-change: transform, clip-path; }\n.cch-card > img, .cch-card > video, .cch-card > i { position: absolute; inset: 0; display: block; width: 100%; max-width: none; height: 100%; margin: 0; object-fit: cover; pointer-events: none; }\n.cch-card > video { opacity: 0; transition: opacity 0.4s; }\n.cch-card > video[data-ready] { opacity: 1; }\n@container (max-width: 820px) {\n .cch-frame { position: static; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; width: 100%; height: 100%; padding: 20px 0; transform: none; --cch-units: 640; }\n .cch-badge, .cch-title, .cch-lede, .cch-track-band, .cch-cta { position: static; translate: none; }\n .cch-badge { height: 30px; padding: 0 14px; font-size: 13px; }\n .cch-title { padding: 0 16px; font-size: clamp(24px, 8cqw, 56px); line-height: 1.04; }\n .cch-lede { width: auto; max-width: 40ch; padding: 0 16px; font-size: 13px; line-height: 1.5; }\n .cch-track-band { flex: 1 1 0; width: 100%; height: auto; min-height: 110px; max-height: 250px; }\n .cch-cta { width: 168px; height: 62px; }\n .cch-cta a { width: 152px; height: 48px; font-size: 15px; }\n .cch-ink, .cch-note { display: none; }\n}\n@container (max-width: 820px) and (max-height: 600px) { .cch-lede { display: none; } }\n`;\n\ntype Pt = [number, number];\n\n/** A closed path through four corners, each rounded with a quadratic curve of radius r. */\nfunction roundedQuad(points: Pt[], r: number) {\n const toward = (from: Pt, to: Pt): Pt => {\n const dx = to[0] - from[0];\n const dy = to[1] - from[1];\n const k = r / Math.hypot(dx, dy);\n return [from[0] + dx * k, from[1] + dy * k];\n };\n const f = (p: Pt) => `${p[0].toFixed(2)} ${p[1].toFixed(2)}`;\n return (\n points\n .map((p, i) => {\n const a = toward(p, points[(i + 3) % 4]);\n const b = toward(p, points[(i + 1) % 4]);\n return `${i ? \"L\" : \"M\"} ${f(a)} Q ${f(p)} ${f(b)}`;\n })\n .join(\" \") + \" Z\"\n );\n}\n\nfunction CarouselTrack({\n cards,\n speed,\n still,\n}: {\n cards: CurvedCarouselCard[];\n speed: number;\n still: boolean;\n}) {\n const trackRef = useRef(null);\n const cardRefs = useRef<(HTMLDivElement | null)[]>([]);\n const state = useRef({\n offset: 0,\n velocity: 0,\n dragging: false,\n lastX: 0,\n lastT: 0,\n units: 1440,\n cy: 192,\n scale: 1,\n });\n\n // At least enough cards to cover the row plus one off each edge.\n const [minCount, setMinCount] = useState(10);\n\n // Wide: the row spans the whole section at the frame's scale. Compact: a 640-unit row fitted to\n // the band. The stylesheet says which through --cch-units.\n useEffect(() => {\n const track = trackRef.current;\n if (!track) return;\n const measure = () => {\n const css = getComputedStyle(track);\n const s = state.current;\n if (Number(css.getPropertyValue(\"--cch-units\")) === 640) {\n // Compact: fit a 640-unit row into whatever height the band has left.\n s.scale = Math.min(track.clientWidth / 640, track.clientHeight / 380);\n s.units = track.clientWidth / s.scale;\n s.cy = track.clientHeight / 2 / s.scale;\n } else {\n const frame = track.closest(\".cch-frame\") as HTMLElement;\n s.scale = frame.clientWidth / 1440;\n s.units = track.clientWidth / s.scale;\n s.cy = Number(css.getPropertyValue(\"--cch-cy\")) || 192;\n }\n setMinCount(Math.ceil((s.units + 600) / PITCH));\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(track);\n return () => observer.disconnect();\n }, []);\n\n // Repeating the whole set keeps a card's copies a full cycle apart instead of side by side.\n const filled = Array.from(\n { length: cards.length ? cards.length * Math.ceil(minCount / cards.length) : minCount },\n (_, i): CurvedCarouselCard => cards[i % cards.length] ?? {},\n );\n const loop = filled.length * PITCH;\n\n useAnimationFrame((_, delta) => {\n const s = state.current;\n const dt = Math.min(delta, 64) / 1000;\n if (!s.dragging) {\n s.offset += s.velocity * dt;\n s.velocity *= Math.pow(0.05, dt);\n if (!still) s.offset -= speed * dt;\n }\n\n const centre = s.units / 2;\n const radius = Math.max(706, centre - 14);\n cardRefs.current.forEach((el, i) => {\n if (!el) return;\n const t = ((((i * PITCH + s.offset) % loop) + loop * 1.5) % loop) - loop / 2;\n const x = centre + t * (1 + 0.083 * (t / radius) ** 2);\n const d = Math.abs(x - centre) / radius;\n el.style.visibility = d > 1.25 ? \"hidden\" : \"\";\n if (d > 1.25) return;\n const w = 170 + 48 * d * d;\n const edge = (ex: number) => 280 + 92 * (Math.abs(ex - centre) / radius) ** 2.6;\n const hl = edge(x - w / 2);\n const hr = edge(x + w / 2);\n const h = Math.max(hl, hr);\n const cy = s.cy - 12 * d * d;\n const k = s.scale;\n\n el.style.width = `${w * k}px`;\n el.style.height = `${h * k}px`;\n el.style.transform = `translate(${(x - w / 2) * k}px, ${(cy - h / 2) * k}px)`;\n el.style.clipPath = `path(\"${roundedQuad(\n [\n [0, ((h - hl) / 2) * k],\n [w * k, ((h - hr) / 2) * k],\n [w * k, ((h + hr) / 2) * k],\n [0, ((h + hl) / 2) * k],\n ],\n 15 * k,\n )}\")`;\n });\n });\n\n const onPointerDown = (event: PointerEvent) => {\n const s = state.current;\n s.dragging = true;\n s.velocity = 0;\n s.lastX = event.clientX;\n s.lastT = event.timeStamp;\n event.currentTarget.setPointerCapture(event.pointerId);\n event.currentTarget.dataset.dragging = \"\";\n };\n const onPointerMove = (event: PointerEvent) => {\n const s = state.current;\n if (!s.dragging) return;\n const dx = (event.clientX - s.lastX) / s.scale;\n const dt = Math.max(event.timeStamp - s.lastT, 1) / 1000;\n s.offset += dx;\n s.velocity = dx / dt;\n s.lastX = event.clientX;\n s.lastT = event.timeStamp;\n };\n const onKeyDown = (event: KeyboardEvent) => {\n const push = { ArrowLeft: 600, ArrowRight: -600 }[event.key];\n if (push === undefined) return;\n event.preventDefault();\n state.current.velocity += push;\n };\n const onPointerUp = (event: PointerEvent) => {\n state.current.dragging = false;\n delete event.currentTarget.dataset.dragging;\n };\n\n return (\n \n {filled.map((card, i) => (\n {\n cardRefs.current[i] = el;\n }}\n className=\"cch-card\"\n >\n \n {card.image && \"\"}\n {card.video && !still && (\n {\n if (!video) return;\n video.muted = true;\n video.play().catch(() => {});\n }}\n src={card.video}\n poster={card.image}\n autoPlay\n muted\n loop\n playsInline\n onLoadedData={(event) => {\n event.currentTarget.dataset.ready = \"\";\n }}\n />\n )}\n \n ))}\n \n );\n}\n\nexport interface CurvedCarouselHeroProps {\n badge?: string;\n /** Headline; a newline starts the second line. */\n title?: string;\n description?: string;\n ctaLabel?: string;\n ctaHref?: string;\n /** Handwritten note by the carousel; a newline breaks it. */\n note?: string;\n /** Handwritten note by the button. */\n ctaNote?: string;\n /** Card media, repeated to fill the arch. Cards without media show a theme-tinted tile. */\n cards?: CurvedCarouselCard[];\n /** Auto-scroll speed in frame units per second. */\n speed?: number;\n backgroundColor?: string;\n className?: string;\n style?: CSSProperties;\n}\n\nexport function CurvedCarouselHero({\n badge = \"New · Curved carousel\",\n title = \"Every story,\\nin motion\",\n description = \"Line your work up on a curved row that drifts on its own and answers to a drag. Drop in clips or images and it does the rest.\",\n ctaLabel = \"Get started\",\n ctaHref = \"#\",\n note = \"Drag\\nthe row\",\n ctaNote = \"It's free\",\n cards = [],\n speed = 50,\n backgroundColor,\n className,\n style,\n}: CurvedCarouselHeroProps) {\n const prefersReducedMotion = useReducedMotion();\n const still = !!prefersReducedMotion;\n\n const enter = (delay: number, from: Record = { opacity: 0, y: 16 }) =>\n still\n ? {}\n : {\n initial: from,\n animate: { opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" },\n transition: { delay, duration: 0.7, ease: [0.22, 1, 0.36, 1] as const },\n };\n const draw = (delay: number) =>\n still\n ? {}\n : {\n initial: { pathLength: 0 },\n animate: { pathLength: 1 },\n transition: { delay, duration: 0.9, ease: \"easeInOut\" as const },\n };\n\n return (\n \n