diff --git a/src/lib/components/MyQbzNavEditModal.svelte b/src/lib/components/MyQbzNavEditModal.svelte new file mode 100644 index 000000000..54335169b --- /dev/null +++ b/src/lib/components/MyQbzNavEditModal.svelte @@ -0,0 +1,183 @@ + + +{#if open} + + + +{/if} + + diff --git a/src/lib/components/Sidebar.svelte b/src/lib/components/Sidebar.svelte index 31cd13979..536ea08c1 100644 --- a/src/lib/components/Sidebar.svelte +++ b/src/lib/components/Sidebar.svelte @@ -2,10 +2,16 @@ 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 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 NavigationItem from './NavigationItem.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 { getSearchQuery, @@ -139,6 +145,14 @@ let showFavoritesMenu = $state(false); 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 let sidebarSearchQuery = $state(getSearchQuery()); let sidebarSearchInput = $state(null); @@ -1649,6 +1663,89 @@ {/if} + + {#if isExpanded} + + + {#if myQbzContextMenu} + + + +
+ +
+ {/if} + + (editMyQbzOpen = false)} + /> + {/if} + {#if !isOffline}
@@ -3135,4 +3232,128 @@ background: var(--border-subtle); 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); + } diff --git a/src/lib/stores/myQbzNavStore.ts b/src/lib/stores/myQbzNavStore.ts new file mode 100644 index 000000000..1cd6107d9 --- /dev/null +++ b/src/lib/stores/myQbzNavStore.ts @@ -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(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 }; diff --git a/src/lib/stores/navigationStore.ts b/src/lib/stores/navigationStore.ts index 2de412632..d9cc080a8 100644 --- a/src/lib/stores/navigationStore.ts +++ b/src/lib/stores/navigationStore.ts @@ -41,7 +41,9 @@ export type ViewType = | 'weeklyq' | 'favq' | 'topq' - | 'artists-by-location'; + | 'artists-by-location' + | 'mixtapes' + | 'collections'; export type FavoritesTab = 'tracks' | 'albums' | 'artists' | 'labels' | 'playlists'; // History entry: view + optional item identifier for granular back/forward diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 2efdd641b..c20f45cd0 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -464,6 +464,7 @@ import CastPicker from '$lib/components/CastPicker.svelte'; import LyricsSidebar from '$lib/components/lyrics/LyricsSidebar.svelte'; import { reloadLyricsDisplay } from '$lib/stores/lyricsDisplayStore'; + import { reloadMyQbzNav } from '$lib/stores/myQbzNavStore'; import OfflinePlaceholder from '$lib/components/OfflinePlaceholder.svelte'; import UpdateAvailableModal from '$lib/components/updates/UpdateAvailableModal.svelte'; import UpdateReminderModal from '$lib/components/updates/UpdateReminderModal.svelte'; @@ -3585,6 +3586,7 @@ // Re-sync volume from the now-correct user-scoped localStorage key await resyncPersistedVolume(); reloadLyricsDisplay(); + reloadMyQbzNav(); // Signal that per-user backend stores are ready — the launch update // flow $effect gates on this to avoid reading default preferences @@ -5882,6 +5884,16 @@ onAlbumClick={handleAlbumClick} onAlbumPlay={playAlbumById} /> + {:else if activeView === 'mixtapes'} +
+

{$t('mixtapes.nav')}

+

Coming soon

+
+ {:else if activeView === 'collections'} +
+

{$t('collections.nav')}

+

Coming soon

+
{:else}
@@ -6409,6 +6421,31 @@ 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 */ .back-to-top-global { position: fixed;