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:
@@ -32,19 +32,25 @@ defmodule SimpleshopTheme.Theme.PreviewData do
|
||||
|
||||
@doc """
|
||||
Returns cart drawer items formatted for the cart drawer component.
|
||||
|
||||
Format matches Cart.hydrate/1 output for consistency between preview and live modes.
|
||||
"""
|
||||
def cart_drawer_items do
|
||||
[
|
||||
%{
|
||||
variant_id: "preview-1",
|
||||
name: "Mountain Sunrise Art Print",
|
||||
variant: "12″ x 18″ / Matte",
|
||||
price: "£24.00",
|
||||
price: 2400,
|
||||
quantity: 1,
|
||||
image: "/mockups/mountain-sunrise-print-1.jpg"
|
||||
},
|
||||
%{
|
||||
variant_id: "preview-2",
|
||||
name: "Fern Leaf Mug",
|
||||
variant: "11oz / White",
|
||||
price: "£14.99",
|
||||
price: 1499,
|
||||
quantity: 2,
|
||||
image: "/mockups/fern-leaf-mug-1.jpg"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user