feat: add cart page, cart drawer, and shared cart infrastructure

- Cart context with pure functions for add/remove/update/hydrate
- Price formatting via ex_money (replaces all float division)
- CartHook on_mount with attach_hook for shared event handlers
  (open/close drawer, remove item, PubSub sync)
- Accessible cart drawer with focus trap, scroll lock, aria-live
- Cart page with increment/decrement quantity controls
- Preview mode cart drawer support in theme editor
- Cart persistence to session via JS hook + API endpoint
- 19 tests covering all Cart pure functions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-05 22:11:16 +00:00
parent 880e7a2888
commit 1bc08bfb23
27 changed files with 1163 additions and 155 deletions

View File

@@ -10,15 +10,16 @@
- Shop pages (home, collections, products, cart, about, contact)
- Mobile-first design with bottom navigation
- 100% PageSpeed score
- Variant selector with color swatches and size buttons
**In Progress:**
- Products context with provider integration (wired to shop views, variant selector next)
- Session-based cart
## Next Up
1. **Variant Selector Component** - Size/colour picker on product pages
2. **Session-based Cart** - Real cart with actual variants
3. **Stripe Checkout Integration** - Payment processing
1. **Session-based Cart** - Real cart with actual variants
2. **Stripe Checkout Integration** - Payment processing
3. **Orders & Fulfillment** - Submit orders to Printify
---
@@ -52,9 +53,8 @@
See: [docs/plans/image-optimization.md](docs/plans/image-optimization.md) for implementation details
### Products & Provider Integration
**Status:** In Progress
**Status:** Complete
#### Completed
- [x] Products context with schemas (c5c06d9)
- [x] Provider abstraction layer
- [x] Printify client integration
@@ -64,21 +64,16 @@ See: [docs/plans/image-optimization.md](docs/plans/image-optimization.md) for im
- [x] Slug-based fallback matching for changed provider IDs
- [x] Printify webhook endpoint with HMAC verification (a9c15ea)
- Note: Printify only supports `product:deleted` and `product:publish:*` events (no `product:updated`)
#### Remaining Tasks
- [ ] Add variant selector component (~2hr)
#### Recently Completed
- [x] Product image download pipeline
- [x] Product image download pipeline (1b49b47)
- Downloads Printify CDN images via ImageDownloadWorker
- Processes through Media pipeline (WebP conversion, AVIF/WebP variants)
- PreviewData uses local images for responsive `<picture>` elements
- sync_product_images preserves image_id when URL unchanged
- Startup recovery and `mix simpleshop.download_images` backfill
- [x] Wire shop LiveViews to Products context
- PreviewData now uses real products when available
- Fixed Printify image sync (position was string, not integer)
- Improved category extraction from Printify tags
- [x] Variant selector component (880e7a2)
- Color swatches with hex colors, size buttons
- Fixed Printify options parsing (Color/Size swap bug)
- Filters to only published variants (not full catalog)
- Price updates on variant change
- Startup recovery for stale sync status
#### Future Enhancements (post-MVP)
- [ ] Pre-checkout variant validation (verify availability before order)
@@ -124,9 +119,12 @@ See: [docs/plans/page-builder.md](docs/plans/page-builder.md) for design
| Feature | Commit | Notes |
|---------|--------|-------|
| Variant selector | 880e7a2 | Color swatches, size buttons, price updates |
| Product image download | 1b49b47 | PageSpeed 100% with local images |
| Wire shop to real data | c818d03 | PreviewData uses Products context |
| Printify webhooks | a9c15ea | Deletion + publish events |
| Products context Phase 1 | c5c06d9 | Schemas, provider abstraction |
| Admin provider setup UI | 5b736b9 | Connect, test, sync with pagination |
| Printify webhooks | a9c15ea | Deletion + publish events (no update event available) |
| Oban Lifeline plugin | c1e1988 | Rescue orphaned jobs |
| Image optimization | Multiple | Full pipeline complete |
| Self-hosted fonts | - | 10 typefaces, 728KB |