"use client"; import { useEffect, useState } from "react"; import { COLOR_TOKENS, ColorToken, Palette, R_INNER, clamp } from "../lib/tokens"; import { AnimatePresence, motion } from "motion/react"; import { COLOR_TOKEN_TEXT, t, useLang } from "../lib/i18n"; import { Icon } from "./M3Node"; export function IconBtn({ icon, on, onClick, title, size = 36, p, danger, disabled, fill, }: { icon: string; on?: boolean; onClick?: () => void; title?: string; size?: number; p: Palette; danger?: boolean; disabled?: boolean; fill?: boolean; }) { return ( ); } export type SegOption = { key: K; icon?: string; label?: string; title?: string; /** small marker: this option carries something */ dot?: boolean; /** this option alone takes the spare width */ grow?: boolean; /** an icon-only option that should not shrink to a square */ wide?: boolean }; /** Connected-button group with the same fused corners as the canvas. */ export function Segmented({ options, value, onChange, p, height = 40, grow = true, }: { options: SegOption[]; value: K; onChange: (k: K) => void; p: Palette; height?: number; grow?: boolean; }) { return (
{options.map((o, i) => { const on = o.key === value; const first = i === 0; const last = i === options.length - 1; const outer = height / 2; return ( ); })}
); } export function Field({ value, onChange, placeholder, p, icon, multiline, rows = 3, height = 44, }: { value: string; onChange: (v: string) => void; placeholder?: string; p: Palette; icon?: string; multiline?: boolean; rows?: number; height?: number; }) { const lang = useLang(); const filled = value.length > 0; const base: React.CSSProperties = { width: "100%", padding: multiline ? `12px ${filled ? 40 : 14}px 12px ${icon ? 42 : 14}px` : `0 ${filled ? 40 : 14}px 0 ${icon ? 42 : 14}px`, borderRadius: multiline ? 18 : height / 2, border: "none", background: p.surfaceContainerHigh, color: p.onSurface, fontSize: 14, lineHeight: multiline ? 1.55 : undefined, outline: "none", boxSizing: "border-box", fontFamily: "inherit", resize: "none", }; return (
{icon && ( )} {multiline ? (