mirror of
https://github.com/rommapp/romm.git
synced 2026-12-05 23:44:11 +01:00
feat(v2): collapse detail subtabs and notes into a picker on phones
Media, Files, Save data and Notes share SubtabNav: the side rail on wide layouts, and on phones a single trigger row opening a bottom sheet (grouped for notes, searchable past eight entries). A subtab's single Upload joins that row, and the walkthrough URL form wraps instead of overflowing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CZ7NE6z9cJ8zsT3TsCtQds
This commit is contained in:
@@ -23,7 +23,7 @@ async function openTab(page: Page, tab: string) {
|
||||
// Media subtabs are a sidebar list of role=tab buttons, distinct from the
|
||||
// top-level RTabNav tabs.
|
||||
async function openSubtab(page: Page, subtab: string) {
|
||||
await page.locator(".r-v2-media__subtab-btn", { hasText: subtab }).click();
|
||||
await page.locator(".r-v2-subtab-nav__btn", { hasText: subtab }).click();
|
||||
}
|
||||
|
||||
/** The one Media panel currently on screen. */
|
||||
@@ -132,9 +132,7 @@ test.describe("Files tab write affordances", () => {
|
||||
await gotoFirstRom(page);
|
||||
await openTab(page, "Files");
|
||||
|
||||
await expect(
|
||||
page.locator(".r-v2-files__subtab-btn").first(),
|
||||
).toBeVisible();
|
||||
await expect(page.locator(".r-v2-subtab-nav__btn").first()).toBeVisible();
|
||||
await expect(uploadButton(page)).toHaveCount(0);
|
||||
await expect(uploadToFolderButton(page)).toHaveCount(0);
|
||||
});
|
||||
@@ -157,7 +155,7 @@ test.describe("Files tab write affordances", () => {
|
||||
await gotoFirstRom(page);
|
||||
await openTab(page, "Files");
|
||||
await page
|
||||
.locator(".r-v2-files__subtab-btn:not(.r-v2-files__subtab-btn--active)")
|
||||
.locator(".r-v2-subtab-nav__btn:not(.r-v2-subtab-nav__btn--active)")
|
||||
.first()
|
||||
.click();
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
// Layout mirrors ScreenshotsSubtab / SaveDataTab / MediaTab: a vertical
|
||||
// subtab list on the left (navigation only — no inline action panel),
|
||||
// and a content column on the right with a section header that hosts
|
||||
// the Upload button plus a Patch button (multi-file ROMs only). Bulk
|
||||
// the Upload button plus a Patch button (multi-file ROMs only). On phones
|
||||
// the list collapses into a folder picker in that same header row. Bulk
|
||||
// download / copy-link affordances live in the selection toolbar
|
||||
// instead — pair them with select-all.
|
||||
//
|
||||
@@ -36,7 +37,7 @@
|
||||
// Selected files in the Files tab can be deleted by users with the
|
||||
// `rom.delete` permission. Each file is removed from disk and the DB
|
||||
// row is dropped via `DELETE /roms/{rom_id}/files/{file_id}`.
|
||||
import { RBtn, RCheckbox, REmptyState, RIcon } from "@v2/lib";
|
||||
import { RBtn, RCheckbox, REmptyState } from "@v2/lib";
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
@@ -48,6 +49,10 @@ import type {
|
||||
import romApi from "@/services/api/rom";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import { getDownloadLink } from "@/utils";
|
||||
import SubtabNav, {
|
||||
type SubtabNavItem,
|
||||
} from "@/v2/components/GameDetails/SubtabNav.vue";
|
||||
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
|
||||
import { useCan } from "@/v2/composables/useCan";
|
||||
import { useConfirm } from "@/v2/composables/useConfirm";
|
||||
import { useIsAlive } from "@/v2/composables/useIsAlive";
|
||||
@@ -72,6 +77,7 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const romsStore = storeRoms();
|
||||
const { refetchRom } = useRomSync();
|
||||
const { smAndDown } = useBreakpoint();
|
||||
|
||||
const canUpload = useCan("rom.upload");
|
||||
const hasDeleteGrant = useCan("rom.delete");
|
||||
@@ -252,20 +258,13 @@ function folderIcon(folder: string): string {
|
||||
return folderMeta(folder)?.icon ?? "mdi-folder-outline";
|
||||
}
|
||||
|
||||
interface SubtabDef {
|
||||
id: Subtab;
|
||||
label: string;
|
||||
icon: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
const subtabDefs = computed<SubtabDef[]>(() => {
|
||||
const out: SubtabDef[] = [
|
||||
const subtabDefs = computed<SubtabNavItem<Subtab>[]>(() => {
|
||||
const out: SubtabNavItem<Subtab>[] = [
|
||||
{
|
||||
id: "all",
|
||||
label: t("rom.all-files"),
|
||||
icon: "mdi-folder-multiple-outline",
|
||||
count: files.value.length,
|
||||
badge: files.value.length,
|
||||
},
|
||||
];
|
||||
// Root always sits right after "All files" so the user's eye lands
|
||||
@@ -277,7 +276,7 @@ const subtabDefs = computed<SubtabDef[]>(() => {
|
||||
id: ROOT,
|
||||
label: t("rom.folder-root"),
|
||||
icon: folderIcon(ROOT),
|
||||
count: rootList.length,
|
||||
badge: rootList.length,
|
||||
});
|
||||
}
|
||||
const folders = [...filesByFolder.value.keys()]
|
||||
@@ -288,7 +287,7 @@ const subtabDefs = computed<SubtabDef[]>(() => {
|
||||
id: folder,
|
||||
label: folderLabel(folder),
|
||||
icon: folderIcon(folder),
|
||||
count: filesByFolder.value.get(folder)?.length ?? 0,
|
||||
badge: filesByFolder.value.get(folder)?.length ?? 0,
|
||||
});
|
||||
}
|
||||
return out;
|
||||
@@ -555,7 +554,7 @@ const uploadFolders = computed<UploadFolderOption[]>(() => [
|
||||
{ value: "", label: folderLabel(ROOT), icon: folderIcon(ROOT) },
|
||||
...subtabDefs.value
|
||||
.filter((s) => s.id !== "all" && s.id !== ROOT)
|
||||
.map((s) => ({ value: s.id, label: s.label, icon: s.icon })),
|
||||
.map((s) => ({ value: s.id, label: s.label, icon: folderIcon(s.id) })),
|
||||
]);
|
||||
|
||||
// Destination implied by the active subtab: "" for the ROM root, null
|
||||
@@ -613,47 +612,36 @@ async function refreshRom() {
|
||||
/>
|
||||
|
||||
<div class="r-v2-files">
|
||||
<aside class="r-v2-files__sidebar">
|
||||
<ul
|
||||
class="r-v2-files__subtabs"
|
||||
role="tablist"
|
||||
aria-orientation="vertical"
|
||||
>
|
||||
<li v-for="tab in subtabDefs" :key="tab.id" class="r-v2-files__subtab">
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
class="r-v2-files__subtab-btn"
|
||||
:class="{
|
||||
'r-v2-files__subtab-btn--active': subTab === tab.id,
|
||||
}"
|
||||
:aria-selected="subTab === tab.id"
|
||||
@click="subTab = tab.id"
|
||||
>
|
||||
<RIcon :icon="tab.icon" size="16" />
|
||||
<span class="r-v2-files__subtab-label">{{ tab.label }}</span>
|
||||
<span v-if="tab.count > 0" class="r-v2-files__subtab-badge">
|
||||
{{ tab.count }}
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<aside v-if="!smAndDown" class="r-v2-files__sidebar">
|
||||
<SubtabNav v-model="subTab" :items="subtabDefs" />
|
||||
</aside>
|
||||
|
||||
<div class="r-v2-files__content">
|
||||
<!-- Section header — the sidebar's subtab label already names the
|
||||
section, so the header skips a redundant title and just hosts
|
||||
the upload action on the right. Download-all / Copy-link are
|
||||
covered by the selection toolbar below (select-all then act). -->
|
||||
<!-- Section header: the subtab nav already names the section, so the
|
||||
header skips a redundant title and just hosts the upload action on
|
||||
the right (next to the folder picker on phones). Download-all /
|
||||
Copy-link are covered by the selection toolbar below (select-all
|
||||
then act). -->
|
||||
<header
|
||||
v-if="filteredFiles.length > 0 && canUpload"
|
||||
v-if="smAndDown || (filteredFiles.length > 0 && canUpload)"
|
||||
class="r-v2-files__section-head"
|
||||
>
|
||||
<div class="r-v2-files__section-actions">
|
||||
<SubtabNav
|
||||
v-if="smAndDown"
|
||||
v-model="subTab"
|
||||
:items="subtabDefs"
|
||||
variant="menu"
|
||||
class="r-v2-files__subtab-menu"
|
||||
/>
|
||||
<div
|
||||
v-if="filteredFiles.length > 0 && canUpload"
|
||||
class="r-v2-files__section-actions"
|
||||
>
|
||||
<RBtn
|
||||
v-if="activeUploadFolder === null"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
:density="smAndDown ? 'comfortable' : undefined"
|
||||
prepend-icon="mdi-folder-upload-outline"
|
||||
:disabled="uploading"
|
||||
:loading="uploading"
|
||||
@@ -665,6 +653,7 @@ async function refreshRom() {
|
||||
v-else
|
||||
variant="outlined"
|
||||
size="small"
|
||||
:density="smAndDown ? 'comfortable' : undefined"
|
||||
prepend-icon="mdi-cloud-upload-outline"
|
||||
:disabled="uploading"
|
||||
:loading="uploading"
|
||||
@@ -802,81 +791,13 @@ async function refreshRom() {
|
||||
.r-v2-files__sidebar {
|
||||
width: 220px;
|
||||
flex-shrink: 0;
|
||||
/* Independent scroll context for the subtab list — without
|
||||
`min-height: 0` + an `overflow-y: auto` child, ROMs with many
|
||||
subfolders push tabs past the panel's visible area and they
|
||||
become unreachable. */
|
||||
/* Caps the subtab list to the panel height so it scrolls on its own;
|
||||
otherwise ROMs with many subfolders push tabs out of reach. */
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Subtab list — visually identical to MediaTab/SaveDataTab so the
|
||||
three tabs share a single navigation vocabulary. Scrolls internally
|
||||
when the folder count exceeds the available vertical space. */
|
||||
.r-v2-files__subtabs {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0 4px 4px 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--r-color-border-strong) transparent;
|
||||
}
|
||||
.r-v2-files__subtabs::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
.r-v2-files__subtabs::-webkit-scrollbar-thumb {
|
||||
background: var(--r-color-border-strong);
|
||||
border-radius: 2px;
|
||||
}
|
||||
.r-v2-files__subtab {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.r-v2-files__subtab-btn {
|
||||
width: 100%;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border-radius: var(--r-radius-md);
|
||||
color: var(--r-color-fg-muted);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: var(--r-font-weight-medium);
|
||||
transition:
|
||||
background var(--r-motion-fast) var(--r-motion-ease-out),
|
||||
color var(--r-motion-fast) var(--r-motion-ease-out);
|
||||
}
|
||||
.r-v2-files__subtab-btn:hover {
|
||||
background: var(--r-color-surface-hover);
|
||||
color: var(--r-color-fg);
|
||||
}
|
||||
.r-v2-files__subtab-btn--active {
|
||||
background: color-mix(in srgb, var(--r-color-brand-primary) 18%, transparent);
|
||||
color: var(--r-color-brand-primary);
|
||||
}
|
||||
.r-v2-files__subtab-label {
|
||||
flex: 1;
|
||||
}
|
||||
.r-v2-files__subtab-badge {
|
||||
font-size: 10px;
|
||||
font-weight: var(--r-font-weight-bold);
|
||||
padding: 1px 7px;
|
||||
border-radius: 999px;
|
||||
background: color-mix(in srgb, currentColor 18%, transparent);
|
||||
}
|
||||
|
||||
/* The hidden file input sits at the template root so the visible button
|
||||
can `.click()` it; display:none works fine since it never needs to be
|
||||
tabbable directly. */
|
||||
@@ -894,6 +815,9 @@ async function refreshRom() {
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.r-v2-files__subtab-menu {
|
||||
flex: 1;
|
||||
}
|
||||
.r-v2-files__section-actions {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
@@ -981,8 +905,8 @@ async function refreshRom() {
|
||||
|
||||
/* Mobile: the details view scrolls as one document (no fixed inner panel),
|
||||
so FilesTab can't pin itself to a scroll viewport (`absolute; inset: 0`
|
||||
would collapse to zero height). Unwind it: stack the folder sidebar above
|
||||
the file list and drop every internal scroll so it flows with the page. */
|
||||
would collapse to zero height). Unwind it and drop every internal scroll so
|
||||
the list flows with the page. */
|
||||
html[data-bp~="sm-and-down"] .r-v2-files {
|
||||
position: static;
|
||||
inset: auto;
|
||||
@@ -990,14 +914,6 @@ html[data-bp~="sm-and-down"] .r-v2-files {
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
html[data-bp~="sm-and-down"] .r-v2-files__sidebar {
|
||||
width: auto;
|
||||
}
|
||||
html[data-bp~="sm-and-down"] .r-v2-files__subtabs {
|
||||
flex: none;
|
||||
min-height: 0;
|
||||
overflow-y: visible;
|
||||
}
|
||||
html[data-bp~="sm-and-down"] .r-v2-files__content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -1010,13 +926,6 @@ html[data-bp~="sm-and-down"] .r-v2-files__list {
|
||||
|
||||
/* (File-row styles moved to the FileRow component.) */
|
||||
|
||||
html[data-bp~="xs"] .r-v2-files {
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
html[data-bp~="xs"] .r-v2-files__sidebar {
|
||||
width: auto;
|
||||
}
|
||||
html[data-bp~="xs"] .r-v2-files__toolbar {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,12 @@ const TextViewer = defineAsyncComponent(
|
||||
() => import("@/v2/components/GameDetails/TextViewer.vue"),
|
||||
);
|
||||
|
||||
const props = defineProps<{ rom: DetailedRom }>();
|
||||
const props = defineProps<{
|
||||
rom: DetailedRom;
|
||||
/** Drop the header Upload button when the parent renders it elsewhere
|
||||
* (through the exposed `openUpload`). */
|
||||
hideUpload?: boolean;
|
||||
}>();
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const snackbar = useSnackbar();
|
||||
const { refetchRom } = useRomSync();
|
||||
@@ -128,6 +133,11 @@ const manualDz = ref<InstanceType<typeof RDropzone> | null>(null);
|
||||
const canUploadMore = computed(
|
||||
() => manualEntries.value.length > 0 && canEdit.value,
|
||||
);
|
||||
|
||||
defineExpose({
|
||||
canUpload: canUploadMore,
|
||||
openUpload: () => manualDz.value?.open(),
|
||||
});
|
||||
const redownloadingManual = ref(false);
|
||||
|
||||
function handleManualFiles(files: File[]) {
|
||||
@@ -172,7 +182,7 @@ function requestDeleteManual() {
|
||||
<!-- The subtab label in the sidebar already names the section, so the
|
||||
header skips a redundant title. -->
|
||||
<header
|
||||
v-if="manualEntries.length > 1 || canUploadMore"
|
||||
v-if="manualEntries.length > 1 || (canUploadMore && !hideUpload)"
|
||||
class="r-v2-manual__head"
|
||||
>
|
||||
<RSelect
|
||||
@@ -185,7 +195,7 @@ function requestDeleteManual() {
|
||||
class="r-v2-manual__select"
|
||||
/>
|
||||
<RBtn
|
||||
v-if="canUploadMore"
|
||||
v-if="canUploadMore && !hideUpload"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
prepend-icon="mdi-cloud-upload-outline"
|
||||
|
||||
@@ -11,11 +11,15 @@
|
||||
// * Upload goes through `useRomFileUpload`, into the soundtrack/ folder
|
||||
//
|
||||
// The soundtrack player is reused from v1 for now.
|
||||
import { RBtn, RDropzone, REmptyState, RIcon } from "@v2/lib";
|
||||
import { RBtn, RDropzone, REmptyState } from "@v2/lib";
|
||||
import { computed, defineAsyncComponent, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import type { DetailedRom } from "@/stores/roms";
|
||||
import SubtabNav, {
|
||||
type SubtabNavItem,
|
||||
} from "@/v2/components/GameDetails/SubtabNav.vue";
|
||||
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
|
||||
import { useCan } from "@/v2/composables/useCan";
|
||||
import {
|
||||
ROM_UPLOAD_FOLDERS,
|
||||
@@ -51,6 +55,7 @@ const {
|
||||
} = useRomSoundtrack(() => props.rom);
|
||||
const { refetchRom } = useRomSync();
|
||||
const { t } = useI18n();
|
||||
const { smAndDown } = useBreakpoint();
|
||||
|
||||
// Soundtrack upload / delete both gate on the ROM write grant, so read-only
|
||||
// users get the player without any upload or delete affordance.
|
||||
@@ -109,12 +114,7 @@ watch(
|
||||
);
|
||||
|
||||
// ---------- Subtab nav ----------
|
||||
// We render the subtab list manually (not via RTabNav) because each
|
||||
// subtab's content panel owns its own section header with title +
|
||||
// contextual actions — the sidebar stays navigation-only, mirroring
|
||||
// ScreenshotsSubtab.
|
||||
type SubtabDef = { id: Subtab; label: string; icon: string };
|
||||
const subtabDefs = computed<SubtabDef[]>(() => [
|
||||
const subtabDefs = computed<SubtabNavItem<Subtab>[]>(() => [
|
||||
{
|
||||
id: "manual",
|
||||
label: t("rom.manual"),
|
||||
@@ -147,6 +147,29 @@ const subtabDefs = computed<SubtabDef[]>(() => [
|
||||
// player when filled). The section header's "upload" button opens the filled
|
||||
// dropzone's picker via this ref.
|
||||
const soundtrackDz = ref<InstanceType<typeof RDropzone> | null>(null);
|
||||
const canUploadSoundtrack = computed(
|
||||
() => props.rom.has_soundtrack && canEdit.value,
|
||||
);
|
||||
|
||||
// On phones a subtab's single Upload joins the picker row; Screenshots has one
|
||||
// per section, so it keeps them in place.
|
||||
type UploadAction = { canUpload: boolean; openUpload: () => void };
|
||||
const manualPanel = ref<UploadAction | null>(null);
|
||||
const walkthroughPanel = ref<UploadAction | null>(null);
|
||||
|
||||
const pickerRowUpload = computed<(() => void) | null>(() => {
|
||||
const panel =
|
||||
subTab.value === "manual"
|
||||
? manualPanel.value
|
||||
: subTab.value === "walkthrough"
|
||||
? walkthroughPanel.value
|
||||
: null;
|
||||
if (panel?.canUpload) return panel.openUpload;
|
||||
if (subTab.value === "soundtrack" && canUploadSoundtrack.value) {
|
||||
return () => soundtrackDz.value?.open();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
async function refreshRom() {
|
||||
await refetchRom(props.rom.id);
|
||||
@@ -169,33 +192,27 @@ async function deleteSoundtrack(fileId: number) {
|
||||
|
||||
<template>
|
||||
<div class="r-v2-media">
|
||||
<aside class="r-v2-media__sidebar">
|
||||
<ul
|
||||
class="r-v2-media__subtabs"
|
||||
role="tablist"
|
||||
aria-orientation="vertical"
|
||||
>
|
||||
<li
|
||||
v-for="tab in subtabDefs"
|
||||
:key="tab.id"
|
||||
class="r-v2-media__subtab"
|
||||
:class="{ 'r-v2-media__subtab--active': subTab === tab.id }"
|
||||
<SubtabNav
|
||||
v-if="smAndDown"
|
||||
v-model="subTab"
|
||||
:items="subtabDefs"
|
||||
variant="menu"
|
||||
>
|
||||
<template #actions>
|
||||
<RBtn
|
||||
v-if="pickerRowUpload"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
density="comfortable"
|
||||
prepend-icon="mdi-cloud-upload-outline"
|
||||
@click="pickerRowUpload()"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
class="r-v2-media__subtab-btn"
|
||||
:class="{
|
||||
'r-v2-media__subtab-btn--active': subTab === tab.id,
|
||||
}"
|
||||
:aria-selected="subTab === tab.id"
|
||||
@click="subTab = tab.id"
|
||||
>
|
||||
<RIcon :icon="tab.icon" size="16" />
|
||||
<span class="r-v2-media__subtab-label">{{ tab.label }}</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
{{ t("common.upload") }}
|
||||
</RBtn>
|
||||
</template>
|
||||
</SubtabNav>
|
||||
<aside v-else class="r-v2-media__sidebar">
|
||||
<SubtabNav v-model="subTab" :items="subtabDefs" />
|
||||
</aside>
|
||||
|
||||
<div class="r-v2-media__content">
|
||||
@@ -208,13 +225,17 @@ async function deleteSoundtrack(fileId: number) {
|
||||
<!-- Manual subtab — its own component (PDF / Markdown viewer with an
|
||||
entry selector; scrolls independently). -->
|
||||
<section v-show="subTab === 'manual'" class="r-v2-media__panel">
|
||||
<ManualSubtab :rom="rom" />
|
||||
<ManualSubtab ref="manualPanel" :rom="rom" :hide-upload="smAndDown" />
|
||||
</section>
|
||||
|
||||
<!-- Walkthrough subtab: uploaded or GameFAQs-fetched documents, with
|
||||
per-user reading progress. -->
|
||||
<section v-show="subTab === 'walkthrough'" class="r-v2-media__panel">
|
||||
<WalkthroughSubtab :rom="rom" />
|
||||
<WalkthroughSubtab
|
||||
ref="walkthroughPanel"
|
||||
:rom="rom"
|
||||
:hide-upload="smAndDown"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<!-- Screenshots subtab — its own component (ROM / Mine / Community
|
||||
@@ -232,7 +253,7 @@ async function deleteSoundtrack(fileId: number) {
|
||||
<!-- Soundtrack subtab -->
|
||||
<section v-show="subTab === 'soundtrack'" class="r-v2-media__panel">
|
||||
<header
|
||||
v-if="rom.has_soundtrack && canEdit"
|
||||
v-if="canUploadSoundtrack && !smAndDown"
|
||||
class="r-v2-media__section-head"
|
||||
>
|
||||
<div class="r-v2-media__section-actions">
|
||||
@@ -307,53 +328,6 @@ async function deleteSoundtrack(fileId: number) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Subtab list — navigation only. Per-section actions (Upload, etc.)
|
||||
live in the content column's section headers, mirroring
|
||||
ScreenshotsSubtab. */
|
||||
.r-v2-media__subtabs {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
.r-v2-media__subtab {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.r-v2-media__subtab-btn {
|
||||
width: 100%;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border-radius: var(--r-radius-md);
|
||||
color: var(--r-color-fg-muted);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: var(--r-font-weight-medium);
|
||||
transition:
|
||||
background var(--r-motion-fast) var(--r-motion-ease-out),
|
||||
color var(--r-motion-fast) var(--r-motion-ease-out);
|
||||
}
|
||||
.r-v2-media__subtab-btn:hover {
|
||||
background: var(--r-color-surface-hover);
|
||||
color: var(--r-color-fg);
|
||||
}
|
||||
.r-v2-media__subtab-btn--active {
|
||||
background: color-mix(in srgb, var(--r-color-brand-primary) 18%, transparent);
|
||||
color: var(--r-color-brand-primary);
|
||||
}
|
||||
.r-v2-media__subtab-label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.r-v2-media__content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
@@ -408,13 +382,10 @@ html[data-bp~="sm-and-down"] .r-v2-media__fill {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
html[data-bp~="xs"] .r-v2-media {
|
||||
html[data-bp~="sm-and-down"] .r-v2-media {
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
html[data-bp~="xs"] .r-v2-media__sidebar {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* Soundtrack — the v1 player has its own internal styling; wrap in an
|
||||
elevated container so it blends with v2 tokens. */
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
// NotesTab — per-ROM notes with a left index (own + community sections)
|
||||
// and a right pane that swaps between MdPreview (read) and MdEditor
|
||||
// (edit-in-place). Public/private toggles via a single icon button (no
|
||||
// dialog), edits save inline, and the active note is URL-persistent via
|
||||
// `?note=<id>` so links deep-link straight to a specific note.
|
||||
// NotesTab: per-ROM notes with a left index (own + community sections;
|
||||
// a grouped note picker on phones) and a right pane that swaps between
|
||||
// MdPreview (read) and MdEditor (edit-in-place). Public/private toggles via a
|
||||
// single icon button (no dialog), edits save inline, and the active note is
|
||||
// URL-persistent via `?note=<id>` so links deep-link straight to a specific
|
||||
// note.
|
||||
import {
|
||||
REmptyState,
|
||||
RAvatar,
|
||||
@@ -23,6 +24,10 @@ import type { UserNoteSchema } from "@/__generated__";
|
||||
import romApi from "@/services/api/rom";
|
||||
import storeAuth from "@/stores/auth";
|
||||
import type { DetailedRom } from "@/stores/roms";
|
||||
import SubtabNav, {
|
||||
type SubtabNavItem,
|
||||
} from "@/v2/components/GameDetails/SubtabNav.vue";
|
||||
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
|
||||
import { useConfirm } from "@/v2/composables/useConfirm";
|
||||
import { useRomSync } from "@/v2/composables/useRomSync";
|
||||
import { useSnackbar } from "@/v2/composables/useSnackbar";
|
||||
@@ -42,6 +47,7 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { isLight: isLightTheme } = useThemeMode();
|
||||
const { user } = storeToRefs(authStore);
|
||||
const { smAndDown } = useBreakpoint();
|
||||
|
||||
const mdTheme = computed<"light" | "dark">(() =>
|
||||
isLightTheme.value ? "light" : "dark",
|
||||
@@ -69,6 +75,44 @@ const communityNotes = computed<UserNoteSchema[]>(() =>
|
||||
.sort((a, b) => a.title.localeCompare(b.title)),
|
||||
);
|
||||
|
||||
// Picker entries for phones, own notes first, matching the desktop index.
|
||||
const noteNavItems = computed<SubtabNavItem[]>(() => [
|
||||
...myNotes.value.map((n) => ({
|
||||
id: String(n.id),
|
||||
label: n.title,
|
||||
group: t("rom.my-notes"),
|
||||
})),
|
||||
...communityNotes.value.map((n) => ({
|
||||
id: String(n.id),
|
||||
label: n.title,
|
||||
group: t("rom.notes-community"),
|
||||
})),
|
||||
]);
|
||||
|
||||
// Row decorations keyed by picker id: an author avatar and name for
|
||||
// community notes, a lock for private own notes.
|
||||
const noteNavExtras = computed(() => {
|
||||
const extras = new Map<
|
||||
string,
|
||||
{ author: { name: string; avatar: string } | null; locked: boolean }
|
||||
>();
|
||||
for (const n of myNotes.value) {
|
||||
extras.set(String(n.id), { author: null, locked: !n.is_public });
|
||||
}
|
||||
for (const n of communityNotes.value) {
|
||||
const avatar = userAvatarUrl({
|
||||
userId: n.user_id,
|
||||
avatarPath: n.user_avatar_path,
|
||||
updatedAt: n.user_updated_at,
|
||||
});
|
||||
extras.set(String(n.id), {
|
||||
author: { name: n.username, avatar },
|
||||
locked: false,
|
||||
});
|
||||
}
|
||||
return extras;
|
||||
});
|
||||
|
||||
const hasAnyNotes = computed(
|
||||
() => myNotes.value.length > 0 || communityNotes.value.length > 0,
|
||||
);
|
||||
@@ -320,7 +364,46 @@ function fmtDate(iso: string): string {
|
||||
</REmptyState>
|
||||
|
||||
<div v-else class="r-v2-notes__body">
|
||||
<aside class="r-v2-notes__index">
|
||||
<SubtabNav
|
||||
v-if="smAndDown && !editForm"
|
||||
:model-value="selectedNoteId === null ? '' : String(selectedNoteId)"
|
||||
:items="noteNavItems"
|
||||
variant="menu"
|
||||
@update:model-value="(id) => selectNote(Number(id))"
|
||||
>
|
||||
<template #item-append="{ item }">
|
||||
<span
|
||||
v-if="noteNavExtras.get(item.id)?.author"
|
||||
class="r-v2-notes__nav-author"
|
||||
>
|
||||
<RAvatar
|
||||
:image="noteNavExtras.get(item.id)?.author?.avatar"
|
||||
size="18"
|
||||
/>
|
||||
<span>{{ noteNavExtras.get(item.id)?.author?.name }}</span>
|
||||
</span>
|
||||
<RIcon
|
||||
v-else-if="noteNavExtras.get(item.id)?.locked"
|
||||
icon="mdi-lock"
|
||||
size="13"
|
||||
class="r-v2-notes__nav-lock"
|
||||
/>
|
||||
</template>
|
||||
<template #actions>
|
||||
<RBtn
|
||||
:disabled="!canCreate"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
density="comfortable"
|
||||
prepend-icon="mdi-plus"
|
||||
@click="startAdd"
|
||||
>
|
||||
{{ t("rom.notes-add") }}
|
||||
</RBtn>
|
||||
</template>
|
||||
</SubtabNav>
|
||||
|
||||
<aside v-if="!smAndDown" class="r-v2-notes__index">
|
||||
<template v-if="myNotes.length > 0">
|
||||
<div class="r-v2-notes__group-label">{{ t("rom.my-notes") }}</div>
|
||||
<ul class="r-v2-notes__group">
|
||||
@@ -661,7 +744,7 @@ function fmtDate(iso: string): string {
|
||||
.r-v2-notes__nav-item--rich {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
gap: var(--r-space-2);
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.r-v2-notes__nav-title {
|
||||
@@ -705,7 +788,7 @@ function fmtDate(iso: string): string {
|
||||
.r-v2-notes__pane-title-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
gap: var(--r-space-2);
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
@@ -808,10 +891,7 @@ function fmtDate(iso: string): string {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
html[data-bp~="xs"] .r-v2-notes__body {
|
||||
html[data-bp~="sm-and-down"] .r-v2-notes__body {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
html[data-bp~="xs"] .r-v2-notes__index {
|
||||
position: static;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
// SaveDataTab — Saves + States, each its own subtab with badge counts
|
||||
// and per-tab Upload affordance. Layout mirrors ScreenshotsSubtab: a
|
||||
// vertical subtab list on the left (navigation only — no inline action
|
||||
// panel), and per-section headers in the content column with the
|
||||
// vertical subtab list on the left (a subtab picker above the content on
|
||||
// phones; navigation only, no inline action panel), and per-section
|
||||
// headers in the content column with the
|
||||
// Upload button on the right when the section already has items. Empty
|
||||
// sections promote the dropzone CTA (the dropzone owns the upload
|
||||
// affordance there).
|
||||
@@ -15,7 +16,7 @@
|
||||
// URL-persistent subtab selection via `?subtab=` so deep-linking
|
||||
// into a specific list works and stale state doesn't leak when the
|
||||
// user navigates to a sibling tab.
|
||||
import { RBtn, RDropzone, RIcon } from "@v2/lib";
|
||||
import { RBtn, RDropzone } from "@v2/lib";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
@@ -33,11 +34,15 @@ import storeAuth from "@/stores/auth";
|
||||
import storeConfig from "@/stores/config";
|
||||
import { getSupportedEJSCores } from "@/utils";
|
||||
import AssetActions from "@/v2/components/GameDetails/AssetActions.vue";
|
||||
import SubtabNav, {
|
||||
type SubtabNavItem,
|
||||
} from "@/v2/components/GameDetails/SubtabNav.vue";
|
||||
import UploadAssetDialog, {
|
||||
type UploadAssetPayload,
|
||||
} from "@/v2/components/GameDetails/UploadAssetDialog.vue";
|
||||
import AssetList from "@/v2/components/shared/AssetList.vue";
|
||||
import AssetStrip from "@/v2/components/shared/AssetStrip.vue";
|
||||
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
|
||||
import { useConfirm } from "@/v2/composables/useConfirm";
|
||||
import { useRomSync } from "@/v2/composables/useRomSync";
|
||||
import { useSnackbar } from "@/v2/composables/useSnackbar";
|
||||
@@ -54,6 +59,7 @@ defineOptions({ inheritAttrs: false });
|
||||
|
||||
const props = defineProps<{ rom: DetailedRomSchema }>();
|
||||
const { t } = useI18n();
|
||||
const { smAndDown } = useBreakpoint();
|
||||
|
||||
// ---------- Subtab state (URL-persisted via `?subtab=`) ----------
|
||||
const validSubtabs = ["saves", "states"] as const;
|
||||
@@ -127,10 +133,19 @@ const savesCount = computed(() => allSaves.value.length);
|
||||
const statesCount = computed(() => allStates.value.length);
|
||||
|
||||
// ---------- Subtab nav definitions ----------
|
||||
type SubtabDef = { id: Subtab; label: string; icon: string };
|
||||
const subtabDefs = computed<SubtabDef[]>(() => [
|
||||
{ id: "saves", label: t("rom.saves-tab"), icon: "mdi-content-save-outline" },
|
||||
{ id: "states", label: t("rom.states-tab"), icon: "mdi-camera-outline" },
|
||||
const subtabDefs = computed<SubtabNavItem<Subtab>[]>(() => [
|
||||
{
|
||||
id: "saves",
|
||||
label: t("rom.saves-tab"),
|
||||
icon: "mdi-content-save-outline",
|
||||
badge: savesCount.value,
|
||||
},
|
||||
{
|
||||
id: "states",
|
||||
label: t("rom.states-tab"),
|
||||
icon: "mdi-camera-outline",
|
||||
badge: statesCount.value,
|
||||
},
|
||||
]);
|
||||
|
||||
// ---------- Upload / refresh plumbing ----------
|
||||
@@ -169,6 +184,19 @@ async function onUploadSubmit({
|
||||
const uploadingSaves = ref(false);
|
||||
const uploadingStates = ref(false);
|
||||
|
||||
// On phones the active subtab's Upload moves from the "Mine" section header
|
||||
// into the subtab picker's row.
|
||||
const pickerRowUpload = computed(() => {
|
||||
if (subTab.value === "saves") {
|
||||
return mySaves.value.length > 0
|
||||
? { type: "save" as const, busy: uploadingSaves.value }
|
||||
: null;
|
||||
}
|
||||
return myStates.value.length > 0
|
||||
? { type: "state" as const, busy: uploadingStates.value }
|
||||
: null;
|
||||
});
|
||||
|
||||
const snackbar = useSnackbar();
|
||||
const confirm = useConfirm();
|
||||
const { refetchRom } = useRomSync();
|
||||
@@ -342,37 +370,29 @@ async function toggleStateVisibility(state: StateSchema) {
|
||||
|
||||
<template>
|
||||
<div class="r-v2-saves">
|
||||
<aside class="r-v2-saves__sidebar">
|
||||
<ul
|
||||
class="r-v2-saves__subtabs"
|
||||
role="tablist"
|
||||
aria-orientation="vertical"
|
||||
>
|
||||
<li v-for="tab in subtabDefs" :key="tab.id" class="r-v2-saves__subtab">
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
class="r-v2-saves__subtab-btn"
|
||||
:class="{
|
||||
'r-v2-saves__subtab-btn--active': subTab === tab.id,
|
||||
}"
|
||||
:aria-selected="subTab === tab.id"
|
||||
@click="subTab = tab.id"
|
||||
>
|
||||
<RIcon :icon="tab.icon" size="16" />
|
||||
<span class="r-v2-saves__subtab-label">{{ tab.label }}</span>
|
||||
<span
|
||||
v-if="
|
||||
(tab.id === 'saves' && savesCount) ||
|
||||
(tab.id === 'states' && statesCount)
|
||||
"
|
||||
class="r-v2-saves__subtab-badge"
|
||||
>
|
||||
{{ tab.id === "saves" ? savesCount : statesCount }}
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<SubtabNav
|
||||
v-if="smAndDown"
|
||||
v-model="subTab"
|
||||
:items="subtabDefs"
|
||||
variant="menu"
|
||||
>
|
||||
<template #actions>
|
||||
<RBtn
|
||||
v-if="pickerRowUpload"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
density="comfortable"
|
||||
prepend-icon="mdi-cloud-upload-outline"
|
||||
:loading="pickerRowUpload.busy"
|
||||
:disabled="pickerRowUpload.busy"
|
||||
@click="openUpload(pickerRowUpload.type)"
|
||||
>
|
||||
{{ t("common.upload") }}
|
||||
</RBtn>
|
||||
</template>
|
||||
</SubtabNav>
|
||||
<aside v-else class="r-v2-saves__sidebar">
|
||||
<SubtabNav v-model="subTab" :items="subtabDefs" />
|
||||
</aside>
|
||||
|
||||
<div class="r-v2-saves__content">
|
||||
@@ -387,7 +407,7 @@ async function toggleStateVisibility(state: StateSchema) {
|
||||
</h3>
|
||||
</div>
|
||||
<RBtn
|
||||
v-if="mySaves.length > 0"
|
||||
v-if="mySaves.length > 0 && !smAndDown"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
prepend-icon="mdi-cloud-upload-outline"
|
||||
@@ -478,7 +498,7 @@ async function toggleStateVisibility(state: StateSchema) {
|
||||
</h3>
|
||||
</div>
|
||||
<RBtn
|
||||
v-if="myStates.length > 0"
|
||||
v-if="myStates.length > 0 && !smAndDown"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
prepend-icon="mdi-cloud-upload-outline"
|
||||
@@ -587,59 +607,6 @@ async function toggleStateVisibility(state: StateSchema) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Subtab list — navigation only. Per-section actions (Upload) live
|
||||
in the content column's section headers, not under the sidebar. */
|
||||
.r-v2-saves__subtabs {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
.r-v2-saves__subtab {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.r-v2-saves__subtab-btn {
|
||||
width: 100%;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border-radius: var(--r-radius-md);
|
||||
color: var(--r-color-fg-muted);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: var(--r-font-weight-medium);
|
||||
transition:
|
||||
background var(--r-motion-fast) var(--r-motion-ease-out),
|
||||
color var(--r-motion-fast) var(--r-motion-ease-out);
|
||||
}
|
||||
.r-v2-saves__subtab-btn:hover {
|
||||
background: var(--r-color-surface-hover);
|
||||
color: var(--r-color-fg);
|
||||
}
|
||||
.r-v2-saves__subtab-btn--active {
|
||||
background: color-mix(in srgb, var(--r-color-brand-primary) 18%, transparent);
|
||||
color: var(--r-color-brand-primary);
|
||||
}
|
||||
.r-v2-saves__subtab-label {
|
||||
flex: 1;
|
||||
}
|
||||
.r-v2-saves__subtab-badge {
|
||||
font-size: 10px;
|
||||
font-weight: var(--r-font-weight-bold);
|
||||
padding: 1px 7px;
|
||||
border-radius: 999px;
|
||||
background: color-mix(in srgb, currentColor 18%, transparent);
|
||||
}
|
||||
|
||||
.r-v2-saves__content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
@@ -677,11 +644,8 @@ async function toggleStateVisibility(state: StateSchema) {
|
||||
color: var(--r-color-fg);
|
||||
}
|
||||
|
||||
html[data-bp~="xs"] .r-v2-saves {
|
||||
html[data-bp~="sm-and-down"] .r-v2-saves {
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
html[data-bp~="xs"] .r-v2-saves__sidebar {
|
||||
width: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
268
frontend/src/v2/components/GameDetails/SubtabNav.vue
Normal file
268
frontend/src/v2/components/GameDetails/SubtabNav.vue
Normal file
@@ -0,0 +1,268 @@
|
||||
<script setup lang="ts" generic="T extends string">
|
||||
// SubtabNav: subtab navigation for the GameDetails tabs that split into
|
||||
// sections. "list" is a rail beside the content; "menu" is a one-row trigger
|
||||
// (plus the `actions` slot) opening the list as a bottom sheet on phones.
|
||||
import { RBtn, RDivider, RIcon, RMenu, RMenuItem } from "@v2/lib";
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { shouldAutofocusSearch } from "@/v2/utils/autofocus";
|
||||
|
||||
export interface SubtabNavItem<Id extends string = string> {
|
||||
id: Id;
|
||||
label: string;
|
||||
/** Leave unset when every item would carry the same glyph. */
|
||||
icon?: string;
|
||||
/** Count shown after the label; hidden when zero or unset. */
|
||||
badge?: number;
|
||||
/** Heading the item is listed under; keep grouped items adjacent. */
|
||||
group?: string;
|
||||
}
|
||||
|
||||
// Past this many subtabs the sheet gets a filter field.
|
||||
const SEARCH_THRESHOLD = 8;
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue: T;
|
||||
items: SubtabNavItem<T>[];
|
||||
variant?: "list" | "menu";
|
||||
}>(),
|
||||
{ variant: "list" },
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "update:modelValue", value: T): void;
|
||||
}>();
|
||||
|
||||
const slots = defineSlots<{
|
||||
actions?: () => unknown;
|
||||
"item-append"?: (scope: { item: SubtabNavItem<T> }) => unknown;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const active = computed(
|
||||
() => props.items.find((item) => item.id === props.modelValue) ?? null,
|
||||
);
|
||||
|
||||
const menuOpen = ref(false);
|
||||
const search = ref("");
|
||||
const searchable = computed(() => props.items.length > SEARCH_THRESHOLD);
|
||||
|
||||
const menuItems = computed(() => {
|
||||
const query = search.value.trim().toLowerCase();
|
||||
if (!query) return props.items;
|
||||
return props.items.filter((item) => item.label.toLowerCase().includes(query));
|
||||
});
|
||||
|
||||
watch(menuOpen, (open) => {
|
||||
if (!open) search.value = "";
|
||||
});
|
||||
|
||||
function startsGroup(list: SubtabNavItem<T>[], index: number): boolean {
|
||||
const group = list[index].group;
|
||||
return !!group && group !== list[index - 1]?.group;
|
||||
}
|
||||
|
||||
function select(id: T) {
|
||||
if (id !== props.modelValue) emit("update:modelValue", id);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ul
|
||||
v-if="variant === 'list'"
|
||||
class="r-v2-subtab-nav"
|
||||
role="tablist"
|
||||
aria-orientation="vertical"
|
||||
>
|
||||
<template v-for="(item, index) in items" :key="item.id">
|
||||
<li
|
||||
v-if="startsGroup(items, index)"
|
||||
role="presentation"
|
||||
class="r-v2-subtab-nav__group"
|
||||
>
|
||||
{{ item.group }}
|
||||
</li>
|
||||
<li role="presentation" class="r-v2-subtab-nav__item">
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
class="r-v2-subtab-nav__btn"
|
||||
:class="{ 'r-v2-subtab-nav__btn--active': item.id === modelValue }"
|
||||
:aria-selected="item.id === modelValue"
|
||||
@click="select(item.id)"
|
||||
>
|
||||
<RIcon v-if="item.icon" :icon="item.icon" size="16" />
|
||||
<span class="r-v2-subtab-nav__label">{{ item.label }}</span>
|
||||
<slot name="item-append" :item="item" />
|
||||
<span v-if="item.badge" class="r-v2-subtab-nav__badge">
|
||||
{{ item.badge }}
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
</template>
|
||||
</ul>
|
||||
|
||||
<!-- Wrapped so call-site classes land on the row rather than on RMenu's
|
||||
teleported panel. -->
|
||||
<div v-else class="r-v2-subtab-nav-menu">
|
||||
<RMenu
|
||||
v-model="menuOpen"
|
||||
v-model:search="search"
|
||||
location="bottom start"
|
||||
:offset="6"
|
||||
sheet-on-mobile
|
||||
:searchable="searchable"
|
||||
:search-placeholder="t('common.search')"
|
||||
:search-auto-focus="shouldAutofocusSearch()"
|
||||
>
|
||||
<template #activator="{ props: activatorProps }">
|
||||
<RBtn
|
||||
v-bind="activatorProps"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
density="comfortable"
|
||||
block
|
||||
:prepend-icon="active?.icon"
|
||||
append-icon="mdi-menu-down"
|
||||
class="r-v2-subtab-nav__trigger"
|
||||
>
|
||||
<span class="r-v2-subtab-nav__label">{{ active?.label }}</span>
|
||||
<span v-if="active?.badge" class="r-v2-subtab-nav__badge">
|
||||
{{ active.badge }}
|
||||
</span>
|
||||
</RBtn>
|
||||
</template>
|
||||
|
||||
<template v-for="(item, index) in menuItems" :key="item.id">
|
||||
<template v-if="startsGroup(menuItems, index)">
|
||||
<RDivider v-if="index > 0" />
|
||||
<div class="r-v2-subtab-nav__group" data-r-menu-no-close>
|
||||
{{ item.group }}
|
||||
</div>
|
||||
</template>
|
||||
<RMenuItem
|
||||
:icon="item.icon"
|
||||
:label="item.label"
|
||||
:variant="item.id === modelValue ? 'active' : 'default'"
|
||||
:class="{ 'r-v2-subtab-nav__option--bare': !item.icon }"
|
||||
@click="select(item.id)"
|
||||
>
|
||||
<template v-if="item.badge || slots['item-append']" #append>
|
||||
<slot name="item-append" :item="item" />
|
||||
<span v-if="item.badge" class="r-v2-subtab-nav__badge">
|
||||
{{ item.badge }}
|
||||
</span>
|
||||
</template>
|
||||
</RMenuItem>
|
||||
</template>
|
||||
</RMenu>
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* ---------- List ----------
|
||||
Scrolls on its own when a parent caps its height (FilesTab's folder rail),
|
||||
so a ROM with many folders keeps every subtab reachable. */
|
||||
.r-v2-subtab-nav {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0 4px 4px 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--r-color-border-strong) transparent;
|
||||
}
|
||||
.r-v2-subtab-nav::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
.r-v2-subtab-nav::-webkit-scrollbar-thumb {
|
||||
background: var(--r-color-border-strong);
|
||||
border-radius: 2px;
|
||||
}
|
||||
.r-v2-subtab-nav__group {
|
||||
padding: 8px 12px 4px;
|
||||
font-size: var(--r-font-size-xs);
|
||||
font-weight: var(--r-font-weight-bold);
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--r-color-fg-muted);
|
||||
}
|
||||
.r-v2-subtab-nav__item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.r-v2-subtab-nav__btn {
|
||||
width: 100%;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border-radius: var(--r-radius-md);
|
||||
color: var(--r-color-fg-muted);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: var(--r-font-weight-medium);
|
||||
transition:
|
||||
background var(--r-motion-fast) var(--r-motion-ease-out),
|
||||
color var(--r-motion-fast) var(--r-motion-ease-out);
|
||||
}
|
||||
.r-v2-subtab-nav__btn:hover {
|
||||
background: var(--r-color-surface-hover);
|
||||
color: var(--r-color-fg);
|
||||
}
|
||||
.r-v2-subtab-nav__btn--active {
|
||||
background: color-mix(in srgb, var(--r-color-brand-primary) 18%, transparent);
|
||||
color: var(--r-color-brand-primary);
|
||||
}
|
||||
.r-v2-subtab-nav__label {
|
||||
flex: 1;
|
||||
}
|
||||
.r-v2-subtab-nav__badge {
|
||||
font-size: 10px;
|
||||
font-weight: var(--r-font-weight-bold);
|
||||
padding: 1px 7px;
|
||||
border-radius: var(--r-radius-full);
|
||||
background: color-mix(in srgb, currentColor 18%, transparent);
|
||||
}
|
||||
|
||||
/* RMenuItem keeps an icon cell even when empty; drop it so icon-less rows
|
||||
line up with their group heading. */
|
||||
.r-v2-subtab-nav__option--bare :deep(.r-menu-item__icon) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ---------- Menu trigger ----------
|
||||
Reads as a select: active subtab on the left, chevron pinned right. */
|
||||
.r-v2-subtab-nav-menu {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
}
|
||||
.r-v2-subtab-nav__trigger {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.r-v2-subtab-nav__trigger :deep(.r-btn__content),
|
||||
.r-v2-subtab-nav__trigger :deep(.r-btn__label) {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.r-v2-subtab-nav__trigger .r-v2-subtab-nav__label {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
@@ -46,7 +46,12 @@ type WalkthroughEntry = {
|
||||
kind: ViewerKind;
|
||||
};
|
||||
|
||||
const props = defineProps<{ rom: DetailedRom }>();
|
||||
const props = defineProps<{
|
||||
rom: DetailedRom;
|
||||
/** Drop the Upload button when the parent renders it elsewhere (through
|
||||
* the exposed `openUpload`). */
|
||||
hideUpload?: boolean;
|
||||
}>();
|
||||
const snackbar = useSnackbar();
|
||||
const confirm = useConfirm();
|
||||
const { refetchRom } = useRomSync();
|
||||
@@ -127,6 +132,12 @@ async function confirmFolderConversionIfNeeded(): Promise<boolean> {
|
||||
|
||||
// ---------- Upload ----------
|
||||
const walkthroughDz = ref<InstanceType<typeof RDropzone> | null>(null);
|
||||
const canUpload = computed(() => entries.value.length > 0 && canEdit.value);
|
||||
|
||||
defineExpose({
|
||||
canUpload,
|
||||
openUpload: () => walkthroughDz.value?.open(),
|
||||
});
|
||||
|
||||
async function handleFiles(files: File[]) {
|
||||
await uploadFiles(props.rom, ROM_UPLOAD_FOLDERS.walkthrough, files);
|
||||
@@ -199,6 +210,7 @@ async function requestDelete() {
|
||||
<div v-if="canEdit" class="r-v2-wt__url">
|
||||
<RTextField
|
||||
v-model="gamefaqsUrl"
|
||||
class="r-v2-wt__url-field"
|
||||
:placeholder="t('rom.walkthrough-url-label')"
|
||||
density="compact"
|
||||
variant="outlined"
|
||||
@@ -273,7 +285,7 @@ async function requestDelete() {
|
||||
</div>
|
||||
</RDropzone>
|
||||
|
||||
<div v-if="entries.length > 0 && canEdit">
|
||||
<div v-if="canUpload && !hideUpload">
|
||||
<RBtn
|
||||
block
|
||||
variant="outlined"
|
||||
@@ -324,6 +336,21 @@ async function requestDelete() {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
/* Phones: the entry picker and the URL form each take a full row, with the
|
||||
field shrinking so the "add from URL" button never pushes past the edge. */
|
||||
html[data-bp~="sm-and-down"] .r-v2-wt__spacer {
|
||||
display: none;
|
||||
}
|
||||
html[data-bp~="sm-and-down"] .r-v2-wt__select,
|
||||
html[data-bp~="sm-and-down"] .r-v2-wt__url {
|
||||
flex: 1 1 100%;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
}
|
||||
html[data-bp~="sm-and-down"] .r-v2-wt__url-field {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.r-v2-wt__viewer {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
|
||||
Reference in New Issue
Block a user