fuzzyworld

tools / files / separator-page / .github / copilot-instructions.md

copilot-instructions.md

3.6 KB · history · blame

Separator Page - AI Coding Instructions

Project Overview

A self-contained browser tab organizer that creates customizable separator pages. The entire application lives in a single HTML file (index.html) with embedded CSS and JavaScript.

Architecture Patterns

Single-File Web App

Dual Storage Pattern

State Management

Icon System Architecture

Three-Tier Icon Management

  1. Current icon: Synced between preview, favicon, and localStorage
  2. Previous icons: Global history with deduplication and 100-item limit
  3. Default icons: Static array from ./icons/template-icon-*.png files

Multi-Modal Icon Input

Icon Interaction Patterns

// Standard pattern for icon click handling
iconElement.addEventListener("click", async (event) => {
    if (event.shiftKey) {
        removePreviousIcon(iconUrl);           // Remove from history
    } else if (event.ctrlKey || event.metaKey) {
        await downloadImageAsFile(iconUrl, filename); // Download individual
    } else {
        handleIconChange(iconUrl);             // Set as current
    }
});

Key Conventions

Element Selection Pattern

All DOM elements cached as typed constants at script start:

/** @type {HTMLElement} */
const iconPreview = document.getElementById("icon-preview");

Background Image Styling

Data URL Handling

Development Workflows

Local Testing

Icon Management

Debugging State

External Integration

Source
1# Separator Page - AI Coding Instructions
2
3## Project Overview
4A self-contained browser tab organizer that creates customizable separator pages. The entire application lives in a single HTML file (`index.html`) with embedded CSS and JavaScript.
5
6## Architecture Patterns
7
8### Single-File Web App
9- Everything embedded in `index.html`: HTML structure, CSS styles, JavaScript logic
10- No build process, bundlers, or external dependencies beyond CDN libraries
11- Uses `showdown.js` from CDN for Markdown rendering
12
13### Dual Storage Pattern
14- **Per-tab data**: `localStorage['separator-tab-${tabId}']` stores individual separator content (title, description, icon)
15- **Global shared data**: `localStorage['separator-previous-icons']` stores icon history across all tabs
16- Tab ID generation: URL param `?tab=X` or timestamp-based fallback
17
18### State Management
19- No frameworks - direct DOM manipulation with cached element references
20- Save-on-change pattern: every user action triggers `saveTabData()`
21- URL params control initial state: `?name=X` sets title, `?tab=X` sets storage key
22
23## Icon System Architecture
24
25### Three-Tier Icon Management
261. **Current icon**: Synced between preview, favicon, and localStorage
272. **Previous icons**: Global history with deduplication and 100-item limit
283. **Default icons**: Static array from `./icons/template-icon-*.png` files
29
30### Multi-Modal Icon Input
31- Drag & drop image files (converts to data URLs)
32- Paste images from clipboard
33- URL input field
34- Click selection from previous icons grid
35
36### Icon Interaction Patterns
37```javascript
38// Standard pattern for icon click handling
39iconElement.addEventListener("click", async (event) => {
40 if (event.shiftKey) {
41 removePreviousIcon(iconUrl); // Remove from history
42 } else if (event.ctrlKey || event.metaKey) {
43 await downloadImageAsFile(iconUrl, filename); // Download individual
44 } else {
45 handleIconChange(iconUrl); // Set as current
46 }
47});
48```
49
50## Key Conventions
51
52### Element Selection Pattern
53All DOM elements cached as typed constants at script start:
54```javascript
55/** @type {HTMLElement} */
56const iconPreview = document.getElementById("icon-preview");
57```
58
59### Background Image Styling
60- **Preview icons**: Use `background-size: contain` to show full image
61- **Grid icons**: Use `background-size: cover` for consistent thumbnails
62- Always set `background-position: center` and `background-repeat: no-repeat`
63
64### Data URL Handling
65- Skip `data:image/x-icon` URLs in icon history (default favicon)
66- Convert external images to data URLs for persistence
67- Use Canvas API for cross-format PNG conversion
68
69## Development Workflows
70
71### Local Testing
72- Open `index.html` directly in browser - no server required
73- Default icons load from `./icons/` directory (14 template icons)
74- Uses relative paths - deploy anywhere that serves static files
75
76### Icon Management
77- Export: Downloads all current icons as `template-icon-1.png`, `template-icon-2.png`, etc.
78- Reset: Restores to default icon set from `./icons/` folder
79- Individual download: Ctrl/Cmd+click any icon for single file download
80
81### Debugging State
82- Check `localStorage['separator-tab-${tabId}']` for current tab data
83- Check `localStorage['separator-previous-icons']` for global icon history
84- Console logs with `console.debug()` for major state changes
85
86## External Integration
87- Designed for browser bookmark usage - bookmark the URL for instant separator creation
88- Works with tab tree extensions (Firefox Tree Style Tab shown in screenshots)
89- Markdown content rendered via Showdown.js with default settings
90- All links in rendered content open in new tabs (`target="_blank"`)