Port the explorer shell: tokens, header, hero, and a generic table.
CONTENT-WP-0002-T01 adapts the pinned OnCo visual system under ui/ without the corpus, mark, or kind routes. Assistant: grok Assistant-Session: 01a1346c-fdff-7741-b1af-b7283661554b
This commit is contained in:
parent
695060e38d
commit
a6e360aaa5
27 changed files with 4013 additions and 3 deletions
13
ui/lib/sort-rows.ts
Normal file
13
ui/lib/sort-rows.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import type { SortState } from "./types";
|
||||
|
||||
export function sortRows<T>(rows: readonly T[], sort: SortState | undefined, value: (row: T, key: string) => string): T[] {
|
||||
if (!sort) return [...rows];
|
||||
const copy = [...rows];
|
||||
copy.sort((a, b) => value(a, sort.key).localeCompare(value(b, sort.key)) * sort.dir);
|
||||
return copy;
|
||||
}
|
||||
|
||||
export function nextSort(current: SortState | undefined, key: string): SortState {
|
||||
if (current?.key === key) return { key, dir: current.dir === 1 ? -1 : 1 };
|
||||
return { key, dir: 1 };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue