[ci] format
This commit is contained in:
parent
faf3f3a8d1
commit
c8ca528bba
4 changed files with 8 additions and 13 deletions
|
@ -7,7 +7,7 @@ export type CartItem = {
|
|||
name: string;
|
||||
imageSrc: string;
|
||||
quantity: number;
|
||||
}
|
||||
};
|
||||
|
||||
export type CartItemDisplayInfo = Pick<CartItem, 'id' | 'name' | 'imageSrc'>;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import type { ComponentChildren } from 'preact';
|
|||
type Props = {
|
||||
item: CartItemDisplayInfo;
|
||||
children: ComponentChildren;
|
||||
}
|
||||
};
|
||||
|
||||
export default function AddToCartForm({ item, children }: Props) {
|
||||
function addToCart(e: SubmitEvent) {
|
||||
|
@ -14,9 +14,5 @@ export default function AddToCartForm({ item, children }: Props) {
|
|||
addCartItem(item);
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={addToCart}>
|
||||
{children}
|
||||
</form>
|
||||
)
|
||||
return <form onSubmit={addToCart}>{children}</form>;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ export default function CartFlyout() {
|
|||
<aside hidden={!$isCartOpen} className={styles.container}>
|
||||
{Object.values($cartItems).length ? (
|
||||
<ul className={styles.list} role="list">
|
||||
{Object.values($cartItems).map(cartItem => (
|
||||
{Object.values($cartItems).map((cartItem) => (
|
||||
<li className={styles.listItem}>
|
||||
<img className={styles.listItemImg} src={cartItem.imageSrc} alt={cartItem.name} />
|
||||
<div>
|
||||
|
@ -20,7 +20,9 @@ export default function CartFlyout() {
|
|||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p>Your cart is empty!</p>}
|
||||
) : (
|
||||
<p>Your cart is empty!</p>
|
||||
)}
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import { useStore } from '@nanostores/preact';
|
||||
import { isCartOpen } from '../cartStore';
|
||||
|
||||
|
||||
export default function CartFlyoutToggle() {
|
||||
const $isCartOpen = useStore(isCartOpen);
|
||||
return (
|
||||
<button onClick={() => isCartOpen.set(!$isCartOpen)}>Cart</button>
|
||||
)
|
||||
return <button onClick={() => isCartOpen.set(!$isCartOpen)}>Cart</button>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue