Polish: link buttons, theme-aware dark variant, assistant drawer overlay, sticky draft bar

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-11 18:32:46 -07:00
parent aed14cd04f
commit c549c34f60
13 changed files with 60 additions and 66 deletions

View file

@ -125,7 +125,7 @@ export async function runTest(label: string, check: () => Promise<{ modelCount?:
const { modelCount, note } = await check();
const latencyMs = Date.now() - started;
const message =
note ?? (modelCount !== undefined ? `Connected to ${label} — ${modelCount} model${modelCount === 1 ? '' : 's'} available.` : `Connected to ${label}.`);
note ?? (modelCount !== undefined ? `Connected to ${label}: ${modelCount} model${modelCount === 1 ? '' : 's'} available.` : `Connected to ${label}.`);
return modelCount !== undefined ? { ok: true, message, latencyMs, modelCount } : { ok: true, message, latencyMs };
} catch (err) {
const latencyMs = Date.now() - started;

View file

@ -586,7 +586,7 @@ export function Shell() {
</main>
</div>
{showDrawer && (
<aside aria-label="Assistant" className="sticky top-0 z-20 hidden h-dvh w-[420px] shrink-0 animate-drawer flex-col border-l border-line bg-surface lg:flex xl:w-[460px]">
<aside aria-label="Assistant" className="fixed top-0 right-0 z-40 hidden h-dvh w-[420px] shrink-0 animate-drawer flex-col border-l border-line bg-surface shadow-3 lg:flex min-[1360px]:sticky min-[1360px]:z-20 min-[1360px]:w-[440px] min-[1360px]:shadow-none">
<Suspense fallback={<div className="grid flex-1 place-items-center"><Spinner /></div>}>
<AssistantPanel
variant="drawer"

View file

@ -49,11 +49,9 @@ function DraftCard({ item, onNavigate }: { item: Extract<UiItem, { type: 'draft'
</div>
</div>
{!gone && (
<Link to={`/drafts/${item.draftId}`} onClick={onNavigate}>
<Button size="sm" variant={saved ? 'secondary' : 'primary'}>
<Button to={`/drafts/${item.draftId}`} onClick={onNavigate} size="sm" variant={saved ? 'secondary' : 'primary'}>
{saved ? 'Open' : 'Review'}
</Button>
</Link>
)}
</div>
);
@ -399,11 +397,9 @@ export default function AssistantPanel({
<Callout tone="accent" icon={<Sparkles />} title="Connect an AI model to use the assistant">
Add a provider such as OpenAI, Anthropic, Google Gemini or a local model, then switch on a model.
<div className="mt-3">
<Link to="/settings/ai" onClick={() => variant === 'drawer' && assistant.close()}>
<Button size="sm" variant="primary">
<Button to="/settings/ai" onClick={() => variant === 'drawer' && assistant.close()} size="sm" variant="primary">
Open AI settings
</Button>
</Link>
</div>
</Callout>
</div>
@ -428,7 +424,7 @@ export default function AssistantPanel({
<div className="max-w-[88%] rounded-[16px] rounded-br-md bg-ink px-3.5 py-2.5 text-[15px] whitespace-pre-wrap text-paper">{m.text}</div>
</div>
) : (
<AssistantMessage key={m.id} message={m} onNavigate={() => variant === 'drawer' && undefined} onAction={updateAction} />
<AssistantMessage key={m.id} message={m} onNavigate={() => variant === 'drawer' && window.innerWidth < 1360 && assistant.close()} onAction={updateAction} />
),
)}
</div>

View file

@ -151,11 +151,9 @@ export function GenerateDialog({ open, onClose, classId, folderId, preset }: { o
<Callout tone="accent" icon={<Sparkles />} title="Connect an AI model first">
Add a provider (OpenAI, Anthropic, Gemini, or a local model) and switch on at least one model.
<div className="mt-3">
<Link to="/settings/ai" onClick={onClose}>
<Button variant="primary" size="sm">
<Button to="/settings/ai" onClick={onClose} variant="primary" size="sm">
Open AI settings
</Button>
</Link>
</div>
</Callout>
) : (

View file

@ -230,19 +230,15 @@ export default function ClassPage() {
const z = item as QuizItem;
if (z.activeAttemptId)
return (
<Link to={`/session/${z.activeAttemptId}`}>
<Button size="sm" variant="marker" icon={<Play className="fill-current" />}>
<Button to={`/session/${z.activeAttemptId}`} size="sm" variant="marker" icon={<Play className="fill-current" />}>
Resume
</Button>
</Link>
);
if (z.questionCount > 0)
return (
<Link to={`/quizzes/${z.id}?start=1`}>
<Button size="sm" icon={<Play className="fill-current" />}>
<Button to={`/quizzes/${z.id}?start=1`} size="sm" icon={<Play className="fill-current" />}>
Start
</Button>
</Link>
);
return null;
}
@ -250,17 +246,13 @@ export default function ClassPage() {
const d = item as DeckItem;
if (d.dueCount + Math.min(d.newCount, 20) > 0 && d.cardCount > 0)
return (
<Link to={`/review?deckId=${d.id}`}>
<Button size="sm" variant={d.dueCount > 0 ? 'marker' : 'secondary'} icon={<Play className="fill-current" />}>
<Button to={`/review?deckId=${d.id}`} size="sm" variant={d.dueCount > 0 ? 'marker' : 'secondary'} icon={<Play className="fill-current" />}>
{d.dueCount > 0 ? `Review ${d.dueCount}` : 'Learn'}
</Button>
</Link>
);
if (d.cardCount > 0)
return (
<Link to={`/decks/${d.id}/cram`}>
<Button size="sm">Browse</Button>
</Link>
<Button to={`/decks/${d.id}/cram`} size="sm">Browse</Button>
);
}
return null;
@ -479,11 +471,9 @@ export default function ClassPage() {
</div>
<div className="flex flex-wrap items-center gap-2">
{data.due.total > 0 && (
<Link to={`/review?classId=${cls.id}`}>
<Button variant="marker" icon={<Play className="fill-current" />}>
<Button to={`/review?classId=${cls.id}`} variant="marker" icon={<Play className="fill-current" />}>
Review {data.due.total}
</Button>
</Link>
)}
<Button icon={<Sparkles />} onClick={() => setGenerate({})}>
Generate

View file

@ -154,16 +154,12 @@ export default function DeckPage() {
</div>
</div>
<div className="flex flex-wrap items-center gap-2">
<Link to={`/review?deckId=${deck.id}`} aria-disabled={!canStudy} className={cx(!canStudy && 'pointer-events-none')}>
<Button variant={canStudy ? 'primary' : 'secondary'} size="lg" icon={<Play className="fill-current" />} disabled={!canStudy}>
<Button to={`/review?deckId=${deck.id}`} variant={canStudy ? 'primary' : 'secondary'} size="lg" icon={<Play className="fill-current" />} disabled={!canStudy}>
{canStudy ? `Review ${due.total}` : 'Nothing due'}
</Button>
</Link>
<Link to={`/decks/${deck.id}/cram`} className={cx(cards.length === 0 && 'pointer-events-none')}>
<Button size="lg" icon={<Layers />} disabled={cards.length === 0}>
<Button to={`/decks/${deck.id}/cram`} size="lg" icon={<Layers />} disabled={cards.length === 0}>
{data.session ? 'Continue browsing' : 'Browse all'}
</Button>
</Link>
<Menu
trigger={
<IconButton label="Deck options" tooltip={false}>

View file

@ -215,9 +215,7 @@ export default function DocumentPage() {
Read with AI
</Button>
) : (
<Link to="/settings/ai">
<Button size="sm">Set up AI</Button>
</Link>
<Button to="/settings/ai" size="sm">Set up AI</Button>
)
}
>

View file

@ -236,7 +236,7 @@ export default function DraftPage() {
const canSave = errors.length === 0 && (mode === 'new' ? Boolean(classId) : Boolean(targetId));
return (
<div className="animate-in pb-28">
<div className="animate-in">
<header className="mb-6">
<div className="eyebrow mb-2 flex flex-wrap items-center gap-2">
<span className="flex items-center gap-1.5 [&>svg]:size-3.5">
@ -487,8 +487,8 @@ export default function DraftPage() {
)}
{/* save bar */}
<div className="safe-bottom fixed inset-x-0 bottom-14 z-30 border-t border-line bg-paper/95 backdrop-blur lg:bottom-0 lg:left-[252px]">
<div className="mx-auto flex h-16 max-w-[1080px] items-center gap-2 px-4 sm:px-8">
<div className="sticky bottom-14 z-20 -mx-4 mt-8 border-t border-line bg-paper/95 backdrop-blur sm:-mx-8 lg:bottom-0">
<div className="flex h-16 items-center gap-2 px-4 sm:px-8">
<div className="min-w-0 flex-1 text-[13px]" aria-live="polite">
{errors.length > 0 ? (
<span className="flex items-center gap-1.5 font-medium text-bad">

View file

@ -152,11 +152,9 @@ export default function Home() {
</div>
<div className="mt-5 flex flex-wrap gap-2">
{due > 0 ? (
<Link to="/review">
<Button variant="primary" size="lg" icon={<Play className="fill-current" />}>
<Button to="/review" variant="primary" size="lg" icon={<Play className="fill-current" />}>
Start review
</Button>
</Link>
) : null}
{o.missedCount > 0 && (
<Button size="lg" icon={<RotateCcw />} loading={starting} onClick={() => start({ source: { type: 'missed' }, count: Math.min(20, o.missedCount) })}>

View file

@ -409,11 +409,9 @@ export default function QuizPage() {
</div>
<div className="flex flex-wrap items-center gap-2">
{data.activeAttempt ? (
<Link to={`/session/${data.activeAttempt.id}`}>
<Button variant="marker" size="lg" icon={<Play className="fill-current" />}>
<Button to={`/session/${data.activeAttempt.id}`} variant="marker" size="lg" icon={<Play className="fill-current" />}>
Resume ({data.activeAttempt.answeredCount}/{data.activeAttempt.questionCount})
</Button>
</Link>
) : null}
<Button variant={data.activeAttempt ? 'secondary' : 'primary'} size="lg" icon={<Play className="fill-current" />} disabled={questions.length === 0} onClick={() => setStartOpen(true)}>
{data.activeAttempt ? 'Start new' : 'Start'}

View file

@ -319,11 +319,9 @@ function SharedDocument({ doc, token }: { doc: PublicDocument; token: string })
{doc.filename} · {formatBytes(doc.size)}
{doc.pageCount ? ` · ${plural(doc.pageCount, 'page')}` : ''}
</p>
<a href={url} download={inline ? undefined : doc.filename} target={inline ? '_blank' : undefined} rel="noreferrer" className="mt-5 inline-block">
<Button variant="primary" size="lg" icon={<Download />}>
{inline ? 'Open file' : 'Download'}
</Button>
</a>
<Button href={url} download={inline ? undefined : doc.filename} target={inline ? '_blank' : undefined} variant="primary" size="lg" icon={<Download />} className="mt-5">
{inline ? 'Open file' : 'Download'}
</Button>
{doc.docKind === 'image' && <img src={url} alt={doc.title} className="card mt-6 max-w-full p-2" />}
{doc.docKind === 'pdf' && <iframe src={url} title={doc.title} className="card mt-6 hidden h-[78vh] w-full sm:block" />}
</Frame>

View file

@ -1,4 +1,5 @@
@import 'tailwindcss';
@custom-variant dark (&:where([data-theme='dark'], [data-theme='dark'] *));
@source inline("tab-{cobalt,teal,moss,amber,coral,rose,plum,slate}");
@import '@fontsource-variable/instrument-sans';
@import '@fontsource-variable/newsreader';

View file

@ -1,6 +1,7 @@
import { CircleAlert, Inbox, LoaderCircle, X } from 'lucide-react';
import { AlertDialog, Dialog as RDialog, DropdownMenu, Popover as RPopover, Switch as RSwitch, Tooltip as RTooltip } from 'radix-ui';
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useRef, useState, type ButtonHTMLAttributes, type InputHTMLAttributes, type ReactNode, type SelectHTMLAttributes, type TextareaHTMLAttributes } from 'react';
import { Link } from 'react-router';
import { cx } from '@/lib/util';
/* ------------------------------ Button ------------------------------ */
@ -27,29 +28,49 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
loading?: boolean;
icon?: ReactNode;
block?: boolean;
/** Renders a link to a page inside the app that looks like a button. */
to?: string;
/** Renders an ordinary link (downloads, external pages) that looks like a button. */
href?: string;
target?: string;
download?: string | boolean;
}
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
{ variant = 'secondary', size = 'md', loading, icon, block, className, children, disabled, type = 'button', ...rest },
{ variant = 'secondary', size = 'md', loading, icon, block, className, children, disabled, type = 'button', to, href, target, download, ...rest },
ref,
) {
return (
<button
ref={ref}
type={type}
disabled={disabled || loading}
aria-busy={loading || undefined}
className={cx(
'inline-flex shrink-0 select-none items-center justify-center font-medium whitespace-nowrap transition-[background,color,filter,transform] duration-100 active:scale-[0.985] disabled:pointer-events-none disabled:opacity-50',
VARIANT[variant],
SIZE[size],
block && 'w-full',
className,
)}
{...rest}
>
const classes = cx(
'inline-flex shrink-0 select-none items-center justify-center font-medium whitespace-nowrap transition-[background,color,filter,transform] duration-100 active:scale-[0.985] disabled:pointer-events-none disabled:opacity-50',
VARIANT[variant],
SIZE[size],
block && 'w-full',
className,
);
const content = (
<>
{loading ? <LoaderCircle className="size-4 animate-spin" aria-hidden /> : icon ? <span className="grid shrink-0 place-items-center [&>svg]:size-4" aria-hidden>{icon}</span> : null}
{children}
</>
);
// A disabled link is not a thing: fall through to a disabled button.
if (!disabled && !loading && to) {
return (
<Link to={to} className={classes} onClick={rest.onClick as never} aria-label={rest['aria-label']}>
{content}
</Link>
);
}
if (!disabled && !loading && href) {
return (
<a href={href} target={target} download={download} rel={target === '_blank' ? 'noreferrer' : undefined} className={classes} aria-label={rest['aria-label']}>
{content}
</a>
);
}
return (
<button ref={ref} type={type} disabled={disabled || loading} aria-busy={loading || undefined} className={classes} {...rest}>
{content}
</button>
);
});