start-design

star 224

Start design for a GitHub issue - creates design doc from research/ideas, updates status to Ready

nockawa By nockawa schedule Updated 2/21/2026

name: start-design description: Start design for a GitHub issue - creates design doc from research/ideas, updates status to Ready argument-hint: [issue number or title] [--deep]

Start Design for a GitHub Issue

Transition an issue into the Design phase by creating a design document, seeded from existing research (or ideas), and updating the project board status to "Ready".

Input

$ARGUMENTS may contain:

  • An issue number (e.g., 42 or #42) -> proceed directly to the workflow
  • A title/text (non-numeric) -> offer to create a new issue with that title
  • Nothing (empty) -> show available issues to pick from, or offer to create one
  • The --deep flag (anywhere in arguments) -> create a directory structure instead of a single file

Extract --deep from arguments first, then process the remainder as issue number or title.

Help

If $ARGUMENTS contains --help or -h, display the following and stop — do not execute the workflow.

/start-design [#N | title] [--deep]

  Start design for a GitHub issue — creates design doc from research/ideas, updates status to Ready.

Arguments:
  #N              Issue number (e.g., 42 or #42)
  title           Text — offers to create or search
  --deep          Create directory structure instead of single file
  --help, -h      Show this help

What it does:
  1. Fetches issue (or creates one inline)
  2. Checks for research/ideas documents to seed from
  3. Creates design doc (single file or deep directory)
  4. Handles source docs (conclude/archive/leave)
  5. Updates project status to Ready

Examples:
  /start-design #42
  /start-design "Error handling overhaul" --deep
  /start-design

Handling No Issue Number

Case 1: No arguments provided

Fetch Research and Backlog items from the project. Always pipe gh project item-list directly to Python (see .claude/skills/_helpers.md Section 2):

gh project item-list 7 --owner nockawa --limit 200 --format json 2>&1 | python3 -c "
import json, sys
items = json.load(sys.stdin)['items']
for item in items:
    s = item.get('status', '')
    if s in ('Research', 'Backlog'):
        n = item.get('content', {}).get('number', '?')
        t = item.get('title', 'untitled')
        p = item.get('priority', '?')
        a = item.get('area', '?')
        print(f'#{n} | {s} | {p} | {a} | {t}')
"

Use the output to filter for items with Status = "Research" (prioritize these -- they're the ones most likely ready for design) then "Backlog". Use AskUserQuestion to present a choice:

Question: "Which issue would you like to start designing?" Header: "Issue" Options (up to 4, prioritize Research items first, then Backlog by priority):

  • #<number> - <title> (description: "[Status] [Priority] [Area]") -- for each candidate issue
  • Create a new issue (description: "I'll help you create one right now")

If the user picks an existing issue, continue with the normal workflow below using that issue number.

If the user picks "Create a new issue", proceed to Inline Issue Creation below.

Case 2: Non-numeric argument (looks like a title)

If $ARGUMENTS (after removing --deep) is not empty and not a number (doesn't match ^\d+$ after stripping #), use AskUserQuestion:

Question: "It looks like you provided a title instead of an issue number. Would you like to:" Header: "Action" Options:

  • Create a new issue with this title (description: "I'll create '$ARGUMENTS' and start design on it")
  • Search existing issues (description: "Search for issues matching '$ARGUMENTS' to pick one")

If "Create a new issue": proceed to Inline Issue Creation with the title pre-filled.

If "Search existing issues": use mcp__GitHub__search_issues with q: "repo:nockawa/Typhon $ARGUMENTS" and present matching issues via AskUserQuestion.

Inline Issue Creation

When an issue needs to be created, do it inline rather than redirecting the user to /create-issue.

Follow the /create-issue skill workflow directly:

  1. Gather info -- Use AskUserQuestion to collect:

    • Title (if not already provided from $ARGUMENTS)
    • Description (ask the user to describe what needs to be done)
    • Type labels, Area, Priority, Phase, Estimate (use the same questions as /create-issue)
  2. Create the issue -- Use mcp__GitHub__create_issue with:

    • owner: "nockawa"
    • repo: "Typhon"
    • title: "<title>"
    • body: "<description>"
    • labels: ["<label1>", "<label2>"]
    • assignees: ["nockawa"]
  3. Add to project and set fields -- Follow /create-issue steps 3-5

  4. Continue -- Once the issue is created, continue with the normal /start-design workflow below using the new issue number.

Workflow

1. Fetch Issue Details

Use mcp__GitHub__get_issue with:

  • owner: "nockawa"
  • repo: "Typhon"
  • issue_number: <number>

2. Status Guard

Check the issue's current project status. If the issue is already past "Ready" (i.e., status is "In Progress", "Review", or "Done"), warn the user:

Question: "Issue # is already at ''. Starting design would move it back to 'Ready'. Proceed?" Header: "Status" Options:

  • Proceed anyway (description: "Move status back to Ready and create the design doc")
  • Cancel (description: "Don't change anything")

If "Cancel", stop and report that no changes were made.

3. Check for Existing Source Documents

3a. Research documents

List all files under claude/research/:

Glob: claude/research/**/*.md

If any research documents exist, present them to the user via AskUserQuestion:

Question: "I found these research documents. Which ones (if any) should feed into this design?" Header: "Research" Options (up to 4, pick the most likely related ones based on name/path similarity to the issue title):

  • claude/research/<path> (description: first line or title from the file) -- for each candidate
  • None (description: "Don't use any research docs") MultiSelect: true

If the user selects one or more research docs, read their full content for use in step 5.

3b. Ideas documents (if no research was selected)

If the user selected "None" for research docs (or no research docs exist), also check claude/ideas/:

Glob: claude/ideas/**/*.md

If any ideas documents exist, present them the same way:

Question: "No research docs selected. I found these ideas documents. Use any as input?" Header: "Ideas" Options (up to 4):

  • claude/ideas/<path> (description: first line or title from the file) -- for each candidate
  • None -- start fresh (description: "Create the design doc from scratch using only the issue context") MultiSelect: true

If the user selects ideas docs, read their full content for use in step 5.

4. Determine Design Doc Location

First, try to infer the category from the selected source document(s):

  • If one or more research/ideas docs were selected, use their parent directory path as the category.
    • Example: research doc at claude/research/database-engine/QuerySystem.md -> category = database-engine/
    • Example: research doc at claude/research/timeout/README.md -> category = root level, doc name derived from issue
    • If multiple source docs are from different categories, use the most specific common ancestor.

If no category can be inferred (no source docs selected, or docs are at root level with no clear category), ask the user:

List existing directories under claude/design/ and present:

Question: "Where should this design doc go?" Header: "Location" Options (up to 4):

  • design/ (root level) (description: "No category, just a file at the top level")
  • design/<existing-category>/ (description: "Existing category") -- for each existing subdirectory
  • Other (description: "Specify a custom path / create new category") MultiSelect: false

5. Create Design Document

Derive the document name from the issue title, using PascalCase (e.g., issue "Add spatial indexing support" -> SpatialIndexingSupport).

When source documents were selected, read their content to seed specific sections. The design doc is a scaffold -- pre-fill what can be derived, leave the actual design work to the user.

Standard Mode (no --deep)

Create a single file: claude/design/<category>/<Name>.md

# <Issue Title> Design

**Date:** <today YYYY-MM-DD>
**Status:** Draft
**GitHub Issue:** #<number>
**Branch:** --

## Summary

<If a research doc was used and has a Recommendation section, synthesize a 2-3 sentence summary from it. If an ideas doc was used, derive from its "The Idea" section. If starting fresh, derive from the issue body.>

## Goals

<If a research doc was used, extract goals from its Recommendation/Conclusion. If an ideas doc was used, extract from "Why This Might Matter". Otherwise, derive from the issue body. Format as bullet list.>
- Goal 1
- Goal 2

## Non-Goals

- [Explicitly out of scope -- to be filled by user]

## Design

### Overview

[High-level description with diagram if helpful]

### Data Structures

[Key types, schemas, storage]

### API / Interface

[Public API, method signatures]

### Implementation Details

[Key algorithms, edge cases, error handling]

## Testing Strategy

- [ ] Unit tests for X
- [ ] Integration tests for Y

## Open Questions

<If source docs had unresolved questions, migrate relevant ones here. Otherwise leave placeholders.>
- [ ] [Open question]

## References

- GitHub Issue: #<number>
<If research doc was used:>
- Research: `claude/research/<path>`
<If ideas doc was used:>
- Ideas: `claude/ideas/<path>`
<If issue body has links:>
- [Extracted references]

Deep Mode (--deep)

Create a directory: claude/design/<category>/<Name>/

README.md (entry point):

# <Issue Title> Design

<One-line description derived from summary>

**Date:** <today YYYY-MM-DD>
**Status:** Draft
**GitHub Issue:** #<number>
**Branch:** --

## Summary

<Same as standard mode -- synthesized from source docs or issue body.>

## Goals

<Same as standard mode.>

## Non-Goals

- [Explicitly out of scope -- to be filled by user]

## Document Series

| Part | Title | Focus |
|------|-------|-------|
| [01](./01-overview.md) | **Overview & Data Structures** | High-level design, key types |

## Open Questions

<Migrated from source docs or placeholders.>
- [ ] [Open question]

## References

- GitHub Issue: #<number>
<If research doc was used:>
- Research: `claude/research/<path>`
<If ideas doc was used:>
- Ideas: `claude/ideas/<path>`

01-overview.md (first part):

# Overview & Data Structures

## Design Overview

[High-level description with diagram if helpful]

## Data Structures

[Key types, schemas, storage]

## API / Interface

[Public API, method signatures]

## Implementation Details

[Key algorithms, edge cases, error handling]

## Testing Strategy

- [ ] Unit tests for X
- [ ] Integration tests for Y

Additional numbered parts can be added later with "add new part ".</p> <h3>6. Handle Source Documents</h3> <h4>Research documents</h4> <p>If one or more research documents were selected in step 3a, ask <strong>for each one</strong>:</p> <p><strong>Question:</strong> "The research doc <code>claude/research/<path></code> was used. What should happen to it?" <strong>Header:</strong> "Research doc" <strong>Options:</strong></p> <ul> <li><code>Mark as concluded (Recommended)</code> (description: "Keep in research/, set status to 'Moved to design', add cross-ref to the design doc")</li> <li><code>Archive it</code> (description: "Move to claude/archive/")</li> <li><code>Leave as-is</code> (description: "Don't change the research doc at all")</li> </ul> <p><strong>If "Mark as concluded":</strong></p> <ul> <li>Update the research doc's front matter: set <code>**Status:**</code> to <code>Moved to design</code></li> <li>Add (or update) a reference at the bottom:<pre><code class="language-markdown">- **Design doc:** `claude/design/<path>` (started <today>) </code></pre> </li> </ul> <p><strong>If "Archive it":</strong></p> <ul> <li>Move the file (or directory) to <code>claude/archive/</code> preserving its name</li> <li>Add a note at the top: <code>> **Archived:** Promoted to design -- see claude/design/<path></code></li> </ul> <p><strong>If "Leave as-is":</strong></p> <ul> <li>Do nothing.</li> </ul> <h4>Ideas documents</h4> <p>If one or more ideas documents were selected in step 3b, ask <strong>for each one</strong> (same options as <code>/start-research</code>):</p> <p><strong>Question:</strong> "The ideas doc <code>claude/ideas/<path></code> was used. What should happen to it?" <strong>Header:</strong> "Ideas doc" <strong>Options:</strong></p> <ul> <li><code>Archive it</code> (description: "Move to claude/archive/ -- the content lives on in the design doc")</li> <li><code>Keep and cross-reference</code> (description: "Leave in ideas/ but add a link pointing to the new design doc")</li> <li><code>Leave as-is</code> (description: "Don't change the ideas doc at all")</li> </ul> <p><strong>If "Archive it":</strong></p> <ul> <li>Move the file (or directory) to <code>claude/archive/</code> preserving its name</li> <li>Add a note at the top: <code>> **Archived:** Promoted to design -- see claude/design/<path></code></li> </ul> <p><strong>If "Keep and cross-reference":</strong></p> <ul> <li>Add to the ideas doc under <code>## Related</code>:<pre><code class="language-markdown">- **Design doc:** `claude/design/<path>` (started <today>) </code></pre> </li> </ul> <p><strong>If "Leave as-is":</strong></p> <ul> <li>Do nothing.</li> </ul> <h3>7. Update GitHub Issue</h3> <h4>Update Project Status to Ready</h4> <p>Get the project item ID and update Status to "Ready".</p> <p><strong>Project item lookup:</strong> Read <code>.claude/skills/_helpers.md</code> Section 2 for the robust patterns.</p> <pre><code class="language-bash"># Step 1: Find the item ID by piping directly to Python (no temp files) gh project item-list 7 --owner nockawa --limit 200 --format json 2>&1 | python3 -c " import json, sys items = json.load(sys.stdin)['items'] for item in items: if item.get('content', {}).get('number') == int(sys.argv[1]): print(item['id']) sys.exit(0) print('NOT_FOUND') " <issue_number> # Step 2: Update status field (using the item ID from step 1) gh project item-edit --project-id PVT_kwHOAud1ac4BNdCj --id <item_id> \ --field-id PVTSSF_lAHOAud1ac4BNdCjzg8cXYI \ --single-select-option-id 303600de # "Ready" </code></pre> <h4>Link Design Doc in Issue Body</h4> <p>Fetch the current issue body, append a "Related Documents" section (if not already present), or add to the existing one.</p> <p><strong>Step 1:</strong> The issue body was already fetched in step 1 via <code>mcp__GitHub__get_issue</code>.</p> <p><strong>Step 2:</strong> Modify the body to add the design doc link.</p> <p><strong>IMPORTANT:</strong> Always use absolute URLs in issue bodies -- relative paths break when viewed outside the repo (e.g., on the project board). See <code>.claude/skills/_helpers.md</code> rule #9.</p> <p><strong>Step 3:</strong> Update the issue body:</p> <p>Use <code>mcp__GitHub__update_issue</code> with:</p> <ul> <li>owner: <code>"nockawa"</code></li> <li>repo: <code>"Typhon"</code></li> <li>issue_number: <code><number></code></li> <li>body: <code>"<updated body with design doc link>"</code></li> </ul> <p>Example addition to append:</p> <pre><code class="language-markdown">- Design: [`claude/design/<path>`](https://github.com/nockawa/Typhon/blob/main/claude/design/<path>) </code></pre> <p>If the issue body already has a "Related Documents" section, append the design doc link to it instead of creating a new section. Preserve any existing links (e.g., a research doc link added by <code>/start-research</code>).</p> <h3>8. Report Summary</h3> <pre><code>Starting design for #<number>: <title> Design doc: claude/design/<path> -> Mode: Standard / Deep (directory with README.md + 01-overview.md) Status updated: <old> -> Ready Research used: claude/research/<path> -> Concluded / Archived / Left as-is (or "None") Ideas used: claude/ideas/<path> -> Archived / Cross-referenced / Left as-is (or "None -- started fresh") Ready to refine the design! </code></pre> <h2>Status Field Option IDs</h2> <p>For reference:</p> <ul> <li>Backlog: <code>11d8e01f</code></li> <li>Research: <code>6aea77c6</code></li> <li>Ready: <code>303600de</code></li> <li>In Progress: <code>a0a7aab6</code></li> <li>Review: <code>fadead67</code></li> <li>Done: <code>12503e99</code></li> </ul> <h2>Field Reference</h2> <h3>Project ID</h3> <ul> <li><code>PVT_kwHOAud1ac4BNdCj</code></li> </ul> <h3>Status Field</h3> <ul> <li>Field ID: <code>PVTSSF_lAHOAud1ac4BNdCjzg8cXYI</code></li> </ul> <h3>Priority Field</h3> <ul> <li>Field ID: <code>PVTSSF_lAHOAud1ac4BNdCjzg8c8uQ</code></li> </ul> <h3>Phase Field</h3> <ul> <li>Field ID: <code>PVTSSF_lAHOAud1ac4BNdCjzg8c8uU</code></li> </ul> <h3>Area Field</h3> <ul> <li>Field ID: <code>PVTSSF_lAHOAud1ac4BNdCjzg8cX_E</code></li> </ul> <h3>Estimate Field</h3> <ul> <li>Field ID: <code>PVTSSF_lAHOAud1ac4BNdCjzg8cYEU</code></li> </ul> </article> </div> <!-- Right: Metadata & Command Sidebar --> <div class="w-full lg:w-80 shrink-0 flex flex-col gap-6" data-astro-cid-7zzsworf> <!-- Install Card --> <div class="p-6 rounded-xl bg-surface-container border border-border/80 flex flex-col gap-4 shadow-sm" data-astro-cid-7zzsworf> <span class="text-xs font-bold uppercase tracking-widest text-on-surface-variant/60 font-mono" data-astro-cid-7zzsworf>Install via CLI</span> <div class="flex flex-col gap-2" data-astro-cid-7zzsworf> <div id="detail-install-cmd" class="font-mono text-[11px] p-3 rounded-lg bg-black/40 border border-border select-all break-all text-primary font-bold leading-relaxed" data-astro-cid-7zzsworf> npx skills add https://github.com/nockawa/Typhon --skill start-design </div> <button id="detail-copy-btn" class="w-full py-2.5 rounded-lg bg-primary hover:bg-primary-hover text-on-primary font-sans font-bold text-sm shadow transition-all active:scale-95 flex items-center justify-center gap-1.5" data-astro-cid-7zzsworf> <span class="material-symbols-outlined text-[16px]" data-astro-cid-7zzsworf>content_copy</span> <span data-astro-cid-7zzsworf>Copy Command</span> </button> </div> </div> <!-- Details & Stats Card --> <div class="p-6 rounded-xl bg-surface-container border border-border/80 flex flex-col gap-4 shadow-sm text-on-surface" data-astro-cid-7zzsworf> <span class="text-xs font-bold uppercase tracking-widest text-on-surface-variant/60 font-sans" data-astro-cid-7zzsworf>Repository Details</span> <div class="flex flex-col gap-3.5" data-astro-cid-7zzsworf> <div class="flex justify-between items-center text-sm" data-astro-cid-7zzsworf> <span class="text-on-surface-variant/70 flex items-center gap-1.5" data-astro-cid-7zzsworf> <span class="material-symbols-outlined text-[16px] text-on-surface-variant/60" data-astro-cid-7zzsworf>star</span> Stars </span> <span class="font-mono font-bold text-on-surface" data-astro-cid-7zzsworf>224</span> </div> <div class="flex justify-between items-center text-sm" data-astro-cid-7zzsworf> <span class="text-on-surface-variant/70 flex items-center gap-1.5" data-astro-cid-7zzsworf> <span class="material-symbols-outlined text-[16px] text-on-surface-variant/60" data-astro-cid-7zzsworf>call_split</span> Forks </span> <span class="font-mono font-bold text-on-surface" data-astro-cid-7zzsworf>13</span> </div> <div class="flex justify-between items-center text-sm" data-astro-cid-7zzsworf> <span class="text-on-surface-variant/70 flex items-center gap-1.5" data-astro-cid-7zzsworf> <span class="material-symbols-outlined text-[16px] text-on-surface-variant/60" data-astro-cid-7zzsworf>navigation</span> Branch </span> <span class="font-mono bg-surface border border-border px-2 py-0.5 rounded text-[11px] text-on-surface-variant" data-astro-cid-7zzsworf>main</span> </div> <div class="flex justify-between items-start text-sm" data-astro-cid-7zzsworf> <span class="text-on-surface-variant/70 flex items-center gap-1.5 mt-0.5" data-astro-cid-7zzsworf> <span class="material-symbols-outlined text-[16px] text-on-surface-variant/60" data-astro-cid-7zzsworf>article</span> Path </span> <span class="font-mono bg-surface border border-border px-2 py-0.5 rounded text-[11px] text-on-surface-variant truncate max-w-[150px]" title="SKILL.md" data-astro-cid-7zzsworf>SKILL.md</span> </div> </div> </div> <!-- Occupations Tag Card --> <!-- Related Creators Card --> <div class="p-6 rounded-xl bg-surface-container border border-border/80 flex flex-col gap-3 shadow-sm" data-astro-cid-7zzsworf> <span class="text-xs font-bold uppercase tracking-widest text-on-surface-variant/60 font-sans" data-astro-cid-7zzsworf>More from Creator</span> <div class="flex items-center gap-2" data-astro-cid-7zzsworf> <img class="w-8 h-8 rounded-full border border-border" src="https://avatars.githubusercontent.com/u/48723305?u=bfe407b62757a154e8b1baa41115ccbf09e15103&v=4" alt="nockawa" onerror="this.src='https://avatars.githubusercontent.com/u/9919?v=4'" data-astro-cid-7zzsworf> <div class="flex flex-col min-w-0" data-astro-cid-7zzsworf> <span class="font-bold text-sm truncate text-on-surface" data-astro-cid-7zzsworf>nockawa</span> <a href="/?creator=nockawa" class="text-xs text-primary hover:underline font-semibold transition-all" data-astro-cid-7zzsworf>Explore all skills →</a> </div> </div> </div> </div> </div> </div> </div> <script> const copyBtn = document.getElementById("detail-copy-btn"); const installCmd = document.getElementById("detail-install-cmd"); if (copyBtn && installCmd) { copyBtn.addEventListener("click", () => { const cmd = installCmd.textContent.trim(); navigator.clipboard.writeText(cmd).then(() => { const originalText = copyBtn.innerHTML; copyBtn.innerHTML = ` <span class="material-symbols-outlined text-[16px]">check</span> <span>Copied!</span> `; copyBtn.style.background = "#10b981"; copyBtn.style.borderColor = "#10b981"; setTimeout(() => { copyBtn.innerHTML = originalText; copyBtn.style.background = ""; copyBtn.style.borderColor = ""; }, 1500); }); }); } </script> </div> <!-- Footer --> <footer class="border-t border-border bg-surface-container-low text-on-surface-variant py-8 px-gutter mt-16 rounded-xl"> <div class="max-w-container-max mx-auto flex flex-col md:flex-row justify-between items-center gap-6"> <div class="flex items-center gap-2"> <div class="w-6 h-6 rounded bg-primary bg-opacity-20 flex items-center justify-center"> <span class="material-symbols-outlined text-primary text-sm">code_blocks</span> </div> <span class="font-bold text-on-surface text-sm">SkillMD</span> </div> <div class="flex flex-wrap justify-center gap-6 text-sm"> <a href="/about" class="hover:text-primary transition-colors">About Us</a> <a href="/contact" class="hover:text-primary transition-colors">Contact Us</a> <a href="/privacy" class="hover:text-primary transition-colors">Privacy Policy</a> <a href="/terms" class="hover:text-primary transition-colors">Terms of Service</a> <a href="/support" class="hover:text-primary transition-colors">Support</a> </div> <div class="text-xs text-on-surface-variant/80"> © 2026 SkillMD. All rights reserved. </div> </div> </footer> </main> <!-- Script for Theme Toggle, Mobile Menu, and Sidebar Filter Redirection --> <script> // Theme setup const savedTheme = localStorage.getItem("theme") || "dark"; function applyTheme(theme) { document.documentElement.classList.remove("dark", "green", "dracula", "nord"); if (theme === "dark") { document.documentElement.classList.add("dark"); } else if (theme === "green") { document.documentElement.classList.add("dark", "green"); } else if (theme === "dracula") { document.documentElement.classList.add("dark", "dracula"); } else if (theme === "nord") { document.documentElement.classList.add("dark", "nord"); } document.documentElement.setAttribute("data-theme", theme); const themeMoon = document.getElementById("theme-moon"); const themeSun = document.getElementById("theme-sun"); const themeLeaf = document.getElementById("theme-leaf"); const themeDracula = document.getElementById("theme-dracula"); const themeNord = document.getElementById("theme-nord"); if (themeMoon && themeSun && themeLeaf && themeDracula && themeNord) { themeMoon.style.display = theme === "dark" ? "inline" : "none"; themeSun.style.display = theme === "light" ? "inline" : "none"; themeLeaf.style.display = theme === "green" ? "inline" : "none"; themeDracula.style.display = theme === "dracula" ? "inline" : "none"; themeNord.style.display = theme === "nord" ? "inline" : "none"; } } applyTheme(savedTheme); const themeToggleBtn = document.getElementById("theme-toggle-btn"); if (themeToggleBtn) { themeToggleBtn.addEventListener("click", () => { const currentTheme = document.documentElement.getAttribute("data-theme") || "dark"; let newTheme = "dark"; if (currentTheme === "dark") { newTheme = "light"; } else if (currentTheme === "light") { newTheme = "green"; } else if (currentTheme === "green") { newTheme = "dracula"; } else if (currentTheme === "dracula") { newTheme = "nord"; } else { newTheme = "dark"; } applyTheme(newTheme); localStorage.setItem("theme", newTheme); }); } // Mobile menu toggle and sidebar logic const mobileMenuToggle = document.getElementById("mobile-menu-toggle"); const sidebarMenu = document.getElementById("sidebar-menu"); const sidebarOverlay = document.getElementById("sidebar-overlay"); function isMobile() { return window.innerWidth < 768; // 768px is the 'md' breakpoint in Tailwind } function openSidebar() { if (sidebarMenu) { sidebarMenu.classList.remove("-translate-x-full"); } if (sidebarOverlay) { sidebarOverlay.classList.remove("hidden"); } } function closeSidebar() { if (sidebarMenu && isMobile()) { sidebarMenu.classList.add("-translate-x-full"); } if (sidebarOverlay) { sidebarOverlay.classList.add("hidden"); } } if (mobileMenuToggle && sidebarMenu) { mobileMenuToggle.addEventListener("click", (e) => { e.stopPropagation(); if (isMobile()) { const isClosed = sidebarMenu.classList.contains("-translate-x-full"); if (isClosed) { openSidebar(); } else { closeSidebar(); } } }); document.addEventListener("click", (e) => { if (isMobile()) { if (!sidebarMenu.contains(e.target) && !mobileMenuToggle.contains(e.target)) { closeSidebar(); } } }); if (sidebarOverlay) { sidebarOverlay.addEventListener("click", () => { if (isMobile()) { closeSidebar(); } }); } // Collapse sidebar when clicking a filter button, creator button, or nav item inside it sidebarMenu.addEventListener("click", (e) => { if (isMobile()) { const clickTarget = e.target.closest("button, a"); if (clickTarget) { closeSidebar(); } } }); // Sync sidebar state on window resize window.addEventListener("resize", () => { if (!isMobile()) { // Desktop: sidebar should be visible, no overlay if (sidebarMenu) { sidebarMenu.classList.remove("-translate-x-full"); } if (sidebarOverlay) { sidebarOverlay.classList.add("hidden"); } } else { // Mobile: start collapsed if (sidebarMenu) { sidebarMenu.classList.add("-translate-x-full"); } if (sidebarOverlay) { sidebarOverlay.classList.add("hidden"); } } }); } // If not on homepage, redirect on sidebar filter click const isHomepage = window.location.pathname === "/"; document.querySelectorAll("#occupation-filters .filter-btn").forEach(btn => { btn.addEventListener("click", (e) => { const occ = e.currentTarget.getAttribute("data-occupation"); if (!isHomepage) { window.location.href = occ ? `/?occupation=${encodeURIComponent(occ)}` : "/"; } }); }); document.querySelectorAll("#creator-filters .creator-btn").forEach(btn => { btn.addEventListener("click", (e) => { const creator = e.currentTarget.getAttribute("data-creator"); if (!isHomepage) { window.location.href = `/?creator=${encodeURIComponent(creator)}`; } }); }); </script> </body> </html>