diff --git a/PROGRESS.md b/PROGRESS.md index 83aaa30..65925bc 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -81,23 +81,20 @@ Replaced floating toast/flash messages with inline feedback and persistent top b | 6 | Migrate setup wizard notifications | 1h | done | | 7 | Remove old flash/toast CSS and JS | 30m | done | -### Live site editor ([plan](docs/plans/live-site-editor.md)) +### Unified on-site editing ([plan](docs/plans/unified-editing-mode.md)) -On-site editing overlay for admins: browse the real shop with a sidebar for theme and page editing. Inline contenteditable for text, live CSS variable injection for theme changes. Responsive layout (split view on desktop, overlay on mobile). +Extend the existing page editor (PageEditorHook + editor_sheet) to include theme editing. Admin clicks "Theme" → taken to actual shop with a 3-tab panel (Page | Theme | Settings). See changes live on the real site instead of a fake preview. | Phase | Description | Est | Status | |---|---|---|---| -| 1 | Design: sketch approaches, pick one | 2h | planned | -| 2 | Extract shared components from theme editor and page editor | 4h | planned | -| 3 | Build editor wrapper LiveView with sidebar shell | 3h | planned | -| 4 | Theme editing in sidebar (re-use theme controls, live CSS vars) | 3h | planned | -| 5 | Block list and block settings in sidebar | 3h | planned | -| 6 | Block selection: click-to-select with highlight on page | 2h | planned | -| 7 | Inline text editing with contenteditable + phx-hook | 4h | planned | -| 8 | Responsive layout (split view / overlay) | 2h | planned | -| 9 | Save/discard/undo flow | 2h | planned | -| 10 | Edit mode toggle (floating button for admins on shop pages) | 1h | planned | -| 11 | Polish and testing | 4h | planned | +| 1 | Add theme editing state to PageEditorHook | 2h | planned | +| 2 | Add 3-tab UI to editor panel (Page/Theme/Settings) | 2h | planned | +| 3 | Extract theme editor into reusable component | 3h | planned | +| 3b | Create settings editor component | 2h | planned | +| 4 | Image upload handling in hook context | 2h | planned | +| 5 | URL-based mode activation (?edit=theme) | 1h | planned | +| 6 | Admin routing redirect | 30m | planned | +| 7 | Polish and testing | 2h | planned | ### Quick fixes (from usability testing) @@ -149,6 +146,7 @@ All plans in [docs/plans/](docs/plans/). Completed plans are kept as architectur | [url-redirects.md](docs/plans/url-redirects.md) | Complete | | [onboarding-ux.md](docs/plans/onboarding-ux.md) | Planned (v2) | | [notification-overhaul.md](docs/plans/notification-overhaul.md) | Planned | -| [live-site-editor.md](docs/plans/live-site-editor.md) | Design exploration | +| [live-site-editor.md](docs/plans/live-site-editor.md) | Superseded by unified-editing-mode | +| [unified-editing-mode.md](docs/plans/unified-editing-mode.md) | Planned | | [profit-aware-pricing.md](docs/plans/profit-aware-pricing.md) | Planned | | [security-hardening.md](docs/plans/security-hardening.md) | Planned | diff --git a/docs/plans/unified-editing-mode.md b/docs/plans/unified-editing-mode.md new file mode 100644 index 0000000..08fe112 --- /dev/null +++ b/docs/plans/unified-editing-mode.md @@ -0,0 +1,270 @@ +# Unified On-Site Editing Mode + +Status: Planned + +Replace the separate admin theme editor (`/admin/theme`) with an on-site editing experience. When the admin clicks "Theme" or "Edit page", they're taken to the actual shop where a sliding panel allows them to edit either page content or theme settings — seeing changes live on the real site. + +## Current Architecture + +The codebase already has a robust pattern for on-site editing via the **PageEditorHook**: + +- `PageEditorHook` attaches to all shop pages, initializing ~15 editor-related assigns +- `editor_sheet` component in `ShopComponents.Layout` renders a FAB + sliding panel +- `PageRenderer` conditionally renders editor UI when `@is_admin` is true +- Changes preview instantly; state persists across the session + +The theme editor currently lives at `/admin/theme` with its own LiveView and fake preview. + +## Approach + +**Extend the existing editor infrastructure** to support both page editing and theme editing: + +1. Add theme editing state to the existing hook system +2. Add a tab switcher to the editor panel (Page | Theme | Settings) +3. Extract theme editor UI into a reusable component +4. Route `/admin/theme` to shop homepage with `?edit=theme` param + +## User Flow + +1. Admin clicks "Theme" in admin sidebar → redirects to `/?edit=theme` +2. Shop homepage loads with theme editing panel open +3. Admin can switch between "Page", "Theme", and "Settings" tabs +4. Admin can navigate to other shop pages while keeping editor open +5. "Done" or "×" button returns to admin or closes panel + +## Files to Modify + +| File | Change | +|------|--------| +| `lib/berrypod_web/page_editor_hook.ex` | Add theme/settings editing assigns, tab state, event handlers | +| `lib/berrypod_web/page_renderer.ex` | Add tab UI to editor_sheet, dispatch to theme/page/settings content | +| `lib/berrypod_web/components/shop_components/layout.ex` | Update editor_sheet for 3-tab support, add new keys to layout_keys | +| `lib/berrypod_web/components/shop_components/theme_editor.ex` | **New** - Extracted theme editor panel component | +| `lib/berrypod_web/components/shop_components/settings_editor.ex` | **New** - Page/shop settings panel component | +| `lib/berrypod_web/router.ex` | Redirect /admin/theme to /?edit=theme | +| `assets/css/shop/editor.css` | **New** - Editor panel styling (extract from admin) | +| `assets/js/hooks/theme_editor.js` | **New** - ColorSync and other theme editor hooks | + +## Implementation + +### Phase 1: Theme Editor Hook Integration + +Add theme editing state to `PageEditorHook`: + +```elixir +# New assigns in on_mount +:theme_editing -> false +:theme_settings -> nil (loaded when theme_editing activates) +:theme_active_preset -> nil +:theme_logo_image -> nil +:theme_header_image -> nil +:theme_icon_image -> nil +:theme_contrast_warning -> :ok +:theme_customise_open -> false + +# New event handlers +"theme_*" events -> handled by attach_hook similar to editor_* events +``` + +### Phase 2: Editor Panel Tabs + +Add three tabs to the editor panel: + +| Tab | Content | When available | +|-----|---------|----------------| +| **Page** | Block editor for custom pages | Only on editable pages (home, about, custom CMS pages) | +| **Theme** | Global styles, mood, typography, branding | Always | +| **Settings** | Page-specific settings (SEO, slug) or global shop settings | Always (content varies by page) | + +Update `editor_sheet` component: + +```heex +