velxio/frontend/src/components/ui/Input.tsx

47 lines
1.3 KiB
TypeScript
Raw Normal View History

feat(design): tokens, webfonts, Lucide icons, board PNG/WebP picture strip Foundation - Add 7 token CSS files in src/tokens/ — semantic colors, 4-pt spacing, Apple-HIG type ramp, radius/elevation/motion/z-index scales. - Refactor src/index.css to import tokens and remap legacy aliases (--accent, --bg, etc.) onto the new --color-* semantics so existing components keep rendering during migration. - Drop the duplicate font-family from src/App.css; body inherits from :root. - Global *:focus-visible ring backed by --color-focus-ring (WCAG 2.4.7). Webfonts (self-hosted) - Add Inter.var.woff2 (variable, OFL) and JetBrainsMono.var.woff2 to public/fonts/. Preloaded in index.html with crossorigin. - Old stack -apple-system kept as fallback so Mac users still get SF Pro. - Fixes cross-OS rendering inconsistency (Win/Linux/Android were falling back to Segoe UI / Roboto, breaking the type grid). Component primitives - New src/components/ui/{Button,Card,Input}.tsx + .css. Built on the semantic tokens, ready for incremental migration of .ap-* CSS classes. Lucide icons - Replace 6 inline SVG icon components in LandingPage (IcoChip / IcoCpu / IcoCode / IcoZap / IcoLayers / IcoMonitor) with lucide-react imports. Aliased so call sites are unchanged. ~80 lines of inline SVG removed. - IcoGitHub kept bespoke (filled glyph, brand-correct). Marketing assets - Convert top 8 boards to transparent PNG + WebP at 1x / 2x: Arduino Uno, Nano, Mega 2560, Pi Pico, Pi Pico W, ESP32-C3, ESP32-DevKit-V1, XIAO ESP32-S3. - Migrate matching cards in LandingPage and Velxio2Page to <picture> with WebP > PNG > SVG fallback. Other 8 boards keep <img src=*.svg> for now (Raspberry Pi 3B, ESP32-CAM, etc.). - Refresh og-image.png — same canonical URL, new content (4 hero boards + branding instead of generic logo card). - Fix latent bug in LandingPage: ESP32 DevKit V1 card was loading esp32-devkit-c-v4.svg; now uses esp32-devkit-v1.{webp,png,svg}. Build verified: npm run build:docker succeeds, 246 SEO pages prerender. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 01:45:44 +07:00
import { forwardRef, useId, type InputHTMLAttributes } from 'react';
import './Input.css';
interface Props extends InputHTMLAttributes<HTMLInputElement> {
label?: string;
helper?: string;
error?: string;
}
export const Input = forwardRef<HTMLInputElement, Props>(function Input(
{ label, helper, error, id: providedId, className, ...rest },
ref,
) {
const generatedId = useId();
const id = providedId ?? generatedId;
const helperId = helper ? `${id}-helper` : undefined;
const errorId = error ? `${id}-error` : undefined;
return (
<div className={['ui-field', className ?? ''].filter(Boolean).join(' ')}>
{label ? (
<label htmlFor={id} className="ui-field__label">
{label}
</label>
) : null}
<input
ref={ref}
id={id}
className={['ui-input', error ? 'ui-input--error' : ''].filter(Boolean).join(' ')}
aria-invalid={error ? 'true' : undefined}
aria-describedby={errorId ?? helperId}
{...rest}
/>
{helper && !error ? (
<p id={helperId} className="ui-field__helper">
{helper}
</p>
) : null}
{error ? (
<p id={errorId} className="ui-field__error" role="alert">
{error}
</p>
) : null}
</div>
);
});