Phones (<=639px) only for layout/gestures; the theme-level fixes apply
everywhere, as they are token/design changes.
Settings sheet
- Swipe-to-dismiss reusing the InstallSheet gesture: the sheet follows the
finger, closes past ~90px or on a fast flick, snaps back otherwise. Drag
starts only from the handle/header and only while the body is scrolled to
the top. Backdrop tap still closes.
- Fixed header + scrollable body: pb-safe + spacer, so nothing is clipped;
a scroll cue (chevron) fades in while more content is below and out at
the end.
- Show/Save stack under the field at 44px on phones; close, Test connection
and Remove key are 44px too. Remove key is now a rose destructive action
with a confirmation that the full-screen key setup comes back.
- API key note split into a short privacy line plus a collapsible
'Using the local daemon?' tip (OLLAMA_AUTH=local / .env.local / signin).
- Fixed the missing space in the English tip ('ollama signin instead.').
- Health: kept the auto-check and banner; added a loading row and a
'Checked just now' / 'Checked at HH:MM' freshness label (also for errors).
Ice scene / readability
- Verified the orbs were never above content (fixed z-index:-1 layer,
pointer-events:none); they were just shining through the glass. Phones get
lower blob/orb opacity and orbs tucked to the edges; the bottom-right orb
is moved out from under the tab bar and the tab bar paints a more opaque
surface so its labels hold contrast.
Contrast / themes
- Dark --text-subtle raised to #9db1d0 (8.6:1 page, 7.2:1 glass); helper
text now uses the tokens.
- Disabled buttons are a visible muted chip (.btn-disabled) instead of a
40%-opacity ghost.
- One ice primary gradient in both themes; danger/success now actually show
their colour (bg-none strips the primary background-image that used to
paint over !bg-rose-600).
- Light mode: cool card rims instead of white-on-white, stronger shadow.
Redundancy / touch
- Removed only the header gear; the hamburger drawer (folders, Settings,
theme) and the tab-bar Settings stay.
- Theme toggle is a bordered chip with an action aria-label (drawer row too).
- Empty library hides the folder pills, demotes Import to a quiet link and
keeps a single primary CTA. 44px targets for nav rows, segmented control
and folder pills on phones.
- Fixed a pre-existing 16px horizontal overflow (header -mx-4 vs a
padding-less parent) and let info values wrap instead of truncating.
Verified: mobile suite 47/47 (EN+CS, 360/390px), pixel-sampled contrast
audit 0 runs below WCAG AA (8 runs, both themes/locales; axe marks the glass
'incomplete'), i18n 27/27, desktop regression 72/72, lint + build clean.
Service worker cache bumped to freezmo-v5.
162 lines
5 KiB
TypeScript
162 lines
5 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",
|
|
// bg-none strips the primary gradient, which otherwise paints over the
|
|
// rose/emerald background-color and wins visually.
|
|
danger:
|
|
"btn-primary bg-none !bg-rose-600 hover:!bg-rose-700 dark:!bg-rose-500 dark:!text-white dark:hover:!bg-rose-600",
|
|
success:
|
|
"btn-primary bg-none !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",
|
|
VARIANTS[variant],
|
|
SIZES[size],
|
|
// A visible, muted chip rather than a ghosted primary. Only for an
|
|
// explicit `disabled`; a `loading` button stays vivid with its spinner.
|
|
disabled && "btn-disabled",
|
|
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>
|
|
);
|
|
}
|