# Feature: Custom CSS Gallery Templates ## Overview This feature allows administrators to create and manage up to 3 custom CSS templates for gallery styling. Each template can be edited via a tabbed interface in the admin panel and selected when creating or editing events. The first template slot includes a working example template. **GitHub Issue:** Gallery Templates - Additional gallery layouts and themes --- ## Problem Statement Currently, gallery styling is limited to the built-in theme system with predefined color schemes. Photographers and administrators need: - Full CSS customization capabilities for unique branding - Ability to create multiple reusable style templates - Easy switching between templates for different event types - Professional-grade CSS editing experience --- ## User Story As an administrator, I want to create custom CSS templates for my galleries so that I can offer unique visual experiences for different clients and event types while maintaining my brand identity. --- ## Feature Requirements ### 1. Custom CSS Template System #### 1.1 Template Slots - **3 custom CSS template slots** available system-wide - Each slot has: - Name/label (editable, max 50 characters) - CSS content (unlimited, stored as TEXT) - Active/enabled toggle - Last modified timestamp #### 1.2 Default Template (Slot 1) - Pre-populated with a working example template - Demonstrates available CSS custom properties - Can be modified but shows "Reset to Default" option ### 2. Admin UI - Template Editor #### 2.1 Location **Path:** Admin Panel → Settings → Styling → Custom CSS Templates (new tab) #### 2.2 Tabbed Interface ``` ┌─────────────────────────────────────────────────────────────────┐ │ Settings > Styling │ ├─────────────────────────────────────────────────────────────────┤ │ [Theme] [Colors] [Custom CSS Templates] ← NEW TAB │ ├─────────────────────────────────────────────────────────────────┤ │ │ │ ┌──────────────┬──────────────┬──────────────┐ │ │ │ Template 1 │ Template 2 │ Template 3 │ │ │ │ (Elegant) │ (Untitled) │ (Untitled) │ │ │ └──────────────┴──────────────┴──────────────┘ │ │ │ │ Template Name: [Elegant Dark_______________] │ │ │ │ [✓] Enable this template │ │ │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ /* Elegant Dark Theme */ │ │ │ │ :root { │ │ │ │ --gallery-bg: #1a1a2e; │ │ │ │ --gallery-text: #eaeaea; │ │ │ │ --gallery-accent: #e94560; │ │ │ │ } │ │ │ │ │ │ │ │ .gallery-container { │ │ │ │ background: var(--gallery-bg); │ │ │ │ } │ │ │ │ ... │ │ │ └─────────────────────────────────────────────────────────┘ │ │ │ │ CSS Editor (CodeMirror) │ │ Line: 1 Col: 1 | Valid CSS ✓ │ │ │ │ [Preview] [Reset to Default*] [Save Template] │ │ │ │ * Only shown for Template 1 │ └─────────────────────────────────────────────────────────────────┘ ``` #### 2.3 CSS Editor Features - **CodeMirror integration** with CSS mode - Syntax highlighting - Auto-completion for CSS properties - Line numbers - Real-time CSS validation - Error highlighting - Find/replace functionality - Bracket matching ### 3. Event Integration #### 3.1 Event Creation/Edit Form Add template selector dropdown: ``` ┌─────────────────────────────────────────────────────────────────┐ │ Event Details │ ├─────────────────────────────────────────────────────────────────┤ │ ... │ │ │ │ Gallery Styling │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ Custom CSS Template │ │ │ │ ┌───────────────────────────────────────────────────┐ │ │ │ │ │ None (Use default theme) ▼ │ │ │ │ │ │ ─────────────────────────────────────────────────│ │ │ │ │ │ ○ None (Use default theme) │ │ │ │ │ │ ○ Elegant Dark │ │ │ │ │ │ ○ Template 2 (disabled) │ │ │ │ │ │ ○ Minimalist White │ │ │ │ │ └───────────────────────────────────────────────────┘ │ │ │ │ │ │ │ │ [Preview Template] │ │ │ └─────────────────────────────────────────────────────────┘ │ │ │ │ ... │ └─────────────────────────────────────────────────────────────────┘ ``` #### 3.2 Template Selection Rules - Only enabled templates appear in dropdown - "None" option always available (uses default theme) - Disabled templates show "(disabled)" and cannot be selected - Selected template ID stored in events table ### 4. Gallery Frontend Application #### 4.1 CSS Loading When gallery loads: 1. Check if event has `css_template_id` set 2. If set, fetch template CSS from API 3. Inject CSS into `