--- name: product-sdk-pocket-cards description: > Author, check and draw a Pocket card face in product-sdk. Use when: adding a card to the Polkadot app's Pocket tab, writing a card face in JSX, turning a component into a RendererNode, a card draws blank or is refused, wiring a worker that draws a live card, or writing the static preview face the approval sheet shows. Covers @parity/product-sdk-react-renderer (JSX components, createRenderer, drawPocketCard), @parity/product-sdk-renderer (validateFace, assertFaceValid, host limits) and @parity/product-sdk-host (getPocketManager, card list, removal). --- # Pocket cards A Pocket card is a face a product draws into the Polkadot app's Pocket tab. The product declares its cards in its **worker** manifest and answers the host whenever a card is on screen. | Package | Import | Purpose | |---------|--------|---------| | react-renderer | `@parity/product-sdk-react-renderer` | write the face in JSX, and draw it | | renderer | `@parity/product-sdk-renderer` | check it before it reaches a device | | host | `@parity/product-sdk-host` | reach the Pocket manager, list and remove cards | Worked example: `examples/pocket-card-example/`. ## The shape of the whole thing 1. The worker manifest declares the cards. `includes.pocket: true`, plus one entry per card: ```json { "$v": 1, "kind": "worker", "appVersion": [0, 1, 0], "entrypoint": "worker.js", "includes": { "pocket": true }, "pocket": { "cards": [{ "id": "loyalty", "title": "Loyalty", "preview": "pocket/partial.json" }] } } ``` 2. `preview` is a path inside the worker archive to a face written as JSON. The host draws it in the approval sheet, before any of your code runs. 3. Once the card is added, the host asks the worker for a face whenever the card is on screen. **The `id` in the manifest must match the id the worker draws.** Get it wrong and the card silently keeps its static preview face, with nothing on the device saying why. ## Write a face Faces are authored in JSX. `@parity/product-sdk-renderer` has no builder functions, so anything that calls `column(...)` or `text(...)` is written against an API that no longer exists. ```tsx import { Button, Column, Row, Text } from "@parity/product-sdk-react-renderer"; interface LoyaltyFaceProps { stamps: number; goal: number; onStamp?(): void; } export function LoyaltyFace({ stamps, goal, onStamp }: LoyaltyFaceProps) { return ( Loyalty {`${stamps} of ${goal}`}