Search and paging on lists, Settings in tabs, pinned sidebar (1.3.0)
- Installs, Customers, Alerts and the audit log get a search box and 25-per-page paging (Installs also a health filter); install History pages too. - Settings is split into Releases and alerts / Email / Login and security / Audit log tabs, remembered in the URL hash. - The side navigation is sticky at window height, so Sign out no longer scrolls off long pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React from "react";
|
||||
import { ChevronLeft, ChevronRight, Search } from "lucide-react";
|
||||
import type { LicenceStatus, Problem } from "@/lib/types";
|
||||
|
||||
const STATUS_TONE: Record<string, string> = {
|
||||
@@ -71,3 +72,50 @@ export function Stat({ label, value, tone }: { label: string; value: React.React
|
||||
export function Loading() {
|
||||
return <p className="text-sm text-slate-400">Loading…</p>;
|
||||
}
|
||||
|
||||
export function SearchInput({ value, onChange, placeholder = "Search", className = "" }: { value: string; onChange: (v: string) => void; placeholder?: string; className?: string }) {
|
||||
return (
|
||||
<div className={`relative ${className}`}>
|
||||
<Search className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400" aria-hidden="true" />
|
||||
<input type="search" className="input pl-9" aria-label={placeholder} placeholder={placeholder} value={value} onChange={e => onChange(e.target.value)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** "21–40 of 132" with previous/next, under a paged table. Hidden when everything fits on one page. */
|
||||
export function Pager({ page, pages, setPage, total, pageSize }: { page: number; pages: number; setPage: (p: number) => void; total: number; pageSize: number }) {
|
||||
if (pages <= 1) return null;
|
||||
const from = (page - 1) * pageSize + 1;
|
||||
return (
|
||||
<nav aria-label="Pages" className="flex flex-wrap items-center justify-between gap-2 border-t border-slate-200 px-3 py-2 text-sm text-slate-600">
|
||||
<span className="tabular-nums">{from}–{Math.min(page * pageSize, total)} of {total}</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<button type="button" className="btn-secondary px-2 py-1" disabled={page <= 1} onClick={() => setPage(page - 1)} aria-label="Previous page"><ChevronLeft className="h-4 w-4" /></button>
|
||||
<span className="tabular-nums">Page {page} of {pages}</span>
|
||||
<button type="button" className="btn-secondary px-2 py-1" disabled={page >= pages} onClick={() => setPage(page + 1)} aria-label="Next page"><ChevronRight className="h-4 w-4" /></button>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
/** A row of tabs; the panel is whatever the page renders for the active one. */
|
||||
export function Tabs<K extends string>({ tabs, active, onChange }: { tabs: { key: K; label: string }[]; active: K; onChange: (k: K) => void }) {
|
||||
return (
|
||||
<div role="tablist" className="mb-6 flex gap-1 overflow-x-auto border-b border-slate-200">
|
||||
{tabs.map(t => (
|
||||
<button
|
||||
key={t.key}
|
||||
type="button"
|
||||
role="tab"
|
||||
id={`tab-${t.key}`}
|
||||
aria-selected={active === t.key}
|
||||
aria-controls={`panel-${t.key}`}
|
||||
onClick={() => onChange(t.key)}
|
||||
className={`-mb-px whitespace-nowrap border-b-2 px-3 py-2 text-sm ${active === t.key ? "border-indigo-600 font-medium text-indigo-700" : "border-transparent text-slate-600 hover:text-slate-900"}`}
|
||||
>
|
||||
{t.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user