diff --git a/src/components/hand.ts b/src/components/hand.ts index b700cc0..a2bffa6 100644 --- a/src/components/hand.ts +++ b/src/components/hand.ts @@ -1,23 +1,29 @@ import { html } from 'lit-html' import { repeat } from 'lit-html/directives/repeat.js' +import { computed } from 'nanostores' +import { watch } from '#core/lit-nanostores/watch.ts' import type { GameCard } from '#lobo/card.ts' +import { toAtom, type MaybeAtom } from '#types/atom.ts' import { Card } from './card' -export function Hand(cards: GameCard[], handOwner: 'player' | 'wolf' = 'wolf') { +export function Hand(cards: MaybeAtom, handOwner: 'player' | 'wolf' = 'wolf') { + const renderedCards = computed( + [toAtom(cards)], + (cardList) => + html``, + ) return html`

${handOwner} cards

-
-
    - ${repeat( - cards, - (c) => c.id, - (c) => html`
  • ${Card(c)}
  • `, - )} -
-
+
${watch(renderedCards)}
` }