FolderFiles Component
3D filing cabinet with stacked folders and drag-and-drop organisation
Interactive Demo
How to use: Hover over a folder to reveal more tabs beneath β Click a folder to open it β Drag items between "Selected" and "All Items" panels to organise content
Component Features
ποΈ 3D Filing Cabinet
Folders stacked with subtle 3D transforms and depth effects, like a physical filing cabinet drawer.
π¨ Colour-Coded Folders
Each folder has a vibrant colour with visible body and protruding tab for easy identification.
π Staggered Tabs
Folder tabs positioned in left-center-right pattern for easy access, like real filing folders.
ποΈ Hover Animation
Hovering over a folder drops folders beneath to reveal more tabs with smooth animation.
π Drag & Drop
Native HTML5 drag-and-drop between two panels for organising content items.
π¬ Smart Tooltips
Tooltips appear below tabs in the revealed space, showing folder name and item count.
πΎ Database Integration
Neon PostgreSQL with graceful fallback to constants when DB unavailable.
βΏ Accessible
ARIA labels, keyboard navigation, focus management, reduced motion support.
π± Responsive
Mobile-friendly layout adapts to all screen sizes automatically.
π Secure
HTML sanitization with DOMPurify prevents XSS attacks.
π¦ Self-Contained
Copy-paste ready with all styles scoped. Zero external dependencies.
Usage Example
<script>
import FolderFiles from '$lib/components/FolderFiles.svelte';
let { data } = $props();
</script>
<FolderFiles
folders={data.folders}
files={data.files}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
folders | Folder[] | [] | Array of folder objects with id, label, color |
files | FileItem[] | [] | Array of file items with title, subtitle, previewText |
Data Structure
Folder Interface
interface Folder {
id: number;
label: string; // Display name
color: string; // Tailwind class (e.g., 'bg-blue-500')
textColor?: string; // Tailwind class (e.g., 'text-white')
icon?: string; // Emoji or character
description?: string; // For tooltip
category?: string; // For filtering
}FileItem Interface
interface FileItem {
id: number;
folderId: number; // Parent folder ID
title: string;
subtitle?: string;
previewText: string; // Brief description
}Implementation Tips
π¨ Folder Colours
Use hex colour codes for folders (e.g., #a855f7). The component applies
these colours to both the folder tab and body with automatic depth shading.
π Tab Positioning
Tabs automatically stagger left-center-right using modulo pattern. First folder left, second center-left, third center-right, then repeats.
ποΈ Database Schema
Run database/schema_folderfiles.sql in Neon to create tables. Simple
structure with folders and files tables linked by folderId.
π Fallback Data
Component works without database using FALLBACK_FOLDERS and FALLBACK_FILES from constants.ts.