From ea7ec61377f1f7811407aea5767b32cbe54e5933 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 25 Jun 2025 22:12:16 -0400 Subject: [PATCH] refactor: extract BaseDropdown component to reduce duplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create BaseDropdown with shared dropdown logic: - Toggle state management - Click outside handling - Dropdown positioning - Trigger and dropdown slots - Refactor StatusDropdown and PublishDropdown to use BaseDropdown - Reduce code duplication by ~80 lines - Maintain all existing functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- prd/PRD-codebase-cleanup-refactoring.md | 2 +- src/lib/components/admin/BaseDropdown.svelte | 96 +++++++++++++++++ .../components/admin/PublishDropdown.svelte | 72 +++---------- .../components/admin/StatusDropdown.svelte | 102 ++++++------------ 4 files changed, 141 insertions(+), 131 deletions(-) create mode 100644 src/lib/components/admin/BaseDropdown.svelte diff --git a/prd/PRD-codebase-cleanup-refactoring.md b/prd/PRD-codebase-cleanup-refactoring.md index 79adf9d..c58cc5d 100644 --- a/prd/PRD-codebase-cleanup-refactoring.md +++ b/prd/PRD-codebase-cleanup-refactoring.md @@ -96,7 +96,7 @@ Refactor components to reduce duplication and complexity. - [-] **Create base components** - [x] Extract `BaseModal` component for shared modal logic - - [ ] Create `BaseDropdown` for dropdown patterns + - [x] Create `BaseDropdown` for dropdown patterns - [ ] Merge `FormField` and `FormFieldWrapper` - [ ] Create `BaseSegmentedController` for shared logic diff --git a/src/lib/components/admin/BaseDropdown.svelte b/src/lib/components/admin/BaseDropdown.svelte new file mode 100644 index 0000000..25abd9d --- /dev/null +++ b/src/lib/components/admin/BaseDropdown.svelte @@ -0,0 +1,96 @@ + + + + + \ No newline at end of file diff --git a/src/lib/components/admin/PublishDropdown.svelte b/src/lib/components/admin/PublishDropdown.svelte index 679aa8e..d6d0319 100644 --- a/src/lib/components/admin/PublishDropdown.svelte +++ b/src/lib/components/admin/PublishDropdown.svelte @@ -1,6 +1,6 @@ -
+ - - {#if isDropdownOpen} - - - {saveDraftText} - - - {/if} +
+ + {saveDraftText} + +
{/if} -
- - + \ No newline at end of file diff --git a/src/lib/components/admin/StatusDropdown.svelte b/src/lib/components/admin/StatusDropdown.svelte index 93726bb..f69f32d 100644 --- a/src/lib/components/admin/StatusDropdown.svelte +++ b/src/lib/components/admin/StatusDropdown.svelte @@ -1,6 +1,6 @@ -
+ - - {#if isDropdownOpen} - - {#each availableActions as action} - handleDropdownAction(action.status)}> - {action.label} - - {/each} - {#if showViewInDropdown} - {#if availableActions.length > 0} - - {/if} - - View on site - +
+ {#each availableActions as action} + handleDropdownAction(action.status)}> + {action.label} + + {/each} + {#if showViewInDropdown} + {#if availableActions.length > 0} + {/if} - - {/if} + + View on site + + {/if} +
{/if} -
+ + \ No newline at end of file