astro/examples/ssr/src/components/Cart.svelte
Matthew Phillips 4c25a1c2ea
Implements redirects, headers for SSR (#2798)
* Implements redirects, headers for SSR

* Move away from an explicit Request

* Properly handle endpoint routes in the build

* chore(lint): ESLint fix

* Update based on review comments

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-03-16 12:16:21 -04:00

34 lines
556 B
Svelte

<script>
export let count = 0;
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 on:add-to-cart={onAddToCart}/>
<a href="/cart" class="cart">
<span class="material-icons cart-icon">shopping_cart</span>
<span class="count">{count}</span>
</a>