Rebuilds the look around the spec: an ice scene, one shared glass recipe, icy accents and glass on every large surface. Visual only — layout, behaviour, copy and functionality are untouched. Background - .ice-scene: fixed, z-index -1, pointer-events none. Navy base (#070b16 to #0c1426) in dark, pale (#f4f9ff to #e6f1fb) in light, four drifting glacier blobs (#38bdf8/#60a5fa/#818cf8, 30-60s transform-only loops), five glossy ice orbs (40-220px radial gradients with a highlight at 30% 25% and a blue shadow) placed so the glass blurs them, and an SVG feTurbulence grain at 4-5%. - prefers-reduced-motion stops the drift; phones get two blobs and two orbs fewer. Glass - One shared recipe (.glass-panel, .card, .sidebar-surface, .study-chrome, .tabbar, .glass, .gate-card): rgba(255,255,255,.06) dark / .55 light, blur(24px) saturate(140%) (16px on phones), a bright 1px rim, an inset top highlight and a blue-tinted outer shadow. - Nested glass (chips, inputs, secondary buttons) is more opaque and never adds a second blur layer. @supports fallback for no backdrop-filter. Radii: 24-28px cards/sheets, 14px inputs/buttons, pills for chips. Cards hover brighter + cyan rim + 2px lift, 180ms. Colour and type - Accent is glacier cyan (#38bdf8) to ice blue (#0ea5e9); progress bars and selected states use the gradient; the active sidebar item is a frosted highlight with a cyan rim. - Primary CTA: icy gradient — white to #bfe3ff with ink text in dark, deep blue in light (biased so the label sits on the darker half and keeps 5.6:1). - Leftover slate/black greys replaced with navy-tinted frost tokens. - Headings are semibold with tighter tracking. Screens - Dashboard: the sidebar is one tall inset rounded glass panel; deck cards are glass. - Gate: one centred glass card over the scene, orbs visible behind it. - Sheets/modals: glass over the dimmed, lightly blurred backdrop. - Study view: question card more opaque (.glass-solid); top bar and pager are slim glass pills. Perf: measured on a phone viewport with 4x CPU throttling. The animated blobs' filter: blur() was the whole cost (150ms vs 33ms per frame), so they are soft radial gradients with no filter now; idle 60fps, ~17ms median while scrolling. Tests updated for the new tokens: contrast 18/18 AA, deck chrome 15/15, key gate 49/49, install sheet 64/64, deck fixes 15/15, retry 14/14, zoom 6/6, final ux 12/12, security 8/8, pwa 16/16.
155 lines
4.6 KiB
TypeScript
155 lines
4.6 KiB
TypeScript
"use client";
|
|
|
|
import { forwardRef } from "react";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
type ButtonVariant = "primary" | "secondary" | "ghost" | "danger" | "success";
|
|
type ButtonSize = "sm" | "md" | "lg";
|
|
|
|
/**
|
|
* ChatGPT-flavoured buttons: pill-shaped, near-black primary in light mode and
|
|
* white in dark mode, quiet secondaries with hairline borders.
|
|
*/
|
|
const VARIANTS: Record<ButtonVariant, string> = {
|
|
primary: "btn-primary",
|
|
secondary: "btn-secondary",
|
|
ghost: "btn-ghost",
|
|
danger: "btn-primary !bg-rose-600 hover:!bg-rose-700 dark:!bg-rose-500 dark:!text-white dark:hover:!bg-rose-600",
|
|
success: "btn-primary !bg-emerald-600 hover:!bg-emerald-700 dark:!bg-emerald-500 dark:!text-white dark:hover:!bg-emerald-600",
|
|
};
|
|
|
|
const SIZES: Record<ButtonSize, string> = {
|
|
sm: "h-9 px-3.5 text-[13px] rounded-[14px]",
|
|
md: "h-10 px-4 text-sm rounded-[14px]",
|
|
lg: "h-11 px-5 text-[15px] rounded-[14px]",
|
|
};
|
|
|
|
export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
variant?: ButtonVariant;
|
|
size?: ButtonSize;
|
|
loading?: boolean;
|
|
};
|
|
|
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
|
|
{ className, variant = "primary", size = "md", loading, children, disabled, ...props },
|
|
ref,
|
|
) {
|
|
return (
|
|
<button
|
|
ref={ref}
|
|
disabled={disabled || loading}
|
|
className={cn(
|
|
"inline-flex select-none items-center justify-center whitespace-nowrap font-medium transition disabled:cursor-not-allowed disabled:opacity-40",
|
|
VARIANTS[variant],
|
|
SIZES[size],
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
{loading ? <Spinner className="size-4" /> : null}
|
|
{children}
|
|
</button>
|
|
);
|
|
});
|
|
|
|
export function Spinner({ className }: { className?: string }) {
|
|
return (
|
|
<svg className={cn("animate-spin", className)} viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
<circle cx="12" cy="12" r="9" stroke="currentColor" strokeOpacity="0.25" strokeWidth="3" />
|
|
<path d="M21 12a9 9 0 0 0-9-9" stroke="currentColor" strokeWidth="3" strokeLinecap="round" />
|
|
</svg>
|
|
);
|
|
}
|
|
|
|
/** Small neutral pill. Colour is reserved for meaning, not decoration. */
|
|
export function Chip({
|
|
children,
|
|
className,
|
|
tone = "neutral",
|
|
}: {
|
|
children: React.ReactNode;
|
|
className?: string;
|
|
tone?: "neutral" | "accent" | "success" | "warning" | "danger";
|
|
}) {
|
|
const tones: Record<string, string> = {
|
|
neutral: "bg-[var(--surface-sunken)] text-[var(--text-muted)]",
|
|
accent: "bg-accent-500/12 text-accent-700 dark:text-accent-200",
|
|
success: "bg-emerald-500/12 text-emerald-700 dark:text-emerald-300",
|
|
warning: "bg-amber-500/14 text-amber-800 dark:text-amber-300",
|
|
danger: "bg-rose-500/12 text-rose-700 dark:text-rose-300",
|
|
};
|
|
return (
|
|
<span
|
|
className={cn(
|
|
"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[12px] font-medium leading-none",
|
|
tones[tone],
|
|
className,
|
|
)}
|
|
>
|
|
{children}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
export function ProgressBar({
|
|
value,
|
|
max,
|
|
className,
|
|
label,
|
|
}: {
|
|
value: number;
|
|
max: number;
|
|
className?: string;
|
|
label?: string;
|
|
}) {
|
|
const percent = max <= 0 ? 0 : Math.min(100, Math.max(0, (value / max) * 100));
|
|
return (
|
|
<div
|
|
className={cn("h-1 w-full overflow-hidden rounded-full bg-[var(--surface-sunken)]", className)}
|
|
role="progressbar"
|
|
aria-valuenow={Math.round(percent)}
|
|
aria-valuemin={0}
|
|
aria-valuemax={100}
|
|
aria-label={label ?? "Progress"}
|
|
>
|
|
<div
|
|
className="grad-ice h-full rounded-full transition-[width] duration-500 ease-out"
|
|
style={{ width: `${percent}%` }}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function EmptyState({
|
|
title,
|
|
children,
|
|
icon,
|
|
action,
|
|
}: {
|
|
title: string;
|
|
children?: React.ReactNode;
|
|
icon?: React.ReactNode;
|
|
action?: React.ReactNode;
|
|
}) {
|
|
return (
|
|
<div className="animate-rise flex flex-col items-center px-6 py-6 text-center sm:py-24">
|
|
{icon ? (
|
|
<span
|
|
className="mb-4 grid size-12 place-items-center rounded-2xl border border-[var(--hairline)] bg-[var(--surface-strong)] text-[var(--text-subtle)]"
|
|
aria-hidden
|
|
>
|
|
{icon}
|
|
</span>
|
|
) : (
|
|
/* eslint-disable-next-line @next/next/no-img-element -- static app icon, no optimisation needed */
|
|
<img src="/icons/icon-192.png" alt="" aria-hidden className="mb-4 size-12 rounded-2xl" />
|
|
)}
|
|
<h2 className="text-[17px] font-semibold tracking-[-0.01em] text-[var(--text)]">{title}</h2>
|
|
{children ? (
|
|
<p className="mt-2 max-w-md text-sm leading-relaxed text-[var(--text-muted)]">{children}</p>
|
|
) : null}
|
|
{action ? <div className="mt-6">{action}</div> : null}
|
|
</div>
|
|
);
|
|
}
|