feat(ui): My QBZ collapsible nav wrapper with Mixtapes and Collections children

Adds a top-level collapsible nav section "My QBZ" in the sidebar
containing two children — Mixtapes and Collections — that route to
"Coming soon" placeholder views until the full views land in Phase 5.

The parent's display is user-customizable:
- Label (default "My QBZ") via right-click -> Rename
- Icon (default /static/my-qbz.svg) via right-click -> Change icon,
  which opens a native file dialog; selected path is stored as an
  absolute filesystem path, rendered through convertFileSrc() at
  display time.

Both preferences are per-user localStorage via the existing
userStorage.ts wrapper. Collapsed/expanded state also persists.
reloadMyQbzNav() is invoked post-login alongside the other per-user
store resync calls.

No command or internal identifier changes — the nav children identify
as 'mixtapes' / 'collections' in currentView, matching what the
Phase 5 views will expect.

cc
This commit is contained in:
vicrodh committed 2026-04-18 19:57:35 -06:00
1 parent 17e2f711e3
commit 8466a61967
5 files changed
+502 -2

No files matched your search

+183
View File
@@ -0,0 +1,183 @@
<script lang="ts">
import { convertFileSrc } from '@tauri-apps/api/core';
import { open as openDialog } from '@tauri-apps/plugin-dialog';
import {
myQbzNavStore,
setMyQbzLabel,
setMyQbzIconPath,
DEFAULT_ICON,
} from '$lib/stores/myQbzNavStore';
interface Props {
open: boolean;
onClose: () => void;
}
let { open, onClose }: Props = $props();
let draftLabel = $state('');
let draftIconPath = $state<string>('');
// Initialize drafts when opened
$effect(() => {
if (open) {
const state = $myQbzNavStore;
draftLabel = state.label;
draftIconPath = state.iconPath;
}
});
const iconSrc = $derived(
draftIconPath && draftIconPath !== DEFAULT_ICON
? convertFileSrc(draftIconPath)
: DEFAULT_ICON
);
async function pickIcon() {
try {
const selected = await openDialog({
filters: [{ name: 'Image', extensions: ['svg', 'png', 'jpg', 'jpeg', 'webp'] }],
multiple: false,
directory: false,
});
if (typeof selected === 'string') {
draftIconPath = selected;
}
} catch (err) {
console.error('[MyQbzNavEditModal] icon picker failed:', err);
}
}
function resetIcon() {
draftIconPath = DEFAULT_ICON;
}
function save() {
setMyQbzLabel(draftLabel);
setMyQbzIconPath(draftIconPath === DEFAULT_ICON ? null : draftIconPath);
onClose();
}
function cancel() {
onClose();
}
</script>
{#if open}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div class="modal-backdrop" onclick={cancel} role="presentation">
<!-- svelte-ignore a11y_interactive_supports_focus -->
<div
class="modal"
role="dialog"
aria-label="Customize My QBZ nav"
onclick={(e) => e.stopPropagation()}
>
<h2>Customize</h2>
<label class="field">
<span class="label-text">Name</span>
<input type="text" bind:value={draftLabel} maxlength="40" />
</label>
<div class="field">
<span class="label-text">Icon</span>
<div class="icon-row">
<img class="icon-preview" src={iconSrc} alt="" />
<button class="btn-secondary" onclick={pickIcon}>Choose file…</button>
<button class="btn-secondary" onclick={resetIcon}>Reset to default</button>
</div>
</div>
<div class="footer">
<button class="btn-secondary" onclick={cancel}>Cancel</button>
<button class="btn-primary" onclick={save}>Save</button>
</div>
</div>
</div>
{/if}
<style>
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.6);
display: grid;
place-items: center;
z-index: 9999;
}
.modal {
background: var(--bg-primary);
border: 1px solid var(--bg-tertiary);
border-radius: 12px;
padding: 24px;
width: 420px;
max-width: 90vw;
color: var(--text-primary);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
h2 { margin: 0 0 16px; font-size: 18px; font-weight: 700; }
.field { display: block; margin-bottom: 16px; }
.label-text {
display: block;
font-size: 11px;
font-weight: 600;
letter-spacing: 1.5px;
text-transform: uppercase;
color: var(--text-muted);
margin-bottom: 8px;
}
input[type="text"] {
width: 100%;
padding: 10px 12px;
background: var(--bg-secondary);
color: var(--text-primary);
border: 1px solid var(--bg-tertiary);
border-radius: 8px;
font-size: 14px;
font-family: inherit;
box-sizing: border-box;
}
.icon-row {
display: flex;
align-items: center;
gap: 12px;
}
.icon-preview {
width: 40px;
height: 40px;
border: 1px solid var(--bg-tertiary);
border-radius: 8px;
background: var(--bg-secondary);
padding: 6px;
object-fit: contain;
flex-shrink: 0;
}
.btn-secondary, .btn-primary {
padding: 8px 16px;
border-radius: 8px;
border: 1px solid var(--bg-tertiary);
font-size: 13px;
font-weight: 600;
font-family: inherit;
cursor: pointer;
}
.btn-secondary {
background: var(--bg-secondary);
color: var(--text-primary);
}
.btn-secondary:hover {
background: var(--bg-hover);
}
.btn-primary {
background: var(--accent-primary);
color: #ffffff;
border-color: var(--accent-primary);
margin-left: 8px;
}
.footer {
display: flex;
justify-content: flex-end;
margin-top: 24px;
}
</style>
+222 -1
View File
@@ -2,10 +2,16 @@
import { tick } from 'svelte'; import { tick } from 'svelte';
import { Search, HardDrive, Plus, RefreshCw, ChevronDown, ChevronUp, Heart, ListMusic, Import, Settings, Ellipsis, ArrowUpDown, ChevronRight, ChevronLeft, Folder, FolderPlus, X, User, Disc, Disc3, Music, ShoppingBag, Eye, EyeOff, Pencil } from 'lucide-svelte'; import { Search, HardDrive, Plus, RefreshCw, ChevronDown, ChevronUp, Heart, ListMusic, Import, Settings, Ellipsis, ArrowUpDown, ChevronRight, ChevronLeft, Folder, FolderPlus, X, User, Disc, Disc3, Music, ShoppingBag, Eye, EyeOff, Pencil } from 'lucide-svelte';
import type { FavoritesPreferences } from '$lib/types'; import type { FavoritesPreferences } from '$lib/types';
import { invoke } from '@tauri-apps/api/core'; import { invoke, convertFileSrc } from '@tauri-apps/api/core';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import NavigationItem from './NavigationItem.svelte'; import NavigationItem from './NavigationItem.svelte';
import UserCard from './UserCard.svelte'; import UserCard from './UserCard.svelte';
import MyQbzNavEditModal from './MyQbzNavEditModal.svelte';
import {
myQbzNavStore,
setMyQbzExpanded,
DEFAULT_ICON,
} from '$lib/stores/myQbzNavStore';
import { t } from '$lib/i18n'; import { t } from '$lib/i18n';
import { import {
getSearchQuery, getSearchQuery,
@@ -139,6 +145,14 @@
let showFavoritesMenu = $state(false); let showFavoritesMenu = $state(false);
let favoritesMenuPos = $state({ x: 0, y: 0 }); let favoritesMenuPos = $state({ x: 0, y: 0 });
// My QBZ nav state
let editMyQbzOpen = $state(false);
let myQbzContextMenu = $state<{ x: number; y: number } | null>(null);
function closeMyQbzContextMenu() {
myQbzContextMenu = null;
}
// Sidebar search state - synced with SearchView // Sidebar search state - synced with SearchView
let sidebarSearchQuery = $state(getSearchQuery()); let sidebarSearchQuery = $state(getSearchQuery());
let sidebarSearchInput = $state<HTMLInputElement | null>(null); let sidebarSearchInput = $state<HTMLInputElement | null>(null);
@@ -1649,6 +1663,89 @@
</nav> </nav>
{/if} {/if}
<!-- My QBZ collapsible section -->
{#if isExpanded}
<nav class="nav-section my-qbz-section">
<!-- Parent row: click toggles expand, right-click opens context menu -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<div
class="my-qbz-parent"
class:active={activeView === 'mixtapes' || activeView === 'collections'}
onclick={() => setMyQbzExpanded(!$myQbzNavStore.expanded)}
oncontextmenu={(e) => {
e.preventDefault();
myQbzContextMenu = { x: e.clientX, y: e.clientY };
}}
>
<div class="icon-container">
<img
class="my-qbz-icon"
src={$myQbzNavStore.iconPath === DEFAULT_ICON
? DEFAULT_ICON
: convertFileSrc($myQbzNavStore.iconPath)}
alt=""
/>
</div>
<span class="label">{$myQbzNavStore.label}</span>
<span class="my-qbz-chevron" class:expanded={$myQbzNavStore.expanded}>
<ChevronRight size={12} />
</span>
</div>
{#if $myQbzNavStore.expanded}
<div class="my-qbz-children">
<NavigationItem
label={$t('mixtapes.nav')}
active={activeView === 'mixtapes'}
onclick={() => handleViewChange('mixtapes')}
showLabel={true}
indented={true}
>
{#snippet icon()}<img class="my-qbz-child-icon" src="/cassette.svg" alt="" />{/snippet}
</NavigationItem>
<NavigationItem
label={$t('collections.nav')}
active={activeView === 'collections'}
onclick={() => handleViewChange('collections')}
showLabel={true}
indented={true}
>
{#snippet icon()}<img class="my-qbz-child-icon" src="/collection.svg" alt="" />{/snippet}
</NavigationItem>
</div>
{/if}
</nav>
{#if myQbzContextMenu}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<div
class="my-qbz-context-backdrop"
role="presentation"
onclick={closeMyQbzContextMenu}
></div>
<div
class="my-qbz-context-menu"
style:left="{myQbzContextMenu.x}px"
style:top="{myQbzContextMenu.y}px"
>
<button
class="my-qbz-context-item"
onclick={() => { editMyQbzOpen = true; closeMyQbzContextMenu(); }}
>
<Pencil size={14} />
<span>Rename / Change icon…</span>
</button>
</div>
{/if}
<MyQbzNavEditModal
open={editMyQbzOpen}
onClose={() => (editMyQbzOpen = false)}
/>
{/if}
<!-- Playlists Section (hidden in offline mode) --> <!-- Playlists Section (hidden in offline mode) -->
{#if !isOffline} {#if !isOffline}
<div class="section playlists-section"> <div class="section playlists-section">
@@ -3135,4 +3232,128 @@
background: var(--border-subtle); background: var(--border-subtle);
margin: 6px 0; margin: 6px 0;
} }
/* My QBZ collapsible nav section */
.my-qbz-section {
margin-top: 2px;
}
.my-qbz-parent {
position: relative;
width: 100%;
height: 32px;
display: flex;
align-items: center;
gap: 8px;
padding: 0 8px;
border-radius: 6px;
background: transparent;
color: var(--text-muted);
cursor: pointer;
transition: color 150ms ease, background-color 150ms ease;
user-select: none;
}
.my-qbz-parent:hover {
background-color: var(--bg-hover);
}
.my-qbz-parent.active {
background-color: var(--bg-tertiary);
color: var(--text-primary);
}
.my-qbz-parent .icon-container {
width: 14px;
height: 14px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.my-qbz-parent .label {
font-size: 13px;
font-weight: 400;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
min-width: 0;
}
.my-qbz-icon {
width: 14px;
height: 14px;
object-fit: contain;
opacity: 0.75;
filter: var(--icon-filter, none);
}
.my-qbz-parent:hover .my-qbz-icon,
.my-qbz-parent.active .my-qbz-icon {
opacity: 1;
}
.my-qbz-child-icon {
width: 14px;
height: 14px;
object-fit: contain;
opacity: 0.75;
filter: var(--icon-filter, none);
}
.my-qbz-chevron {
display: flex;
align-items: center;
justify-content: center;
transition: transform 150ms ease;
flex-shrink: 0;
}
.my-qbz-chevron.expanded {
transform: rotate(90deg);
}
.my-qbz-children {
display: flex;
flex-direction: column;
}
/* Context menu */
.my-qbz-context-backdrop {
position: fixed;
inset: 0;
z-index: 9998;
}
.my-qbz-context-menu {
position: fixed;
background: var(--bg-primary);
border: 1px solid var(--bg-tertiary);
border-radius: 8px;
padding: 4px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
z-index: 9999;
}
.my-qbz-context-item {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
background: transparent;
border: none;
color: var(--text-primary);
font-size: 13px;
font-family: inherit;
cursor: pointer;
width: 100%;
text-align: left;
border-radius: 6px;
}
.my-qbz-context-item:hover {
background: var(--bg-hover);
}
</style> </style>
+57
View File
@@ -0,0 +1,57 @@
import { writable } from 'svelte/store';
import { getUserItem, setUserItem, removeUserItem } from '$lib/utils/userStorage';
const DEFAULT_LABEL = 'My QBZ';
const DEFAULT_ICON = '/my-qbz.svg'; // served from /static
const LABEL_KEY = 'qbz-my-qbz-label';
const ICON_KEY = 'qbz-my-qbz-icon-path';
const EXPANDED_KEY = 'qbz-my-qbz-expanded';
export interface MyQbzNavState {
label: string;
/** Either an absolute filesystem path (user-chosen) or '/my-qbz.svg' for default */
iconPath: string;
/** Whether the collapsible section is expanded in the sidebar */
expanded: boolean;
}
function loadInitial(): MyQbzNavState {
const savedLabel = getUserItem(LABEL_KEY);
const savedIcon = getUserItem(ICON_KEY);
const savedExpanded = getUserItem(EXPANDED_KEY);
return {
label: savedLabel || DEFAULT_LABEL,
iconPath: savedIcon || DEFAULT_ICON,
expanded: savedExpanded === null ? true : savedExpanded === 'true',
};
}
export const myQbzNavStore = writable<MyQbzNavState>(loadInitial());
export function setMyQbzLabel(label: string): void {
const trimmed = label.trim();
const next = trimmed === '' ? DEFAULT_LABEL : trimmed;
setUserItem(LABEL_KEY, next);
myQbzNavStore.update((state) => ({ ...state, label: next }));
}
export function setMyQbzIconPath(iconPath: string | null): void {
if (iconPath === null || iconPath.trim() === '') {
removeUserItem(ICON_KEY);
myQbzNavStore.update((state) => ({ ...state, iconPath: DEFAULT_ICON }));
return;
}
setUserItem(ICON_KEY, iconPath);
myQbzNavStore.update((state) => ({ ...state, iconPath }));
}
export function setMyQbzExpanded(expanded: boolean): void {
setUserItem(EXPANDED_KEY, String(expanded));
myQbzNavStore.update((state) => ({ ...state, expanded }));
}
export function reloadMyQbzNav(): void {
myQbzNavStore.set(loadInitial());
}
export { DEFAULT_LABEL, DEFAULT_ICON };
+3 -1
View File
@@ -41,7 +41,9 @@ export type ViewType =
| 'weeklyq' | 'weeklyq'
| 'favq' | 'favq'
| 'topq' | 'topq'
| 'artists-by-location'; | 'artists-by-location'
| 'mixtapes'
| 'collections';
export type FavoritesTab = 'tracks' | 'albums' | 'artists' | 'labels' | 'playlists'; export type FavoritesTab = 'tracks' | 'albums' | 'artists' | 'labels' | 'playlists';
// History entry: view + optional item identifier for granular back/forward // History entry: view + optional item identifier for granular back/forward
+37
View File
@@ -464,6 +464,7 @@
import CastPicker from '$lib/components/CastPicker.svelte'; import CastPicker from '$lib/components/CastPicker.svelte';
import LyricsSidebar from '$lib/components/lyrics/LyricsSidebar.svelte'; import LyricsSidebar from '$lib/components/lyrics/LyricsSidebar.svelte';
import { reloadLyricsDisplay } from '$lib/stores/lyricsDisplayStore'; import { reloadLyricsDisplay } from '$lib/stores/lyricsDisplayStore';
import { reloadMyQbzNav } from '$lib/stores/myQbzNavStore';
import OfflinePlaceholder from '$lib/components/OfflinePlaceholder.svelte'; import OfflinePlaceholder from '$lib/components/OfflinePlaceholder.svelte';
import UpdateAvailableModal from '$lib/components/updates/UpdateAvailableModal.svelte'; import UpdateAvailableModal from '$lib/components/updates/UpdateAvailableModal.svelte';
import UpdateReminderModal from '$lib/components/updates/UpdateReminderModal.svelte'; import UpdateReminderModal from '$lib/components/updates/UpdateReminderModal.svelte';
@@ -3585,6 +3586,7 @@
// Re-sync volume from the now-correct user-scoped localStorage key // Re-sync volume from the now-correct user-scoped localStorage key
await resyncPersistedVolume(); await resyncPersistedVolume();
reloadLyricsDisplay(); reloadLyricsDisplay();
reloadMyQbzNav();
// Signal that per-user backend stores are ready — the launch update // Signal that per-user backend stores are ready — the launch update
// flow $effect gates on this to avoid reading default preferences // flow $effect gates on this to avoid reading default preferences
@@ -5882,6 +5884,16 @@
onAlbumClick={handleAlbumClick} onAlbumClick={handleAlbumClick}
onAlbumPlay={playAlbumById} onAlbumPlay={playAlbumById}
/> />
{:else if activeView === 'mixtapes'}
<div class="coming-soon">
<h1>{$t('mixtapes.nav')}</h1>
<p>Coming soon</p>
</div>
{:else if activeView === 'collections'}
<div class="coming-soon">
<h1>{$t('collections.nav')}</h1>
<p>Coming soon</p>
</div>
{:else} {:else}
<!-- Catch-all fallback: view has no matching data, show loading/error --> <!-- Catch-all fallback: view has no matching data, show loading/error -->
<div class="view-error"> <div class="view-error">
@@ -6409,6 +6421,31 @@
background: var(--bg-hover); background: var(--bg-hover);
} }
/* Coming soon placeholder for Mixtapes/Collections */
.coming-soon {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
height: 100%;
color: var(--text-muted);
padding: 40px;
text-align: center;
}
.coming-soon h1 {
font-size: 22px;
font-weight: 700;
color: var(--text-primary);
margin: 0;
}
.coming-soon p {
font-size: 14px;
margin: 0;
}
/* Global back-to-top button */ /* Global back-to-top button */
.back-to-top-global { .back-to-top-global {
position: fixed; position: fixed;