import type { CSSProperties, ReactNode } from 'react'; import { prefersReducedMotion } from './utils.js'; export interface MeshBackgroundProps { /** Optional content rendered on top of the mesh. */ children?: ReactNode; /** * Mood tier — controls the overall saturation + animation cadence. * - `calm` — slow drift, low saturation. Default. * - `focus` — slightly faster + a touch more saturation. * - `celebrate` — vibrant, faster oscillation. Use sparingly. */ mood?: 'calm' | 'focus' | 'celebrate'; /** Override the gradient stop colour palette (CSS colours). */ colors?: [string, string, string, string]; /** Bypass animation (static mesh) — respects prefers-reduced-motion. */ disableMotion?: boolean; className?: string; style?: CSSProperties; } /** * `` — ambient OKLCH-flavoured gradient wash with two * blurred conic "blobs" drifting slowly. Pure CSS, zero JS once mounted. * * Designed as a background layer behind landing-page heroes. Subtle by * default (calm mood); never use for content surfaces (kills contrast). * * Honours `prefers-reduced-motion`: the blobs render static when the * user opts out. */ export function MeshBackground({ children, mood = 'calm', colors, disableMotion, className, style, }: MeshBackgroundProps) { const reduced = disableMotion ?? prefersReducedMotion(); const palette = colors ?? ([ // Default palette uses tokens with sensible sRGB fallbacks. 'color-mix(in srgb, var(--bl-accent, #6366f1) 60%, transparent)', 'color-mix(in srgb, var(--bl-success, #34d399) 50%, transparent)', 'color-mix(in srgb, var(--bl-warning, #fbbf24) 50%, transparent)', 'color-mix(in srgb, var(--bl-danger, #f472b6) 50%, transparent)', ] as const); const speed: Record, string> = { calm: '24s', focus: '16s', celebrate: '10s', }; return (
{/* Two blurred blobs drifting on independent paths. */} ); }