Implement sticky navigation bar with integrated search in LocalLibraryView
- Changed tab buttons to text links with underline style (matching ArtistDetailView) - Made navigation bar sticky with proper z-index and negative margin - Integrated track search into sticky nav bar (closed by default) - Search opens with toggle button, closes with X or Escape key - Removed duplicate search input from tracks section - Added slideInFromRight animation for search appearance Navigation now: - Sticks to top when scrolling (position: sticky; top: 0; z-index: 4) - Uses minimal text links instead of button-style tabs - Active tab shown with accent-colored underline - Track search accessible from any tab via sticky nav
This commit is contained in:
1 parent
5b0fb1a72d
commit
f48d857e0f
1 file changed
+186
-67
@@ -166,6 +166,8 @@
|
|||||||
let showGroupMenu = $state(false);
|
let showGroupMenu = $state(false);
|
||||||
let artistSearch = $state('');
|
let artistSearch = $state('');
|
||||||
let trackSearch = $state('');
|
let trackSearch = $state('');
|
||||||
|
let trackSearchOpen = $state(false);
|
||||||
|
let trackSearchInputEl: HTMLInputElement | undefined;
|
||||||
type TrackGroupMode = 'album' | 'artist' | 'name';
|
type TrackGroupMode = 'album' | 'artist' | 'name';
|
||||||
let trackGroupMode = $state<TrackGroupMode>('album');
|
let trackGroupMode = $state<TrackGroupMode>('album');
|
||||||
let trackGroupingEnabled = $state(false);
|
let trackGroupingEnabled = $state(false);
|
||||||
@@ -1267,6 +1269,20 @@
|
|||||||
}, 250);
|
}, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleTrackSearch() {
|
||||||
|
trackSearchOpen = !trackSearchOpen;
|
||||||
|
if (trackSearchOpen) {
|
||||||
|
// Focus input after it's rendered
|
||||||
|
setTimeout(() => trackSearchInputEl?.focus(), 50);
|
||||||
|
} else {
|
||||||
|
// Clear search when closing
|
||||||
|
trackSearch = '';
|
||||||
|
if (activeTab === 'tracks') {
|
||||||
|
loadTracks('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function trackSortValue(track: LocalTrack) {
|
function trackSortValue(track: LocalTrack) {
|
||||||
const disc = track.disc_number ?? 0;
|
const disc = track.disc_number ?? 0;
|
||||||
const trackNumber = track.track_number ?? 0;
|
const trackNumber = track.track_number ?? 0;
|
||||||
@@ -1867,35 +1883,59 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<!-- Tabs -->
|
<!-- Tabs Navigation -->
|
||||||
<div class="tabs">
|
<div class="jump-nav">
|
||||||
<button
|
<div class="jump-nav-left">
|
||||||
class="tab"
|
<div class="jump-links">
|
||||||
class:active={activeTab === 'albums'}
|
<button
|
||||||
onclick={() => handleTabChange('albums')}
|
class="jump-link"
|
||||||
>
|
class:active={activeTab === 'albums'}
|
||||||
<Disc3 size={16} />
|
onclick={() => handleTabChange('albums')}
|
||||||
<span>Albums</span>
|
>
|
||||||
<span class="count">({filteredAlbumCount})</span>
|
Albums ({filteredAlbumCount})
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="tab"
|
class="jump-link"
|
||||||
class:active={activeTab === 'artists'}
|
class:active={activeTab === 'artists'}
|
||||||
onclick={() => handleTabChange('artists')}
|
onclick={() => handleTabChange('artists')}
|
||||||
>
|
>
|
||||||
<Mic2 size={16} />
|
Artists ({filteredArtistCount})
|
||||||
<span>Artists</span>
|
</button>
|
||||||
<span class="count">({filteredArtistCount})</span>
|
<button
|
||||||
</button>
|
class="jump-link"
|
||||||
<button
|
class:active={activeTab === 'tracks'}
|
||||||
class="tab"
|
onclick={() => handleTabChange('tracks')}
|
||||||
class:active={activeTab === 'tracks'}
|
>
|
||||||
onclick={() => handleTabChange('tracks')}
|
Tracks ({filteredTrackCount})
|
||||||
>
|
</button>
|
||||||
<Music size={16} />
|
</div>
|
||||||
<span>Tracks</span>
|
</div>
|
||||||
<span class="count">({filteredTrackCount})</span>
|
<div class="page-search" class:open={trackSearchOpen}>
|
||||||
</button>
|
{#if trackSearchOpen}
|
||||||
|
<div class="search-input-container">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="search-input-sticky"
|
||||||
|
placeholder="Search tracks..."
|
||||||
|
bind:value={trackSearch}
|
||||||
|
bind:this={trackSearchInputEl}
|
||||||
|
oninput={scheduleTrackSearch}
|
||||||
|
onkeydown={(e) => {
|
||||||
|
if (e.key === 'Escape') toggleTrackSearch();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div class="search-controls">
|
||||||
|
<button class="search-close-btn" onclick={toggleTrackSearch} title="Close search">
|
||||||
|
<X size={16} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<button class="search-toggle" onclick={toggleTrackSearch} title="Search tracks">
|
||||||
|
<Search size={18} />
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
@@ -2209,22 +2249,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="track-controls">
|
<div class="track-controls">
|
||||||
<div class="search-container">
|
|
||||||
<Search size={16} class="search-icon" />
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="Search tracks, albums, artists..."
|
|
||||||
bind:value={trackSearch}
|
|
||||||
oninput={scheduleTrackSearch}
|
|
||||||
class="search-input"
|
|
||||||
/>
|
|
||||||
{#if trackSearch}
|
|
||||||
<button class="clear-search" onclick={() => { trackSearch = ''; loadTracks(''); }}>
|
|
||||||
<X size={14} />
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="dropdown-container">
|
<div class="dropdown-container">
|
||||||
<button
|
<button
|
||||||
class="control-btn"
|
class="control-btn"
|
||||||
@@ -2998,44 +3022,139 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Tabs */
|
/* Tabs */
|
||||||
.tabs {
|
/* Sticky Navigation */
|
||||||
|
.jump-nav {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 4;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
justify-content: space-between;
|
||||||
margin-bottom: 24px;
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 12px 24px;
|
||||||
|
background-color: var(--bg-primary);
|
||||||
border-bottom: 1px solid var(--bg-tertiary);
|
border-bottom: 1px solid var(--bg-tertiary);
|
||||||
padding-bottom: 16px;
|
margin: 0 -24px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab {
|
.jump-nav-left {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jump-links {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jump-link {
|
||||||
|
padding: 4px 0;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
border-bottom: 2px solid transparent;
|
||||||
|
transition: color 150ms ease, border-color 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jump-link:hover {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.jump-link.active {
|
||||||
|
color: var(--text-primary);
|
||||||
|
border-bottom-color: var(--accent-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Page Search in Nav */
|
||||||
|
.page-search {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
}
|
||||||
padding: 10px 20px;
|
|
||||||
background: none;
|
.search-toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 8px;
|
background: transparent;
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
font-size: 14px;
|
border-radius: 6px;
|
||||||
font-weight: 500;
|
cursor: pointer;
|
||||||
|
transition: color 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-toggle:hover {
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border: 1px solid var(--bg-tertiary);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 0 4px 0 12px;
|
||||||
|
animation: slideInFromRight 200ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slideInFromRight {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(20px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input-sticky {
|
||||||
|
width: 180px;
|
||||||
|
padding: 6px 0;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-size: 13px;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input-sticky::placeholder {
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-controls {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 2px;
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-close-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text-muted);
|
||||||
|
border-radius: 4px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 150ms ease;
|
transition: all 150ms ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab:hover {
|
.search-close-btn:hover {
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
background-color: var(--bg-tertiary);
|
background-color: var(--bg-tertiary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab.active {
|
|
||||||
color: var(--text-primary);
|
|
||||||
background-color: var(--bg-tertiary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.tab .count {
|
|
||||||
font-size: 12px;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Album Controls */
|
/* Album Controls */
|
||||||
.album-controls {
|
.album-controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
Reference in new issue
Block a user