diff options
Diffstat (limited to 'examples/ssr/src/components/Cart.svelte')
-rw-r--r-- | examples/ssr/src/components/Cart.svelte | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/ssr/src/components/Cart.svelte b/examples/ssr/src/components/Cart.svelte new file mode 100644 index 000000000..5d4b7d251 --- /dev/null +++ b/examples/ssr/src/components/Cart.svelte @@ -0,0 +1,34 @@ +<script> + let { count } = $props() + let items = new Set(); + + function onAddToCart(ev) { + const id = ev.detail; + items.add(id); + count++; + } +</script> +<style> + .cart { + display: flex; + align-items: center; + text-decoration: none; + color: inherit; + } + .cart :first-child { + margin-right: 5px; + } + + .cart-icon { + font-size: 36px; + } + + .count { + font-size: 24px; + } +</style> +<svelte:window onadd-to-cart={onAddToCart}/> +<a href="/cart" class="cart"> + <span class="material-icons cart-icon">shopping_cart</span> + <span class="count">{count}</span> +</a> |