feat(folders): add icon and background customization to folders
- Create FolderEditModal component with icon presets and background colors - Reuse same styling pattern as FavoritesEditModal - Update folder cards in PlaylistManagerView to show custom icons/backgrounds - Support preset icons (heart, star, music, folder, disc, library) - Support solid colors and gradients for backgrounds - Support custom image upload This customization only affects PlaylistManagerView, not the sidebar.
This commit is contained in:
1 parent
ca8b657413
commit
69f4de6d1a
2 files changed
+552
-57
No files matched your search
@@ -0,0 +1,488 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { open } from '@tauri-apps/plugin-dialog';
|
||||||
|
import Modal from './Modal.svelte';
|
||||||
|
import { Heart, Star, Music, Folder, Disc, Library, Upload } from 'lucide-svelte';
|
||||||
|
import type { PlaylistFolder } from '$lib/stores/playlistFoldersStore';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
isOpen: boolean;
|
||||||
|
folder: PlaylistFolder | null;
|
||||||
|
onClose: () => void;
|
||||||
|
onSave: (folder: PlaylistFolder | null, updates: {
|
||||||
|
name: string;
|
||||||
|
iconType: string;
|
||||||
|
iconPreset: string;
|
||||||
|
iconColor: string;
|
||||||
|
customImagePath?: string;
|
||||||
|
}) => void;
|
||||||
|
onDelete?: (folder: PlaylistFolder) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { isOpen, folder, onClose, onSave, onDelete }: Props = $props();
|
||||||
|
|
||||||
|
let folderName = $state('');
|
||||||
|
let customIconPath = $state<string | null>(null);
|
||||||
|
let customIconPreset = $state<string>('folder');
|
||||||
|
let iconBackground = $state<string | null>(null);
|
||||||
|
let useCustomImage = $state(false);
|
||||||
|
let saving = $state(false);
|
||||||
|
|
||||||
|
const presetIcons = [
|
||||||
|
{ id: 'heart', label: 'Heart', icon: Heart },
|
||||||
|
{ id: 'star', label: 'Star', icon: Star },
|
||||||
|
{ id: 'music', label: 'Music', icon: Music },
|
||||||
|
{ id: 'folder', label: 'Folder', icon: Folder },
|
||||||
|
{ id: 'disc', label: 'Disc', icon: Disc },
|
||||||
|
{ 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: 'cyan', label: 'Cyan', value: '#06b6d4' },
|
||||||
|
{ id: 'blue', label: 'Blue', value: '#3b82f6' },
|
||||||
|
{ id: 'purple', label: 'Purple', value: '#a855f7' },
|
||||||
|
{ id: 'pink', label: 'Pink', value: '#ec4899' },
|
||||||
|
{ id: 'rose', label: 'Rose', value: '#f43f5e' },
|
||||||
|
{ id: 'slate', label: 'Slate', value: '#64748b' },
|
||||||
|
];
|
||||||
|
|
||||||
|
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: 'mint', label: 'Mint', value: 'linear-gradient(135deg, #00b09b 0%, #96c93d 100%)' },
|
||||||
|
{ id: 'candy', label: 'Candy', value: 'linear-gradient(135deg, #fc6767 0%, #ec008c 100%)' },
|
||||||
|
{ id: 'forest', label: 'Forest', value: 'linear-gradient(135deg, #134e5e 0%, #71b280 100%)' },
|
||||||
|
];
|
||||||
|
|
||||||
|
function selectPreset(presetId: string) {
|
||||||
|
customIconPreset = presetId;
|
||||||
|
useCustomImage = false;
|
||||||
|
customIconPath = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncFromFolder() {
|
||||||
|
if (folder) {
|
||||||
|
folderName = folder.name;
|
||||||
|
customIconPath = folder.custom_image_path || null;
|
||||||
|
customIconPreset = folder.icon_preset || 'folder';
|
||||||
|
iconBackground = folder.icon_color || null;
|
||||||
|
useCustomImage = folder.icon_type === 'custom' && !!folder.custom_image_path;
|
||||||
|
} else {
|
||||||
|
folderName = '';
|
||||||
|
customIconPath = null;
|
||||||
|
customIconPreset = 'folder';
|
||||||
|
iconBackground = null;
|
||||||
|
useCustomImage = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleUploadClick() {
|
||||||
|
try {
|
||||||
|
const selected = await open({
|
||||||
|
multiple: false,
|
||||||
|
filters: [{
|
||||||
|
name: 'Images',
|
||||||
|
extensions: ['png', 'jpg', 'jpeg', 'webp', 'gif']
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
|
||||||
|
if (selected && typeof selected === 'string') {
|
||||||
|
customIconPath = selected;
|
||||||
|
useCustomImage = true;
|
||||||
|
customIconPreset = 'folder';
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to open file picker:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSave() {
|
||||||
|
if (!folderName.trim()) return;
|
||||||
|
|
||||||
|
saving = true;
|
||||||
|
try {
|
||||||
|
onSave(folder, {
|
||||||
|
name: folderName.trim(),
|
||||||
|
iconType: useCustomImage ? 'custom' : 'preset',
|
||||||
|
iconPreset: customIconPreset,
|
||||||
|
iconColor: iconBackground || '',
|
||||||
|
customImagePath: useCustomImage ? customIconPath || undefined : undefined
|
||||||
|
});
|
||||||
|
onClose();
|
||||||
|
} finally {
|
||||||
|
saving = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDelete() {
|
||||||
|
if (folder && onDelete) {
|
||||||
|
onDelete(folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCancel() {
|
||||||
|
syncFromFolder();
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (isOpen) {
|
||||||
|
syncFromFolder();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Modal {isOpen} onClose={handleCancel} title={folder ? 'Edit Folder' : 'New Folder'} maxWidth="560px">
|
||||||
|
{#snippet children()}
|
||||||
|
<div class="folder-modal-content">
|
||||||
|
<!-- Name input -->
|
||||||
|
<div class="modal-section">
|
||||||
|
<h3>Name</h3>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="folder-name-input"
|
||||||
|
bind:value={folderName}
|
||||||
|
placeholder="Enter folder name"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Icon Section -->
|
||||||
|
<div class="modal-section">
|
||||||
|
<h3>Icon</h3>
|
||||||
|
<p class="section-description">Choose an icon for this folder</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>
|
||||||
|
|
||||||
|
<!-- Background Section -->
|
||||||
|
<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="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>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
{#snippet footer()}
|
||||||
|
<div class="modal-actions">
|
||||||
|
{#if folder && onDelete}
|
||||||
|
<button class="btn btn-danger" onclick={handleDelete} disabled={saving}>
|
||||||
|
Delete Folder
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
<div class="modal-actions-right">
|
||||||
|
<button class="btn btn-secondary" onclick={handleCancel} disabled={saving}>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-primary" onclick={handleSave} disabled={saving || !folderName.trim()}>
|
||||||
|
{saving ? 'Saving...' : folder ? 'Save' : 'Create'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.folder-modal-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-name-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px 12px;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border: 1px solid var(--bg-tertiary);
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
outline: none;
|
||||||
|
transition: border-color 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-name-input:focus {
|
||||||
|
border-color: var(--accent-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-name-input::placeholder {
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-section {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-section h3 {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0 0 4px 0;
|
||||||
|
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);
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-preset-btn {
|
||||||
|
aspect-ratio: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 150ms ease;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-preset-btn:hover {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border-color: var(--accent-primary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-preset-btn.active {
|
||||||
|
background: var(--accent-primary);
|
||||||
|
border-color: var(--accent-primary);
|
||||||
|
color: var(--bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(12, 1fr);
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-btn {
|
||||||
|
aspect-ratio: 1;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: transparent;
|
||||||
|
font-size: 0;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 150ms ease;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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: 4px;
|
||||||
|
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;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border: 1px solid var(--bg-tertiary);
|
||||||
|
border-radius: 6px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-btn:hover {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-filename {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding-top: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-actions-right {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
padding: 8px 20px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 150ms ease;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary:hover:not(:disabled) {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background: var(--accent-primary);
|
||||||
|
color: var(--bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover:not(:disabled) {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-danger {
|
||||||
|
background: rgba(239, 68, 68, 0.1);
|
||||||
|
border: 1px solid rgba(239, 68, 68, 0.3);
|
||||||
|
color: #ef4444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-danger:hover:not(:disabled) {
|
||||||
|
background: rgba(239, 68, 68, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
import { ArrowLeft, Filter, ArrowUpDown, LayoutGrid, List, GripVertical, EyeOff, Eye, BarChart2, Play, Pencil, Search, X, Cloud, CloudOff, Wifi, Heart, Folder, FolderPlus, ChevronRight, ChevronDown, Trash2 } from 'lucide-svelte';
|
import { ArrowLeft, Filter, ArrowUpDown, LayoutGrid, List, GripVertical, EyeOff, Eye, BarChart2, Play, Pencil, Search, X, Cloud, CloudOff, Wifi, Heart, Folder, FolderPlus, ChevronRight, ChevronDown, Trash2, Star, Music, Disc, Library } from 'lucide-svelte';
|
||||||
import PlaylistCollage from '../PlaylistCollage.svelte';
|
import PlaylistCollage from '../PlaylistCollage.svelte';
|
||||||
import PlaylistModal from '../PlaylistModal.svelte';
|
import PlaylistModal from '../PlaylistModal.svelte';
|
||||||
|
import FolderEditModal from '../FolderEditModal.svelte';
|
||||||
import { t } from '$lib/i18n';
|
import { t } from '$lib/i18n';
|
||||||
import {
|
import {
|
||||||
subscribe as subscribeOffline,
|
subscribe as subscribeOffline,
|
||||||
@@ -108,7 +109,6 @@
|
|||||||
// Create/Edit folder modal state
|
// Create/Edit folder modal state
|
||||||
let showFolderModal = $state(false);
|
let showFolderModal = $state(false);
|
||||||
let editingFolder = $state<PlaylistFolder | null>(null);
|
let editingFolder = $state<PlaylistFolder | null>(null);
|
||||||
let folderName = $state('');
|
|
||||||
|
|
||||||
// Persist preferences
|
// Persist preferences
|
||||||
$effect(() => { localStorage.setItem('qbz-pm-filter', filter); });
|
$effect(() => { localStorage.setItem('qbz-pm-filter', filter); });
|
||||||
@@ -537,50 +537,62 @@
|
|||||||
|
|
||||||
function openCreateFolderModal() {
|
function openCreateFolderModal() {
|
||||||
editingFolder = null;
|
editingFolder = null;
|
||||||
folderName = '';
|
|
||||||
showFolderModal = true;
|
showFolderModal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openEditFolderModal(folder: PlaylistFolder) {
|
function openEditFolderModal(folder: PlaylistFolder) {
|
||||||
editingFolder = folder;
|
editingFolder = folder;
|
||||||
folderName = folder.name;
|
|
||||||
showFolderModal = true;
|
showFolderModal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeFolderModal() {
|
function closeFolderModal() {
|
||||||
showFolderModal = false;
|
showFolderModal = false;
|
||||||
editingFolder = null;
|
editingFolder = null;
|
||||||
folderName = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSaveFolder() {
|
async function handleSaveFolder(
|
||||||
if (!folderName.trim()) return;
|
folder: PlaylistFolder | null,
|
||||||
|
updates: {
|
||||||
if (editingFolder) {
|
name: string;
|
||||||
// Update existing folder (name only for now)
|
iconType: string;
|
||||||
await updateFolder(editingFolder.id, {
|
iconPreset: string;
|
||||||
name: folderName.trim()
|
iconColor: string;
|
||||||
|
customImagePath?: string;
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
if (folder) {
|
||||||
|
// Update existing folder
|
||||||
|
await updateFolder(folder.id, {
|
||||||
|
name: updates.name,
|
||||||
|
iconType: updates.iconType,
|
||||||
|
iconPreset: updates.iconPreset,
|
||||||
|
iconColor: updates.iconColor,
|
||||||
|
customImagePath: updates.customImagePath
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Create new folder (simple, name only)
|
// Create new folder
|
||||||
await createFolder(folderName.trim());
|
await createFolder(
|
||||||
|
updates.name,
|
||||||
|
updates.iconType,
|
||||||
|
updates.iconPreset,
|
||||||
|
updates.iconColor
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
folders = getVisibleFolders();
|
folders = getVisibleFolders();
|
||||||
closeFolderModal();
|
closeFolderModal();
|
||||||
|
onPlaylistsChanged?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDeleteFolder() {
|
async function handleDeleteFolder(folder: PlaylistFolder) {
|
||||||
if (!editingFolder) return;
|
const confirmed = confirm(`Delete folder "${folder.name}"? Playlists will be moved to root.`);
|
||||||
|
|
||||||
const confirmed = confirm(`Delete folder "${editingFolder.name}"? Playlists will be moved to root.`);
|
|
||||||
if (!confirmed) return;
|
if (!confirmed) return;
|
||||||
|
|
||||||
await deleteFolder(editingFolder.id);
|
await deleteFolder(folder.id);
|
||||||
folders = getVisibleFolders();
|
folders = getVisibleFolders();
|
||||||
|
|
||||||
// If we're inside the deleted folder, go back to root
|
// If we're inside the deleted folder, go back to root
|
||||||
if (currentFolderId === editingFolder.id) {
|
if (currentFolderId === folder.id) {
|
||||||
currentFolderId = null;
|
currentFolderId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,8 +782,22 @@
|
|||||||
onclick={() => navigateToFolder(folder.id)}
|
onclick={() => navigateToFolder(folder.id)}
|
||||||
onkeydown={(e) => e.key === 'Enter' && navigateToFolder(folder.id)}
|
onkeydown={(e) => e.key === 'Enter' && navigateToFolder(folder.id)}
|
||||||
>
|
>
|
||||||
<div class="folder-icon">
|
<div class="folder-icon" style={folder.icon_color ? `background: ${folder.icon_color};` : ''}>
|
||||||
|
{#if folder.icon_type === 'custom' && folder.custom_image_path}
|
||||||
|
<img src={folder.custom_image_path} alt="" class="folder-custom-img" />
|
||||||
|
{:else if folder.icon_preset === 'heart'}
|
||||||
|
<Heart size={32} />
|
||||||
|
{:else if folder.icon_preset === 'star'}
|
||||||
|
<Star size={32} />
|
||||||
|
{:else if folder.icon_preset === 'music'}
|
||||||
|
<Music size={32} />
|
||||||
|
{:else if folder.icon_preset === 'disc'}
|
||||||
|
<Disc size={32} />
|
||||||
|
{:else if folder.icon_preset === 'library'}
|
||||||
|
<Library size={32} />
|
||||||
|
{:else}
|
||||||
<Folder size={32} />
|
<Folder size={32} />
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<span class="folder-name">{folder.name}</span>
|
<span class="folder-name">{folder.name}</span>
|
||||||
<span class="folder-count">{getPlaylistCountInFolder(folder.id)} playlists</span>
|
<span class="folder-count">{getPlaylistCountInFolder(folder.id)} playlists</span>
|
||||||
@@ -1000,43 +1026,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Folder Modal -->
|
<!-- Folder Modal -->
|
||||||
{#if showFolderModal}
|
<FolderEditModal
|
||||||
<div class="modal-overlay" onclick={closeFolderModal} role="presentation">
|
isOpen={showFolderModal}
|
||||||
<div class="modal-content folder-modal" onclick={(e) => e.stopPropagation()} role="dialog" aria-modal="true">
|
folder={editingFolder}
|
||||||
<h2 class="modal-title">{editingFolder ? 'Edit Folder' : 'New Folder'}</h2>
|
onClose={closeFolderModal}
|
||||||
<div class="form-group">
|
onSave={handleSaveFolder}
|
||||||
<label for="folder-name-input">Name</label>
|
onDelete={handleDeleteFolder}
|
||||||
<input
|
|
||||||
id="folder-name-input"
|
|
||||||
type="text"
|
|
||||||
bind:value={folderName}
|
|
||||||
placeholder="Enter folder name"
|
|
||||||
onkeydown={(e) => e.key === 'Enter' && handleSaveFolder()}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
<div class="modal-actions">
|
|
||||||
{#if editingFolder}
|
|
||||||
<button class="btn-danger" onclick={handleDeleteFolder}>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
Delete
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
<div class="modal-actions-right">
|
|
||||||
<button class="btn-secondary" onclick={closeFolderModal}>
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="btn-primary"
|
|
||||||
onclick={handleSaveFolder}
|
|
||||||
disabled={!folderName.trim()}
|
|
||||||
>
|
|
||||||
{editingFolder ? 'Save' : 'Create'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<!-- Edit Modal -->
|
<!-- Edit Modal -->
|
||||||
{#if editingPlaylist}
|
{#if editingPlaylist}
|
||||||
@@ -1213,6 +1209,17 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
border-radius: 12px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-custom-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.folder-name {
|
.folder-name {
|
||||||
|
|||||||
Reference in new issue
Block a user