+
+
+ 📁
+ /romm/library/snes/Super Mario World (USA).sfc
+
+
+
+ `,
+ }),
+};
+
// ── States ──────────────────────────────────────────────────────────
export const WithHint: Story = {
diff --git a/frontend/src/v2/lib/forms/RTextField/RTextField.vue b/frontend/src/v2/lib/forms/RTextField/RTextField.vue
index 2a7c7e910..7a714d3ca 100644
--- a/frontend/src/v2/lib/forms/RTextField/RTextField.vue
+++ b/frontend/src/v2/lib/forms/RTextField/RTextField.vue
@@ -84,6 +84,12 @@ interface Props {
* matters. Affects the input/textarea only — labels keep the regular
* family so the chrome still reads as a normal form field. */
mono?: boolean;
+ /** Small context line rendered just below the field box (above the
+ * details/error row). Mono-styled — used for file paths, URLs,
+ * hashes, or any "this is where the value resolves to" hint that
+ * pairs with the field's value. The `#subtitle` slot wins over the
+ * prop when both are provided; use the slot to drop in an icon. */
+ subtitle?: string;
}
const props = withDefaults(defineProps(), {
@@ -114,6 +120,7 @@ const props = withDefaults(defineProps(), {
multiline: false,
rows: 4,
mono: false,
+ subtitle: undefined,
});
const emit = defineEmits<{
@@ -294,6 +301,8 @@ const hasAppendInner = computed(
const inlineLabelOn = computed(() => props.prefixLabel === "inline");
const stackedLabelOn = computed(() => props.prefixLabel === "stacked");
+const hasSubtitle = computed(() => !!props.subtitle || !!slots.subtitle);
+
// When `label` is set without a `prefixLabel`, we don't render a
// visible label — fall back to the label as placeholder + aria-label
// so the field still reads what it's for. Consumers wanting a visible
@@ -306,14 +315,30 @@ const effectiveAriaLabel = computed(() =>
);
// True when the parent is subscribed to a click on the adornment.
-// Vue normalises `@click:append-inner` to the key `onClick:appendInner`
-// in `$attrs`. The fallback handles older codepaths that camelCase the
-// whole name. When subscribed, the adornment renders as a focusable
-// `
+
+
+ {{ subtitle }}
+
+
("asc");
// `?kind=` URL-synced filter — same direction rules as
// `useTileSearchUrl`: route → ref on every change, ref → router.replace
@@ -183,14 +184,21 @@ const filtered = computed(() => {
return byTerm;
});
+// Sort comparator for grid mode — the toolbar asc/desc toggle drives
+// direction, name is the only sort axis the grid surface exposes.
+function gridCompare(a: CollectionTileEntry, b: CollectionTileEntry): number {
+ const sign = gridSortDir.value === "asc" ? 1 : -1;
+ return a.name.localeCompare(b.name) * sign;
+}
+
// Curated = regular + smart (both real, hand-managed). Virtual is the
// dynamic/computed kind. Splitting up front keeps every render branch
// (flat / letter / list) free of inline kind checks.
const curatedTiles = computed(() =>
- filtered.value.filter((c) => c.kind !== "virtual"),
+ [...filtered.value.filter((c) => c.kind !== "virtual")].sort(gridCompare),
);
const virtualTiles = computed(() =>
- filtered.value.filter((c) => c.kind === "virtual"),
+ [...filtered.value.filter((c) => c.kind === "virtual")].sort(gridCompare),
);
const totalCount = computed(() => tiles.value.length);
@@ -202,22 +210,38 @@ const noResults = computed(
);
type LetterGroup = { letter: string; items: CollectionTileEntry[] };
+// Bucket visual order in asc: `# A…Z @` — `#` (digits) first, `@`
+// (other symbols) last; mirrors AlphaStrip's ALPHABET. Desc flips the
+// whole sequence (`@ Z…A #`).
+const COLLECTION_BUCKET_ORDER = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ@";
function groupByLetter(items: CollectionTileEntry[]): LetterGroup[] {
- const sorted = [...items].sort((a, b) => a.name.localeCompare(b.name));
+ // `items` is pre-sorted by `gridCompare` (see curatedTiles /
+ // virtualTiles); Array.push + Map iteration preserve insertion order
+ // so items inside each bucket inherit that direction.
+ //
+ // Non-letter first chars split into two distinct buckets so digits
+ // and other symbols read as separate sections:
+ // * "#" — digits (0-9)
+ // * "@" — anything else
const map = new Map();
- for (const c of sorted) {
+ for (const c of items) {
const ch = c.name.charAt(0).toUpperCase();
- const key = /[A-Z]/.test(ch) ? ch : "#";
+ let key: string;
+ if (/[A-Z]/.test(ch)) key = ch;
+ else if (/[0-9]/.test(ch)) key = "#";
+ else key = "@";
const bucket = map.get(key);
if (bucket) bucket.push(c);
else map.set(key, [c]);
}
+ const dirSign = gridSortDir.value === "asc" ? 1 : -1;
return [...map.entries()]
- .sort(([a], [b]) => {
- if (a === "#") return 1;
- if (b === "#") return -1;
- return a.localeCompare(b);
- })
+ .sort(
+ ([a], [b]) =>
+ (COLLECTION_BUCKET_ORDER.indexOf(a) -
+ COLLECTION_BUCKET_ORDER.indexOf(b)) *
+ dirSign,
+ )
.map(([letter, items]) => ({ letter, items }));
}
const curatedLetterGroups = computed(() =>
@@ -253,6 +277,7 @@ const showVirtualSection = computed(
diff --git a/frontend/src/v2/views/PlatformsIndex.vue b/frontend/src/v2/views/PlatformsIndex.vue
index 539ba29be..0f59f1a3b 100644
--- a/frontend/src/v2/views/PlatformsIndex.vue
+++ b/frontend/src/v2/views/PlatformsIndex.vue
@@ -55,55 +55,88 @@ const playableById = computed(() => {
return map;
});
-// Sort state — local to this view (the platforms index is small enough
-// that a URL round-trip is overkill; debt item if/when we make this
-// bookmarkable).
-const sortKey = ref("name");
-const sortDir = ref<"asc" | "desc">("asc");
+// Two independent sort states. The list view's column headers drive
+// `listSortKey` + `listSortDir`; the grid view's toolbar asc/desc toggle
+// drives `gridSortDir`, with the implicit axis tied to the active
+// groupBy (letter → name, family → family, …, none → name). Keeping
+// them separate so flipping one mode doesn't reshuffle the other.
+const listSortKey = ref("name");
+const listSortDir = ref<"asc" | "desc">("asc");
+const gridSortDir = ref<"asc" | "desc">("asc");
-function onSort({ key, dir }: { key: PlatformSortKey; dir: "asc" | "desc" }) {
- sortKey.value = key;
- sortDir.value = dir;
+function onListSort({
+ key,
+ dir,
+}: {
+ key: PlatformSortKey;
+ dir: "asc" | "desc";
+}) {
+ listSortKey.value = key;
+ listSortDir.value = dir;
}
-// Comparator pulled out so the flat list and each bucket can share it.
-// `name` is the secondary tiebreaker for every other column so equal
-// values still land in a stable alphabetical order.
-function compare(a: Platform, b: Platform): number {
- const dir = sortDir.value === "asc" ? 1 : -1;
+// Sort axis the grid view should use, derived from the active groupBy.
+// Grid has no column headers — the bucket axis is the natural sort axis,
+// the toolbar asc/desc toggle is the only direction control.
+const gridSortKey = computed(() => {
+ switch (groupBy.value) {
+ case "family":
+ return "family";
+ case "category":
+ return "category";
+ case "generation":
+ return "generation";
+ case "playable":
+ return "playable";
+ default:
+ return "name";
+ }
+});
+
+// Pure comparator parameterised by (key, dir). Both sort states feed it
+// to produce their respective sorted arrays. `name` is the secondary
+// tiebreaker for every other column so equal values still land in a
+// stable alphabetical order.
+function compareBy(
+ a: Platform,
+ b: Platform,
+ key: PlatformSortKey,
+ dir: "asc" | "desc",
+): number {
+ const sign = dir === "asc" ? 1 : -1;
const byName = a.display_name.localeCompare(b.display_name);
- switch (sortKey.value) {
+ switch (key) {
case "name":
- return byName * dir;
+ return byName * sign;
case "family": {
const af = a.family_name ?? "";
const bf = b.family_name ?? "";
const cmp = af.localeCompare(bf);
- return (cmp || byName) * dir;
+ return (cmp || byName) * sign;
}
case "category": {
const ac = a.category ?? "";
const bc = b.category ?? "";
const cmp = ac.localeCompare(bc);
- return (cmp || byName) * dir;
+ return (cmp || byName) * sign;
}
case "generation": {
const ag = a.generation ?? -1;
const bg = b.generation ?? -1;
const cmp = ag - bg;
- return (cmp || byName) * dir;
+ return (cmp || byName) * sign;
}
case "playable": {
const ap = playableById.value.get(a.id) ? 1 : 0;
const bp = playableById.value.get(b.id) ? 1 : 0;
const cmp = ap - bp;
- return (cmp || byName) * dir;
+ return (cmp || byName) * sign;
}
case "rom_count": {
const ar = a.rom_count ?? 0;
const br = b.rom_count ?? 0;
const cmp = ar - br;
- return (cmp || byName) * dir;
+ return (cmp || byName) * sign;
}
}
}
@@ -164,11 +197,19 @@ const filtered = computed(() => {
);
});
-// Sorted view of the filtered list. Single source of truth feeding both
-// the flat layouts and the bucket builders (which preserve insertion
-// order, so items inside each bucket inherit this sort).
-const sorted = computed(() => {
- return [...filtered.value].sort(compare);
+// Per-mode sorted views. Grid uses the toolbar asc/desc + groupBy axis;
+// list uses the column-header click state. Buckets are always fed the
+// grid-sorted array (Map iteration preserves insertion order, so items
+// inside each bucket inherit that order).
+const sortedForGrid = computed(() => {
+ return [...filtered.value].sort((a, b) =>
+ compareBy(a, b, gridSortKey.value, gridSortDir.value),
+ );
+});
+const sortedForList = computed(() => {
+ return [...filtered.value].sort((a, b) =>
+ compareBy(a, b, listSortKey.value, listSortDir.value),
+ );
});
const totalCount = computed(() => filledPlatforms.value.length);
@@ -202,32 +243,34 @@ function bucketBy(
return [...map.values()].sort(sort);
}
-// Letter buckets. Non-alpha first chars roll up under "#" so Greek /
-// numeric / symbol-prefixed platform names still land in a stable
-// section.
-const letterGroups = computed(() =>
- bucketBy(
- sorted.value,
+// Letter buckets. Non-letter first chars split into two head buckets so
+// the user can tell digits apart from other symbols at a glance:
+// * "#" — digits (0-9)
+// * "@" — anything else (Greek, punctuation, etc.)
+// Order in asc: `# A…Z @` — `#` first, `@` last (matches AlphaStrip's
+// ALPHABET). Desc flips the whole sequence (`@ Z…A #`).
+const BUCKET_ORDER = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ@";
+const letterGroups = computed(() => {
+ const dirSign = gridSortDir.value === "asc" ? 1 : -1;
+ return bucketBy(
+ sortedForGrid.value,
(p) => {
const ch = p.display_name.charAt(0).toUpperCase();
- const key = /[A-Z]/.test(ch) ? ch : "#";
- return { key, label: key };
+ if (/[A-Z]/.test(ch)) return { key: ch, label: ch };
+ if (/[0-9]/.test(ch)) return { key: "#", label: "#" };
+ return { key: "@", label: "@" };
},
- (a, b) => {
- // "#" sorts after letters so the alphabetical run is unbroken.
- if (a.key === "#") return 1;
- if (b.key === "#") return -1;
- return a.key.localeCompare(b.key);
- },
- ),
-);
+ (a, b) =>
+ (BUCKET_ORDER.indexOf(a.key) - BUCKET_ORDER.indexOf(b.key)) * dirSign,
+ );
+});
// Family buckets. `family_slug` is the stable id (cheap to use as a
// Map key); `family_name` is what the user reads. Platforms without a
// family land in "Other" and sort last.
const familyGroups = computed(() =>
bucketBy(
- sorted.value,
+ sortedForGrid.value,
(p) => {
const slug = p.family_slug;
const name = p.family_name;
@@ -248,7 +291,7 @@ const familyGroups = computed(() =>
// label without altering the underlying key.
const categoryGroups = computed(() =>
bucketBy(
- sorted.value,
+ sortedForGrid.value,
(p) => {
const c = p.category;
if (c) return { key: c, label: prettifyPlatformCategory(c) };
@@ -267,7 +310,7 @@ const categoryGroups = computed(() =>
// list-mode metadata column and the group heading agree word-for-word.
const generationGroups = computed(() =>
bucketBy(
- sorted.value,
+ sortedForGrid.value,
(p) => {
const g = p.generation;
if (typeof g === "number" && g > 0) {
@@ -292,7 +335,7 @@ const generationGroups = computed(() =>
// top regardless of sort direction.
const playableGroups = computed(() =>
bucketBy(
- sorted.value,
+ sortedForGrid.value,
(p) =>
playableById.value.get(p.id)
? { key: "playable", label: "Playable" }
@@ -336,21 +379,23 @@ const groupedBuckets = computed(() => {
@@ -381,7 +426,7 @@ const groupedBuckets = computed(() => {
would have separated them. -->