feat(phase4.3): add background color picker to favorites modal
- Add icon_background field to backend (Rust + TS types) - Update modal to 60% wider (1150px) - Implement two-column layout (icon left, tabs right) - Add solid color picker (8 colors + none) - Add gradient picker (6 gradients) - Remove background from edit button to match PlaylistView style - Update database migration for icon_background field cp
This commit is contained in:
1 parent
5bd52cc89b
commit
4009ae9b26
4 files changed
+233
-69
No files matched your search
@@ -16,6 +16,7 @@
|
||||
|
||||
let customIconPath = $state<string | null>(initialPreferences.custom_icon_path || null);
|
||||
let customIconPreset = $state<string | null>(initialPreferences.custom_icon_preset || 'heart');
|
||||
let iconBackground = $state<string | null>(initialPreferences.icon_background || null);
|
||||
let tabOrder = $state<string[]>([...initialPreferences.tab_order]);
|
||||
let useCustomImage = $state(!!initialPreferences.custom_icon_path);
|
||||
let saving = $state(false);
|
||||
@@ -29,6 +30,26 @@
|
||||
{ id: 'library', label: 'Library', icon: Library },
|
||||
];
|
||||
|
||||
const solidColors = [
|
||||
{ id: 'accent', label: 'Accent', value: 'var(--accent-primary)' },
|
||||
{ id: 'red', label: 'Red', value: '#ef4444' },
|
||||
{ id: 'orange', label: 'Orange', value: '#f97316' },
|
||||
{ id: 'amber', label: 'Amber', value: '#f59e0b' },
|
||||
{ id: 'green', label: 'Green', value: '#10b981' },
|
||||
{ id: 'blue', label: 'Blue', value: '#3b82f6' },
|
||||
{ id: 'purple', label: 'Purple', value: '#a855f7' },
|
||||
{ id: 'pink', label: 'Pink', value: '#ec4899' },
|
||||
];
|
||||
|
||||
const gradients = [
|
||||
{ id: 'sunset', label: 'Sunset', value: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)' },
|
||||
{ id: 'ocean', label: 'Ocean', value: 'linear-gradient(135deg, #2e3192 0%, #1bffff 100%)' },
|
||||
{ id: 'fire', label: 'Fire', value: 'linear-gradient(135deg, #ff0844 0%, #ffb199 100%)' },
|
||||
{ id: 'forest', label: 'Forest', value: 'linear-gradient(135deg, #0ba360 0%, #3cba92 100%)' },
|
||||
{ id: 'aurora', label: 'Aurora', value: 'linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)' },
|
||||
{ id: 'midnight', label: 'Midnight', value: 'linear-gradient(135deg, #000428 0%, #004e92 100%)' },
|
||||
];
|
||||
|
||||
const tabLabels: Record<string, string> = {
|
||||
tracks: 'Tracks',
|
||||
albums: 'Albums',
|
||||
@@ -82,6 +103,7 @@
|
||||
const prefs: FavoritesPreferences = {
|
||||
custom_icon_path: useCustomImage ? customIconPath : null,
|
||||
custom_icon_preset: useCustomImage ? null : customIconPreset,
|
||||
icon_background: iconBackground,
|
||||
tab_order: tabOrder,
|
||||
};
|
||||
|
||||
@@ -98,73 +120,127 @@
|
||||
function handleCancel() {
|
||||
customIconPath = initialPreferences.custom_icon_path || null;
|
||||
customIconPreset = initialPreferences.custom_icon_preset || 'heart';
|
||||
iconBackground = initialPreferences.icon_background || null;
|
||||
tabOrder = [...initialPreferences.tab_order];
|
||||
useCustomImage = !!initialPreferences.custom_icon_path;
|
||||
onClose();
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal {isOpen} onClose={handleCancel} title="Favorites Settings" maxWidth="720px">
|
||||
<Modal {isOpen} onClose={handleCancel} title="Favorites Settings" maxWidth="1150px">
|
||||
{#snippet children()}
|
||||
<div class="modal-section">
|
||||
<h3>Icon</h3>
|
||||
<p class="section-description">Choose an icon for the Favorites page header</p>
|
||||
|
||||
<div class="icon-grid">
|
||||
{#each presetIcons as preset}
|
||||
<button
|
||||
class="icon-preset-btn"
|
||||
class:active={!useCustomImage && customIconPreset === preset.id}
|
||||
onclick={() => selectPreset(preset.id)}
|
||||
title={preset.label}
|
||||
>
|
||||
<svelte:component this={preset.icon} size={24} />
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div class="custom-upload">
|
||||
<button class="upload-btn" onclick={handleUploadClick}>
|
||||
<Upload size={16} />
|
||||
<span>Upload Custom Image</span>
|
||||
</button>
|
||||
{#if useCustomImage && customIconPath}
|
||||
<span class="upload-filename">{customIconPath.split('/').pop()}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-section">
|
||||
<h3>Tab Order</h3>
|
||||
<p class="section-description">Reorder tabs in the Favorites page navigation</p>
|
||||
|
||||
<div class="tab-order-list">
|
||||
{#each tabOrder as tab, index}
|
||||
<div class="tab-order-item">
|
||||
<div class="tab-grip">
|
||||
<GripVertical size={16} />
|
||||
</div>
|
||||
<div class="tab-label">{tabLabels[tab] || tab}</div>
|
||||
<div class="tab-controls">
|
||||
<div class="modal-columns">
|
||||
<!-- Left Column: Icon Customization -->
|
||||
<div class="modal-column">
|
||||
<div class="modal-section">
|
||||
<h3>Icon</h3>
|
||||
<p class="section-description">Choose an icon for the Favorites page header</p>
|
||||
|
||||
<div class="icon-grid">
|
||||
{#each presetIcons as preset}
|
||||
<button
|
||||
class="tab-move-btn"
|
||||
onclick={() => moveUp(index)}
|
||||
disabled={index === 0}
|
||||
title="Move up"
|
||||
class="icon-preset-btn"
|
||||
class:active={!useCustomImage && customIconPreset === preset.id}
|
||||
onclick={() => selectPreset(preset.id)}
|
||||
title={preset.label}
|
||||
>
|
||||
↑
|
||||
<svelte:component this={preset.icon} size={24} />
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div class="custom-upload">
|
||||
<button class="upload-btn" onclick={handleUploadClick}>
|
||||
<Upload size={16} />
|
||||
<span>Upload Custom Image</span>
|
||||
</button>
|
||||
{#if useCustomImage && customIconPath}
|
||||
<span class="upload-filename">{customIconPath.split('/').pop()}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-section">
|
||||
<h3>Background</h3>
|
||||
<p class="section-description">Choose a background color or gradient</p>
|
||||
|
||||
<div class="color-section">
|
||||
<h4>Solid Colors</h4>
|
||||
<div class="color-grid">
|
||||
<button
|
||||
class="tab-move-btn"
|
||||
onclick={() => moveDown(index)}
|
||||
disabled={index === tabOrder.length - 1}
|
||||
title="Move down"
|
||||
class="color-btn"
|
||||
class:active={iconBackground === null}
|
||||
onclick={() => iconBackground = null}
|
||||
title="None"
|
||||
>
|
||||
↓
|
||||
<div class="color-swatch no-color"></div>
|
||||
</button>
|
||||
{#each solidColors as color}
|
||||
<button
|
||||
class="color-btn"
|
||||
class:active={iconBackground === color.value}
|
||||
onclick={() => iconBackground = color.value}
|
||||
title={color.label}
|
||||
>
|
||||
<div class="color-swatch" style="background: {color.value};"></div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
<div class="color-section">
|
||||
<h4>Gradients</h4>
|
||||
<div class="color-grid">
|
||||
{#each gradients as gradient}
|
||||
<button
|
||||
class="color-btn"
|
||||
class:active={iconBackground === gradient.value}
|
||||
onclick={() => iconBackground = gradient.value}
|
||||
title={gradient.label}
|
||||
>
|
||||
<div class="color-swatch" style="background: {gradient.value};"></div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right Column: Tab Order -->
|
||||
<div class="modal-column">
|
||||
<div class="modal-section">
|
||||
<h3>Tab Order</h3>
|
||||
<p class="section-description">Reorder tabs in the Favorites page navigation</p>
|
||||
|
||||
<div class="tab-order-list">
|
||||
{#each tabOrder as tab, index}
|
||||
<div class="tab-order-item">
|
||||
<div class="tab-grip">
|
||||
<GripVertical size={16} />
|
||||
</div>
|
||||
<div class="tab-label">{tabLabels[tab] || tab}</div>
|
||||
<div class="tab-controls">
|
||||
<button
|
||||
class="tab-move-btn"
|
||||
onclick={() => moveUp(index)}
|
||||
disabled={index === 0}
|
||||
title="Move up"
|
||||
>
|
||||
↑
|
||||
</button>
|
||||
<button
|
||||
class="tab-move-btn"
|
||||
onclick={() => moveDown(index)}
|
||||
disabled={index === tabOrder.length - 1}
|
||||
title="Move down"
|
||||
>
|
||||
↓
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
@@ -182,6 +258,16 @@
|
||||
</Modal>
|
||||
|
||||
<style>
|
||||
.modal-columns {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 32px;
|
||||
}
|
||||
|
||||
.modal-column {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.modal-section {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
@@ -197,12 +283,27 @@
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.modal-section h4 {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
margin: 0 0 8px 0;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.section-description {
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
margin: 0 0 16px 0;
|
||||
}
|
||||
|
||||
.color-section {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.color-section:last-of-type {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.icon-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, 1fr);
|
||||
@@ -214,7 +315,7 @@
|
||||
aspect-ratio: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
justify-center: center;
|
||||
background: var(--bg-secondary);
|
||||
border: 2px solid transparent;
|
||||
border-radius: 8px;
|
||||
@@ -235,6 +336,62 @@
|
||||
color: var(--bg-primary);
|
||||
}
|
||||
|
||||
.color-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.color-btn {
|
||||
aspect-ratio: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: transparent;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 150ms ease;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.color-btn:hover {
|
||||
border-color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.color-btn.active {
|
||||
border-color: var(--accent-primary);
|
||||
box-shadow: 0 0 0 1px var(--accent-primary);
|
||||
}
|
||||
|
||||
.color-swatch {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.color-swatch.no-color {
|
||||
background: linear-gradient(
|
||||
45deg,
|
||||
var(--bg-tertiary) 25%,
|
||||
transparent 25%,
|
||||
transparent 75%,
|
||||
var(--bg-tertiary) 75%,
|
||||
var(--bg-tertiary)
|
||||
),
|
||||
linear-gradient(
|
||||
45deg,
|
||||
var(--bg-tertiary) 25%,
|
||||
transparent 25%,
|
||||
transparent 75%,
|
||||
var(--bg-tertiary) 75%,
|
||||
var(--bg-tertiary)
|
||||
);
|
||||
background-size: 10px 10px;
|
||||
background-position: 0 0, 5px 5px;
|
||||
}
|
||||
|
||||
.custom-upload {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -137,6 +137,7 @@
|
||||
let favoritesPreferences = $state<FavoritesPreferences>({
|
||||
custom_icon_path: null,
|
||||
custom_icon_preset: 'heart',
|
||||
icon_background: null,
|
||||
tab_order: ['tracks', 'albums', 'artists', 'playlists'],
|
||||
});
|
||||
|
||||
@@ -1402,18 +1403,15 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--bg-tertiary);
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
transition: all 150ms ease;
|
||||
}
|
||||
|
||||
.edit-btn:hover {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
border-color: var(--accent-primary);
|
||||
color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.tabs {
|
||||
|
||||
@@ -250,5 +250,6 @@ export interface SongLinkResponse {
|
||||
export interface FavoritesPreferences {
|
||||
custom_icon_path: string | null;
|
||||
custom_icon_preset: string | null;
|
||||
icon_background: string | null;
|
||||
tab_order: string[];
|
||||
}
|
||||
Reference in new issue
Block a user