Recipe: Workshop RSVP
A sign-up page for a workshop, a class or an event: each session is a card with its picture, time and place, a bar of the places taken, and two buttons, I'm going and Maybe, with an optional note for the organisers. A visitor gives their name the first time they answer, with no Playbook account, and can change or cancel their answer later. Nothing is written on the board: the answers are guest answers, and the organisers read them in Playbook. Light and dark themes follow the visitor's system, with a toggle.
When to use it
- Anyone with the link answers: a public workshop, an open studio, a team offsite, a tasting. Access is
publicand sign-up isopen: visitors type their name. - For a closed group, deploy it with
passwordinstead and keep"signup": "open": visitors pass the password, then give their name. To know exactly who answers, use"signup": "pin"and add each person (see the client approval recipe). - Open sign-up has no captcha: someone determined can sign up many times. Keep
per_assetand watch the Answers tab.
How the board drives it
- One asset per session. Its title is the card's title; its description holds the time, place and what to bring, one per line. Its picture is the card's image.
- The board's title and description are the page's heading and introduction.
playbook.jsondeclares the record actionrsvp(a choice ofGoingorMaybe, an optional note, at most 20 current answers per session) andcancel, which takes the guest's answer back. Both are below.- The organisers see each answer, with the guest's name and note, in Developer → Custom apps → Guests → Answers in Playbook, or with
list_app_answers.notify: trueemails the app's creator when answers come in, at most every 10 minutes.
Places are counted from the answers: GET playbook/guest/actions/rsvp/results returns each session's total and its count per choice, with no names, to any visitor. Going and Maybe both take a place, because per_asset counts every current answer.
The files
playbook.json:
{
"guests": { "signup": "open" },
"guest_actions": {
"rsvp": {
"label": "RSVP",
"record": true,
"input": { "choice": ["Going", "Maybe"], "note?": true },
"limit": { "per_asset": 20 },
"notify": true
},
"cancel": {
"label": "Cancel my RSVP",
"record": true,
"undoes": "rsvp"
}
}
}
index.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sessions</title>
<script>
// The visitor's theme, set before the page paints.
try { const theme = localStorage.getItem(`theme:${location.pathname}`); if (theme) document.documentElement.dataset.theme = theme } catch {}
</script>
<link rel="icon" href="data:," />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,[email protected],400;12..96,600;12..96,800&display=swap" />
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<header class="top">
<p class="who" id="who"></p>
<button type="button" class="theme" id="theme" aria-label="Switch between light and dark"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="8" fill="none" stroke="currentColor" stroke-width="1.8" /><path d="M12 4a8 8 0 0 1 0 16z" fill="currentColor" /></svg></button>
</header>
<section class="hero">
<h1 id="title">Loading…</h1>
<p class="subtitle" id="subtitle"></p>
</section>
<main class="sessions" id="sessions" aria-live="polite"></main>
<p class="notice" id="notice" hidden>The sessions did not load. Reload the page to try again.</p>
<dialog class="sheet" id="signup">
<form method="dialog" id="signup-form">
<h2>Who's coming?</h2>
<p>Your name goes on the list the organisers see. No account needed.</p>
<label for="signup-name">Your name</label>
<input id="signup-name" maxlength="80" autocomplete="name" required />
<p class="error" id="signup-error" role="alert"></p>
<div class="sheet-actions">
<button type="button" class="ghost" id="signup-cancel">Cancel</button>
<button type="submit" class="solid" id="signup-send">Continue</button>
</div>
</form>
</dialog>
<p class="toast" id="toast" role="status" hidden></p>
<script type="module" src="app.js"></script>
</body>
</html>
styles.css:
/* Light by default, dark when the system asks for it, and either one when the
visitor picks it (data-theme on <html>, set by the toggle). */
:root {
color-scheme: light;
--bg: #f3f5f7;
--card: #ffffff;
--ink: #101418;
--soft: #46505a;
--muted: #76808a;
--line: rgba(16, 20, 24, 0.1);
--field: #f3f5f7;
--going: #0b7a55;
--on-going: #ffffff;
--maybe: #b86e00;
--full: #c2352b;
--shadow: rgba(16, 20, 24, 0.08);
--focus: rgba(11, 122, 85, 0.55);
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme='light']) {
color-scheme: dark;
--bg: #0d1013; --card: #161a1f; --ink: #eef1f4; --soft: #c0c7ce; --muted: #8b949d; --line: rgba(255, 255, 255, 0.1);
--field: #0d1013; --going: #3fd19b; --on-going: #04241a; --maybe: #f2b34c; --full: #ff7a6e; --shadow: rgba(0, 0, 0, 0.4); --focus: rgba(63, 209, 155, 0.6);
}
}
:root[data-theme='dark'] {
color-scheme: dark;
--bg: #0d1013; --card: #161a1f; --ink: #eef1f4; --soft: #c0c7ce; --muted: #8b949d; --line: rgba(255, 255, 255, 0.1);
--field: #0d1013; --going: #3fd19b; --on-going: #04241a; --maybe: #f2b34c; --full: #ff7a6e; --shadow: rgba(0, 0, 0, 0.4); --focus: rgba(63, 209, 155, 0.6);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 16px/1.5 'Bricolage Grotesque', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.solid, .ghost, .choice { min-height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 600; white-space: nowrap; }
.solid { border: 0; background: var(--ink); color: var(--bg); }
.ghost { border: 1px solid var(--line); background: none; }
.solid:disabled, .ghost:disabled, .choice:disabled { opacity: 0.5; cursor: default; }
.link { padding: 0; border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.theme { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--soft); }
.theme svg { width: 16px; height: 16px; }
.top { display: flex; justify-content: flex-end; align-items: center; gap: 14px; max-width: 1080px; margin: 0 auto; padding: 20px 24px 0; }
.who { margin: 0; color: var(--muted); font-size: 14px; }
.who b { color: var(--ink); font-weight: 600; }
.hero { max-width: 1080px; margin: 0 auto; padding: 48px 24px 32px; }
h1 { max-width: 16ch; margin: 0; font-size: clamp(40px, 7vw, 80px); font-weight: 800; line-height: 0.95; letter-spacing: -0.04em; }
.subtitle { max-width: 58ch; margin: 16px 0 0; color: var(--soft); font-size: 18px; white-space: pre-line; }
.subtitle:empty { display: none; }
.sessions { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; max-width: 1080px; margin: 0 auto; padding: 0 24px 72px; }
.session { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: 0 1px 2px var(--shadow); }
.session img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.session-body { display: flex; flex: 1; flex-direction: column; gap: 12px; padding: 18px 20px 20px; }
.session h2 { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.details { margin: 0; color: var(--soft); white-space: pre-line; }
.details:empty { display: none; }
.places { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 6px; font-size: 14px; color: var(--muted); }
.meter { flex: 1; height: 6px; overflow: hidden; border-radius: 99px; background: var(--line); }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--going); transition: width 0.4s ease; }
.places.is-full .meter i { background: var(--full); }
.places b { color: var(--ink); font-variant-numeric: tabular-nums; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { border: 1px solid var(--line); background: none; }
.choice[data-choice='Going'][aria-pressed='true'] { border-color: var(--going); background: var(--going); color: var(--on-going); }
.choice[data-choice='Maybe'][aria-pressed='true'] { border-color: var(--maybe); color: var(--maybe); }
.note { width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); outline: none; }
.note:focus { border-color: var(--focus); }
.mine { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin: 0; font-size: 14px; color: var(--soft); }
.error { margin: 0; color: var(--full); font-size: 14px; }
.error:empty { display: none; }
.empty, .notice { color: var(--muted); }
.notice { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.sheet { width: min(420px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: 0 30px 80px var(--shadow); }
.sheet::backdrop { background: rgba(10, 12, 14, 0.5); backdrop-filter: blur(4px); }
.sheet h2 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.sheet p { margin: 6px 0 18px; color: var(--soft); }
.sheet label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.sheet input { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); outline: none; }
.sheet input:focus { border-color: var(--focus); }
.sheet .error { margin-top: 10px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toast { position: fixed; z-index: 20; bottom: 24px; left: 50%; margin: 0; padding: 10px 18px; transform: translateX(-50%); border-radius: 99px; background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 600; }
@media (max-width: 640px) {
.top { padding: 14px 16px 0; }
.hero { padding: 28px 16px 24px; }
.sessions { grid-template-columns: 1fr; gap: 14px; padding: 0 16px 48px; }
.session-body { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { transition: none !important; }
}
app.js:
// Sessions of a workshop or an event, one asset each, open to anyone with the link
// (access `public`). Visitors sign up with their name and answer Going or Maybe,
// with an optional note: the record action `rsvp` in playbook.json. Nothing is
// written on the board; the organisers see the answers in Playbook.
const ACTION = 'rsvp'
const CANCEL = 'cancel'
const CAPACITY = 20 // limit.per_asset in playbook.json: Going and Maybe both take a place
const CHOICES = ['Going', 'Maybe']
const $ = (id) => document.getElementById(id)
const plain = (html) => new DOMParser().parseFromString(html || '', 'text/html').body.textContent.trim()
const el = (tag, className, text) => {
const node = document.createElement(tag)
if (className) node.className = className
if (text) node.textContent = text
return node
}
// Every call goes to the app's own address. Busy or cold reads (429, 5xx) are
// retried twice. A refusal throws its message, with its code and status.
async function call(path, { method = 'GET', body, tries = 3 } = {}) {
const response = await fetch(path, {
method,
headers: body ? { 'Content-Type': 'application/json' } : {},
body: body && JSON.stringify(body),
}).catch(() => null)
const status = response?.status ?? 0
if (method === 'GET' && tries > 1 && (status === 0 || status === 429 || status >= 500)) {
const wait = Number(response?.headers.get('Retry-After')) || 2
await new Promise((resolve) => setTimeout(resolve, wait * 1000))
return call(path, { method, body, tries: tries - 1 })
}
const answer = response ? await response.json().catch(() => ({})) : {}
if (response?.ok) return answer
throw Object.assign(new Error(answer.error || 'That did not go through. Try again.'), { code: answer.code, status })
}
let sessions = []
let me = null // the guest: { name, runs }, or null for a visitor who has not signed up
const counts = {} // by asset token: { total, choices: { Going: n, Maybe: n } }
const answers = {} // the guest's own answer by asset token: 'Going' or 'Maybe'
const errors = {}
const ZERO = { total: 0, choices: {} }
const countOf = (token) => counts[token] || ZERO
function toast(text) {
$('toast').textContent = text
$('toast').hidden = false
clearTimeout(toast.timer)
toast.timer = setTimeout(() => ($('toast').hidden = true), 2400)
}
// `runs` lists the guest's current runs of every action; keep this action's.
function setGuest(guest) {
me = guest
for (const token of Object.keys(answers)) delete answers[token]
for (const run of guest?.runs || []) if (run.action === ACTION) answers[run.asset] = run.choice
$('who').replaceChildren()
if (!me) return
const out = el('button', 'link', 'Not you?')
out.type = 'button'
out.addEventListener('click', signOut)
$('who').append('Answering as ', el('b', '', me.name), ' · ', out)
}
function placesLine(token) {
const { total, choices } = countOf(token)
const left = Math.max(CAPACITY - total, 0)
const line = el('div', `places${left ? '' : ' is-full'}`)
const meter = el('span', 'meter')
const fill = el('i')
fill.style.width = `${Math.min(total / CAPACITY, 1) * 100}%`
meter.append(fill)
const text = el('span')
text.append(el('b', '', String(choices.Going || 0)), ' going')
if (choices.Maybe) text.append(' · ', el('b', '', String(choices.Maybe)), ' maybe')
text.append(left ? ` · ${left} left` : ' · Full')
line.append(meter, text)
return line
}
function card(asset) {
const node = el('article', 'session')
node.dataset.token = asset.token
if (asset.thumbnails?.length) {
const image = el('img')
const thumbs = [...asset.thumbnails].sort((a, b) => a.width - b.width)
image.src = (thumbs.find((t) => t.width >= 640) || thumbs.at(-1)).url
image.alt = ''
image.loading = 'lazy'
image.style.backgroundColor = asset.average_color || ''
node.append(image)
}
const body = el('div', 'session-body')
body.append(el('h2', '', asset.title), el('p', 'details', plain(asset.description)), placesLine(asset.token))
const mine = answers[asset.token]
const full = countOf(asset.token).total >= CAPACITY
const choices = el('div', 'choices')
for (const choice of CHOICES) {
const button = el('button', 'choice', choice === 'Going' ? 'I’m going' : 'Maybe')
button.type = 'button'
button.dataset.choice = choice
button.setAttribute('aria-pressed', String(mine === choice))
// A full session still takes a change of answer from someone already on it.
button.disabled = full && !mine
button.addEventListener('click', () => answer(asset, choice, node.querySelector('.note').value.trim()))
choices.append(button)
}
const note = el('input', 'note')
note.placeholder = mine ? 'Change your note (optional)' : 'A note for the organisers (optional)'
note.maxLength = 500
note.setAttribute('aria-label', `A note about ${asset.title}`)
body.append(choices, note)
if (mine) {
const line = el('p', 'mine')
const cancel = el('button', 'link', 'Cancel my answer')
cancel.type = 'button'
cancel.addEventListener('click', () => withdraw(asset))
line.append(el('span', '', mine === 'Going' ? 'You’re going.' : 'You said maybe.'), cancel)
body.append(line)
} else if (full) {
body.append(el('p', 'mine', 'This session is full.'))
}
body.append(el('p', 'error', errors[asset.token] || ''))
node.append(body)
return node
}
function render() {
$('sessions').replaceChildren(
...(sessions.length ? sessions.map(card) : [el('p', 'empty', 'No sessions yet. Check back soon.')])
)
}
function rerender(asset) {
document.querySelector(`[data-token="${asset.token}"]`)?.replaceWith(card(asset))
}
// The sign-up sheet resolves with the guest, or null when the visitor closes it.
function signUp() {
return new Promise((resolve) => {
const sheet = $('signup')
$('signup-error').textContent = ''
sheet.onclose = () => resolve(me)
sheet.showModal()
$('signup-name').focus()
})
}
$('signup-form').addEventListener('submit', async (event) => {
event.preventDefault()
$('signup-send').disabled = true
$('signup-error').textContent = ''
try {
await call('playbook/guest', { method: 'POST', body: { name: $('signup-name').value.trim() } })
setGuest(await call('playbook/guest/me'))
$('signup').close()
} catch (error) {
$('signup-error').textContent = error.message
} finally {
$('signup-send').disabled = false
}
})
$('signup-cancel').addEventListener('click', () => $('signup').close())
async function signOut() {
await call('playbook/guest/signout', { method: 'POST', body: {} }).catch(() => {})
setGuest(null)
render()
}
async function run(asset, action, body, done) {
if (!me && !(await signUp())) return
delete errors[asset.token]
const node = document.querySelector(`[data-token="${asset.token}"]`)
node?.querySelectorAll('button').forEach((button) => (button.disabled = true))
try {
const result = await call(`playbook/guest/actions/${action}`, { method: 'POST', body: { asset: asset.token, ...body } })
// The answer carries the fresh counts: reads stay cached for minutes.
counts[asset.token] = result.counts || ZERO
done()
} catch (error) {
if (error.status === 401) {
// The pass ended: sign up again, then the visitor can retry.
setGuest(null)
render()
return
}
errors[asset.token] = error.code === 'full' ? 'This session just filled up.' : error.message
}
rerender(asset)
}
const answer = (asset, choice, note) =>
run(asset, ACTION, { choice, ...(note && { note }) }, () => {
answers[asset.token] = choice
toast(choice === 'Going' ? 'See you there' : 'Marked as maybe')
})
const withdraw = (asset) =>
run(asset, CANCEL, {}, () => {
delete answers[asset.token]
toast('Your answer is cancelled')
})
// Light or dark: the visitor's pick, kept per app, else the system's.
$('theme').addEventListener('click', () => {
const root = document.documentElement
const dark = root.dataset.theme ? root.dataset.theme === 'dark' : matchMedia('(prefers-color-scheme: dark)').matches
root.dataset.theme = dark ? 'light' : 'dark'
try {
localStorage.setItem(`theme:${location.pathname}`, root.dataset.theme)
} catch {}
})
async function allAssets() {
const all = []
for (let page = 1; ; page++) {
const { data, pagy } = await call(`playbook/api/assets?per_page=100&page=${page}`)
all.push(...data)
if (!pagy || pagy.current_page >= pagy.total_pages) return all
}
}
try {
const app = await call('playbook/app')
const [{ data: board }, assets, guest] = await Promise.all([
call(`playbook/api/boards/${app.board}`),
allAssets(),
call('playbook/guest/me').catch(() => null), // 401: not signed up yet
])
sessions = assets.filter((asset) => !asset.is_group)
// `results` takes at most 100 items at a time.
for (let start = 0; start < sessions.length; start += 100) {
const tokens = sessions.slice(start, start + 100).map((session) => session.token)
Object.assign(counts, await call(`playbook/guest/actions/${ACTION}/results?assets=${tokens.join(',')}`))
}
document.title = board.title
$('title').textContent = board.title
$('subtitle').textContent = plain(board.description)
setGuest(guest)
render()
} catch {
$('title').textContent = ''
$('notice').hidden = false
}
Make it yours
Change:
CHOICESinapp.jsandchoiceinplaybook.jsontogether: the same words, in the same spelling. The buttons' wording is incard().CAPACITYandlimit.per_assettogether. For sessions of different sizes, give each size its own app and board, or leave the limit out and show only the counts.- The sign-up sheet's words in
index.html: say what the name is used for. - Colours. The tokens at the top of
styles.css: the light set on:root, the dark set twice below it. Change both together. - Type. The Google Fonts link in
index.htmland thefontonbody.
Keep:
guests/meread once at load, and itsrunsfiltered torsvp: it lists the guest's current runs of every action.- The counts from each answer kept on the page.
resultsis cached for up to five minutes, and an answer clears it within about 15 seconds; reading it again right after an answer can show the old count. - A
401from a guest path taken as "not signed up", never as a reason to reload. - Names and notes shown with
textContent, neverinnerHTML.
Check it
Open the app 390 px wide and 1280 px wide, in both themes. Answer I'm going on one session: the sign-up sheet opens, and after your name the answer is sent and the bar moves. Reload: your answer is still marked. Change it to Maybe, then cancel it. In Playbook, open Developer → Custom apps → Guests → Answers and find your answer while it is current.