@pincast/placecard-kit, that puts a person’s cards on a table they can sort, filter and flip. Your server fetches the cards and your key stays there. The kit only draws what it’s handed.
These steps build a small app called Lantern Walk with Vite and Vue. It runs on sample cards until you add a key.
Install
You need Node 20.12 or later. Work in an empty folder, or in thelantern-walk folder if you built Your first collect:
Save your set
GET /sets/{set} answers with a set’s name and counts, without its cards, so your app keeps its own copy of what it sent to PUT /sets/{set}. Save this one as data/set.json:
data/set.json
Add the server route
This file reads one person’s collects with your key and turns them into the collection the table draws.cardsRoute takes that person as its third argument. Save it as server/cards.js:
server/cards.js
ttFromAppSet marks the cards in the collects as held. The rest of the set waits under the Missing chip. A retired card shows only to a person who holds it, and an experience card never shows. null means no one is signed in. The table then shows 0 cards and a Your first card tile, with no chips, as it does for a person who holds nothing yet.
Draw the table
The config goes insrc/tabletop.js:
src/tabletop.js
facesdeclares every face your cards take.lanternis this app’s own, drawn by the kit’sdestinationface.theme.classgoes on the table, over the kit’s Card room theme.fonts: []means the page loads no outside fonts.handnames where the kit stores a person’s hand of cards: localStorage, unless you pass a store.
src/main.js. ttHtmlLock stops the page scrolling behind an open card:
src/main.js
src/cards.css, under its data-face:
src/cards.css
vite.config.js
index.html
.gitignore
/. To change its words or its address, add links: { back: { label: 'Home', href: '/' } } to the config.
npx vite has no sign-in, and it runs on a different port from the :3000 address you registered. It shows the sample cards or, once you add a key, the one test person in PINCAST_ACTOR. With the .env from Your first collect, it has a key and no test person, so the table starts empty.
Go live
Every key is live, so what you write with one is real (Test and live). To ask for a key, write to andrew@pincast.fm. If you built Your first collect, your key and set are already in place. Skip to Show the table to the person who signed in.-
Change
lantern-walkto your app’s id inserver/cards.jsandsrc/tabletop.js. It’s the part of your key betweenpck_and the next underscore. -
Put your key in a file named
.env, next topackage.json, with the API’s address and one test person fornpx viteto show. Git ignores it:.env -
Register the set. Its
meta.listedisfalse, so it stays off the Placecard map and front page: -
Record one collect for that guest:
-
Restart
npx vite. The table now shows that guest’s one card, with the other two under Missing.
Show the table to the person who signed in
Your first collect ends with a server that knows who signed in. Serve the table from that server and hand it the session’s person. It runs onhttp://localhost:3000, the address your sign-in client allows, so sign-in and the table share one cookie. Work in the lantern-walk folder, with the files above beside server.mjs.
-
Change
lantern-walkto your app’s id inserver/cards.jsandsrc/tabletop.js. If you registered a scratch set, changeold-town-lanternsin both files too. -
Build the table into
dist: -
Save the table’s routes as
server/table.js:server/table.js -
Add one import at the top of
server.mjs: -
In the request handler at the bottom of
server.mjs, add one line aboveres.writeHead(404).end(): -
Stop the server if it’s running, and start it again:
/table lands on /, where they can sign in.
Run npx vite build again after you change anything in src, and restart the server after you change anything in server.
In production, do the same on your own server: pass cardsRoute the person from your session, and run it from the project folder, where it reads data/set.json and dist.
Test it with the kit’s conformance suite
ttConformance checks your config, your collection, your theme’s tokens, your class names and the table’s markup at phone and laptop widths. Install what it needs:
test/conformance.test.js
test/goldens. Read it and commit it, and later runs compare against it. A new app id, theme or face changes that markup, so write it again when you make one:
When something goes wrong
The kit’s contract lists every config key, face, theme token and event.