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 { modelCount, note } = await check();
const latencyMs = Date.now() - started; const latencyMs = Date.now() - started;
const message = 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 }; return modelCount !== undefined ? { ok: true, message, latencyMs, modelCount } : { ok: true, message, latencyMs };
} catch (err) { } catch (err) {
const latencyMs = Date.now() - started; const latencyMs = Date.now() - started;

View file

@ -586,7 +586,7 @@ export function Shell() {
</main> </main>
</div> </div>
{showDrawer && ( {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>}> <Suspense fallback={<div className="grid flex-1 place-items-center"><Spinner /></div>}>
<AssistantPanel <AssistantPanel
variant="drawer" variant="drawer"

View file

@ -49,11 +49,9 @@ function DraftCard({ item, onNavigate }: { item: Extract<UiItem, { type: 'draft'
</div> </div>
</div> </div>
{!gone && ( {!gone && (
<Link to={`/drafts/${item.draftId}`} onClick={onNavigate}> <Button to={`/drafts/${item.draftId}`} onClick={onNavigate} size="sm" variant={saved ? 'secondary' : 'primary'}>
<Button size="sm" variant={saved ? 'secondary' : 'primary'}>
{saved ? 'Open' : 'Review'} {saved ? 'Open' : 'Review'}
</Button> </Button>
</Link>
)} )}
</div> </div>
); );
@ -399,11 +397,9 @@ export default function AssistantPanel({
<Callout tone="accent" icon={<Sparkles />} title="Connect an AI model to use the assistant"> <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. Add a provider such as OpenAI, Anthropic, Google Gemini or a local model, then switch on a model.
<div className="mt-3"> <div className="mt-3">
<Link to="/settings/ai" onClick={() => variant === 'drawer' && assistant.close()}> <Button to="/settings/ai" onClick={() => variant === 'drawer' && assistant.close()} size="sm" variant="primary">
<Button size="sm" variant="primary">
Open AI settings Open AI settings
</Button> </Button>
</Link>
</div> </div>
</Callout> </Callout>
</div> </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 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> </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> </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"> <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. Add a provider (OpenAI, Anthropic, Gemini, or a local model) and switch on at least one model.
<div className="mt-3"> <div className="mt-3">
<Link to="/settings/ai" onClick={onClose}> <Button to="/settings/ai" onClick={onClose} variant="primary" size="sm">
<Button variant="primary" size="sm">
Open AI settings Open AI settings
</Button> </Button>
</Link>
</div> </div>
</Callout> </Callout>
) : ( ) : (

View file

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

View file

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

View file

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

View file

@ -236,7 +236,7 @@ export default function DraftPage() {
const canSave = errors.length === 0 && (mode === 'new' ? Boolean(classId) : Boolean(targetId)); const canSave = errors.length === 0 && (mode === 'new' ? Boolean(classId) : Boolean(targetId));
return ( return (
<div className="animate-in pb-28"> <div className="animate-in">
<header className="mb-6"> <header className="mb-6">
<div className="eyebrow mb-2 flex flex-wrap items-center gap-2"> <div className="eyebrow mb-2 flex flex-wrap items-center gap-2">
<span className="flex items-center gap-1.5 [&>svg]:size-3.5"> <span className="flex items-center gap-1.5 [&>svg]:size-3.5">
@ -487,8 +487,8 @@ export default function DraftPage() {
)} )}
{/* save bar */} {/* 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="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="mx-auto flex h-16 max-w-[1080px] items-center gap-2 px-4 sm:px-8"> <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"> <div className="min-w-0 flex-1 text-[13px]" aria-live="polite">
{errors.length > 0 ? ( {errors.length > 0 ? (
<span className="flex items-center gap-1.5 font-medium text-bad"> <span className="flex items-center gap-1.5 font-medium text-bad">

View file

@ -152,11 +152,9 @@ export default function Home() {
</div> </div>
<div className="mt-5 flex flex-wrap gap-2"> <div className="mt-5 flex flex-wrap gap-2">
{due > 0 ? ( {due > 0 ? (
<Link to="/review"> <Button to="/review" variant="primary" size="lg" icon={<Play className="fill-current" />}>
<Button variant="primary" size="lg" icon={<Play className="fill-current" />}>
Start review Start review
</Button> </Button>
</Link>
) : null} ) : null}
{o.missedCount > 0 && ( {o.missedCount > 0 && (
<Button size="lg" icon={<RotateCcw />} loading={starting} onClick={() => start({ source: { type: 'missed' }, count: Math.min(20, o.missedCount) })}> <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>
<div className="flex flex-wrap items-center gap-2"> <div className="flex flex-wrap items-center gap-2">
{data.activeAttempt ? ( {data.activeAttempt ? (
<Link to={`/session/${data.activeAttempt.id}`}> <Button to={`/session/${data.activeAttempt.id}`} variant="marker" size="lg" icon={<Play className="fill-current" />}>
<Button variant="marker" size="lg" icon={<Play className="fill-current" />}>
Resume ({data.activeAttempt.answeredCount}/{data.activeAttempt.questionCount}) Resume ({data.activeAttempt.answeredCount}/{data.activeAttempt.questionCount})
</Button> </Button>
</Link>
) : null} ) : null}
<Button variant={data.activeAttempt ? 'secondary' : 'primary'} size="lg" icon={<Play className="fill-current" />} disabled={questions.length === 0} onClick={() => setStartOpen(true)}> <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'} {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.filename} · {formatBytes(doc.size)}
{doc.pageCount ? ` · ${plural(doc.pageCount, 'page')}` : ''} {doc.pageCount ? ` · ${plural(doc.pageCount, 'page')}` : ''}
</p> </p>
<a href={url} download={inline ? undefined : doc.filename} target={inline ? '_blank' : undefined} rel="noreferrer" className="mt-5 inline-block"> <Button href={url} download={inline ? undefined : doc.filename} target={inline ? '_blank' : undefined} variant="primary" size="lg" icon={<Download />} className="mt-5">
<Button variant="primary" size="lg" icon={<Download />}>
{inline ? 'Open file' : 'Download'} {inline ? 'Open file' : 'Download'}
</Button> </Button>
</a>
{doc.docKind === 'image' && <img src={url} alt={doc.title} className="card mt-6 max-w-full p-2" />} {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" />} {doc.docKind === 'pdf' && <iframe src={url} title={doc.title} className="card mt-6 hidden h-[78vh] w-full sm:block" />}
</Frame> </Frame>

View file

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

View file

@ -1,6 +1,7 @@
import { CircleAlert, Inbox, LoaderCircle, X } from 'lucide-react'; 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 { 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 { 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'; import { cx } from '@/lib/util';
/* ------------------------------ Button ------------------------------ */ /* ------------------------------ Button ------------------------------ */
@ -27,29 +28,49 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
loading?: boolean; loading?: boolean;
icon?: ReactNode; icon?: ReactNode;
block?: boolean; 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( 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, ref,
) { ) {
return ( const classes = cx(
<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', '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], VARIANT[variant],
SIZE[size], SIZE[size],
block && 'w-full', block && 'w-full',
className, className,
)} );
{...rest} 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} {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} {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> </button>
); );
}); });