Event card
One workshop, class, supper club or pop-up: the kind, the title, the date and time, the venue, what you'll do and eat, the price per person and a booking link.
quiet warm playful
Open the live demo
npx @susegad/cli add event-card
Stands on: Core, Core: components, Core: rupees and the Indian clock, Engine, Tokens
The prompt
the prompt
One workshop, class, supper club or pop-up: a pasta class at a partner kitchen, a chef's supper, a market-day pop-up, a yoga morning, a studio open day.
The kind, the title, when and where, what you'll do and eat, the price per person and a way to book. It knows what time it is, so it says whether the event is coming up, today, on now or over, and it stops offering a booking link for something that has finished.
<link rel="stylesheet" href="susegad/components/event-card/event-card.css">
<script type="module" src="susegad/components/event-card/event-card.js"></script>
<sg-event-card kind="workshop" start="2026-10-04T11:00" end="2026-10-04T13:00" seats-left="4">
<article aria-labelledby="ev1">
<p class="sg-event-kind">Workshop</p>
<h3 id="ev1">Handmade pasta, from the dough up</h3>
<p class="sg-event-when"><time datetime="2026-10-04T11:00:00+05:30">Sun 4 Oct, 11 am to 1 pm</time></p>
<p class="sg-event-where"><span class="sg-event-venue">A kitchen studio</span>, <span class="sg-event-area">Aldona</span> <a href="https://maps.example/…">Map</a></p>
<section class="sg-event-do"><h4>What you'll do</h4><ul><li>Mix and knead a dough by hand</li></ul></section>
<section class="sg-event-eat"><h4>What you'll eat</h4><ul><li>Your own pasta, with a seasonal sauce</li></ul></section>
<footer class="sg-event-stub">
<p class="sg-event-price"><span class="sg-event-amount">₹2,000</span> per person</p>
<p class="sg-event-cta"><a href="https://wa.me/919800000000?text=…">Save my seat</a></p>
</footer>
</article>
</sg-event-card>
The prompt
Make an event card web component around an <article>: a small kind label (workshop, supper club, pop-up or class), the title as a heading, the date with its weekday in a <time datetime> and the time as a range ("Sun 4 Oct, 11 am to 1 pm"), the venue's name and area with an optional map link, a "what you'll do" list and a "what you'll eat" list, the price per person, and a call to action that is a plain link in a slot (it will usually open WhatsApp; take the link from the markup and never build it in the component). With JavaScript, read the clock in the venue's own time zone (Asia/Kolkata unless a timezone is given) and say in words which of four things is true: how far off it is ("In 2 days", "Tomorrow"), today ("Today at 11 am"), on now ("On now, until 1 pm"), or over ("This one has happened. Booking is closed."). Move on by itself when the clock passes the start or the end, using one timer that runs only while the card is on screen and catches up when it is seen again. Show a seats line ("4 seats left") only when a seats-left number is given, and call the event sold out only when seats-left is 0, then swap the booking link for an alternative if there is one. Hide the booking link on a finished event and show no seats line. Give it three registers. Quiet: a ruled card, the foot ruled off, the booking link an outline. Warm: a ticket, with a notch cut at each end of a perforated tear line (the holes drawn in code, each a little different, from a seed), the stub a tinted column at the right when there is room and a strip along the foot when there is not, set on at a small seeded lean. Playful: the same ticket in the hand, the kind label a hand-lettered pill, and the stub tears a little when the pointer or the keyboard focus is on the card: it lifts at its free corner and settles there with a spring, once, nothing loops. Under reduced motion nothing moves.
Words to code
| When you say | Technique | What happens |
|---|---|---|
| the venue's own time zone | pure core | parseWhen(text, zone) reads "2026-10-04T11:00" as wall-clock time in the zone (an offset or Z in the text wins); wall() and zoneOffset() use Intl so no library is needed and summer-time zones work. |
| coming up, today, on now, over | eventPhase(now, start, end, zone) | The start is inclusive and the end is not. Days are the venue's calendar days, so 00:30 in Goa is already "today" for an event that day, though it is still the evening before in UTC. With no end an event is "today" until its day is over and never claims to be on now. |
| in words | describeEvent() | awayInWords (Tomorrow, In 5 days, In 3 weeks, then the date), clock ("11 am", "6:30 pm", "12 noon"), formatWhen ("Sun 4 Oct, 11 am to 1 pm", across midnight "Sat 3 Oct, 8 pm to Sun 4 Oct, 1 am"). |
| only when a number is given | seatsOf(raw) | Only a whole number of 0 or more counts. "lots", "", a missing attribute and "-2" are unknown, and an unknown number says nothing. Sold out is seats-left="0" and nothing else. |
| finished events stop offering booking | honesty | showCta is false once over or sold out; the element hides .sg-event-cta, shows [data-when="sold-out"] alternatives when sold out, and removes the seats line from a finished event. |
| moves on by itself | one timer | nextChange() gives the next boundary (midnight, start, end); setTimeout runs only while the card is visible (the shared IntersectionObserver) and the card refreshes the moment it is seen again. Inside an <sg-event-list> the list keeps the clock instead. |
| a notch at each end of a perforated tear line | warm skin | CSS masks cut two circles where the tear meets the edge; the skin measures where the stub starts (a column or a strip), tells the CSS, and draws the holes along it with perforation(length, seed). |
| a small seeded lean | lean(seed) | 0.2 to 0.7 degrees, set once as --sg-event-lean. |
| the stub tears a little ... settles | CSS only | On :hover or :focus-within the stub gets a short translate and rotate about its free corner with the spring ease; reduced motion keeps it flat. No loops, no timers. |
| a call to action ... take the link from the markup | slot | The element never writes a link. It only shows or hides the <a> you put in .sg-event-cta. |
Accessibility
- An
<article>named by its heading; the date is a real<time datetime>with the offset. - The state is words ("On now, until 1 pm", "Sold out"), with a shape (ring, half, dot, dash) as well; never colour alone.
- The booking link is an ordinary link: it takes Tab, shows a 2 px focus ring, and leaves the tab order when the event is over.
- The perforation is drawn in an
aria-hiddenSVG; the tear is decoration. - Without JavaScript the markup you wrote shows in full: kind, title, date, venue, lists, price and link.
<sg-event-card> is one workshop, class, supper club or pop-up. It enhances an <article>.
Markup
| Element | What it is |
|---|---|
p.sg-event-kind | the kind, in words ("Workshop", "Supper club", "Pop-up", "Class"). Optional: with a kind attribute and no such element, one is added. |
a heading (h2 to h4) | the title; the first heading directly in the article |
p.sg-event-when with <time> | the date and time. With start set, the element writes the text and datetime itself, so they cannot disagree with the clock; what you write is what people see without JavaScript, so write it the same way. |
p.sg-event-where | .sg-event-venue, .sg-event-area and, if you like, a map <a> |
section.sg-event-do, section.sg-event-eat | "What you'll do or learn" and "What you'll eat", each a small heading and a <ul> |
footer.sg-event-stub | the foot of the card: the price, the seats line and the booking link. It is the stub of the ticket in warm and playful. |
p.sg-event-price | .sg-event-amount and the words after it ("per person", "a plate") |
p.sg-event-cta | the booking link: your own <a>, usually WhatsApp (build it with waLink() from reach.core.js). The card never writes a link. |
[data-when="sold-out"] | an optional hidden element, usually a link ("Ask about the next date"), shown only when the event is sold out |
The element adds p.sg-event-status ("In 2 days", "Today at 11 am", "On now, until 1 pm", "This one has happened. Booking is closed.") after the date and, when seats-left is given, p.sg-event-seats in the foot.
Attributes
| Attribute | Values | Default |
|---|---|---|
start | YYYY-MM-DDTHH:MM, wall-clock time in the zone; an offset or Z wins | required |
end | the same | none: the event is "today" all day and never "on now" |
timezone | an IANA zone, or the list's | Asia/Kolkata |
seats-left | a whole number | none: no seats line. 0 means sold out. |
kind | workshop, supper-club, pop-up, class | none |
now | an ISO time to count from, for demos, tests and print; it stops the clock | the real clock |
seed | the ticket's lean and the holes of its tear line | the title |
register | quiet, warm, playful | inherited |
Event: sg-event-state { phase, soldOut }, when the clock moves the card on. card.refresh(nowMs) reads the clock again; card.info is the latest description.
Honest by the clock
| It is | The card says | Booking link | Seats line |
|---|---|---|---|
| coming up | "In 2 days", "Tomorrow", "In 3 weeks", then the date | shown | only if seats-left is a number |
| today, before the start | "Today at 11 am" | shown | as above |
on now (needs an end) | "On now, until 1 pm" | shown | as above |
| over | "This one has happened. Booking is closed." | gone | gone |
seats-left="0" | "Sold out" | replaced by [data-when="sold-out"] if you wrote one | "Sold out" |
The start is inclusive and the end is not: at 11:00:00 it is on now, at 13:00:00 it is over. Days are the venue's days: at 00:30 in Goa, 19:00 UTC the evening before, an event that day is already "today".
A seats line never appears unless you gave a number. A card with no seats-left says nothing about seats; it never guesses scarcity.
On a static site you can compute all of this at build time with describeEvent() from event.core.js, so a reader without JavaScript sees the same words. Use one or the other: the element writes its own status line whatever the HTML already says.
Registers
| Look | |
|---|---|
| quiet | a ruled card, the foot ruled off, the booking link an outline |
| warm | a ticket: notches and a perforated tear line (holes drawn in code, each a little different), a tinted stub as a column at the right when the card is wide enough and a strip along the foot when it is not, a small seeded lean |
| playful | the same ticket in the hand; the stub tears a little on hover or focus, lifts at its free corner, settles with a spring and stays there while the pointer stays, and goes back when it leaves. Nothing loops. |
Reduced motion keeps every register still.
Accessibility
How this component meets WCAG 2.2 level A and AA, criterion by criterion, how each was checked, and what your page still owns.
- Meets 15
- 2
- Not applicable 1
| Criterion | Status | How it was checked |
|---|---|---|
| 1.1.1 Non-text content | Meets | The tear line and its holes are an aria-hidden drawing (packages/components/event-card/event-card.js, .sg-event-perf; packages/components/event-card/event-card.css), and the card holds no images of its own. Kind, date, venue and price are text. |
| 1.3.1 Info and relationships | Meets | An <article aria-labelledby> with an <h3>, a real <time datetime> with the offset, <section>s with <h4>s and lists, and the booking link in the footer (packages/components/event-card/event-card.js, the markup in its header comment). packages/components/event-card/event-card.check.mjs: "without JavaScript: kind, title, date, venue, price and booking link all show on every card" and "the date the element writes is the date the plain markup already says". |
| 1.4.1 Use of color | Meets | The clock state is words ("Today at 11 a.m.", "On now", "Over") and a sold-out card says so in words and swaps the booking link for the alternative (event-card.check.mjs: "clock <time>: <phase>, "<status>", booking link shown or gone", "<name>: seats line ..., sold out, booking replaced by the alternative"). |
| 1.4.3 Contrast (minimum) | Meets | event-card.check.mjs: "axe, light, all three registers: 0 violations", the same in dark, in each register on its own in dark (playful with reduced motion), and with JavaScript off, color-contrast included. Text roles are tested at 4.5:1 or more on every surface in packages/tokens/tokens.test.js. |
| 1.4.4 Resize text | Meets | Manual test, 2026-10-07: the demo with the root font size at 200 percent in three registers (1280 px wide), no sideways scroll and no clipped text (throwaway Playwright script). |
| 1.4.10 Reflow | Meets | event-card.check.mjs: "at 390 px the demo does not scroll sideways", and warm "at 390: the stub is a strip along the foot with a horizontal tear line, and the page does not scroll sideways". Manual test at 320 CSS px, three registers, 2026-10-07: no sideways scroll and no element past the viewport. |
| 1.4.11 Non-text contrast | Meets | The tear line is decoration. The focus ring is --sg-focus and the card's rules are --sg-rule-strong, tested 3:1 or more on every surface for every palette and theme in packages/tokens/tokens.test.js. |
| 1.4.12 Text spacing | Meets | Manual test, 2026-10-07: the WCAG text-spacing values (line height 1.5, letter 0.12em, word 0.16em, paragraph spacing 2em) injected on the demo in three registers, no clipped or overlapping text (throwaway Playwright script). No check in the repository asserts it yet. |
| 2.1.1 Keyboard | Meets | event-card.check.mjs: "<register>: Tab reaches "Save my seat" (N presses) and it shows a focus ring" in each register, "a sold-out event: Tab reaches the alternative link, not the booking one", and "a finished event: Tab never lands on a booking link". |
| 2.1.2 No keyboard trap | Meets | Manual test, 2026-10-07: packages/components/event-card/event-card.js and its skins bind no key handler, set no tabindex and call no focus(), so Tab and Shift+Tab pass through the native links and the booking and map links. packages/components/event-card/event-card.check.mjs Tabs through the demo in each register ("Tab reaches "Save my seat" ... and it shows a focus ring"). |
| 2.4.4 Link purpose (in context) | The booking link sits in the card's footer inside an <article> named by its title, and the clock hides it once the event is over (event-card.check.mjs: "a finished event: Tab never lands on a booking link"). The link text is the author's: Manual test, 2026-10-07: in the demo's markup the booking links on the upcoming and the sold-out card both read "Save my seat" and the map links "Map", which a list of links shows without the event's name. Writing the event into the link text or an aria-label makes each one stand alone. | |
| 2.4.7 Focus visible | Meets | event-card.check.mjs: "Tab reaches "Save my seat" ... and it shows a focus ring" in each register; the rule is sg-event-card a:focus-visible in packages/components/event-card/event-card.css, and tools/touch.check.mjs requires a focus style as well. |
| 2.5.3 Label in name | Meets | Links are named by their visible text because the component adds no aria-label (packages/components/event-card/event-card.js). |
| 2.5.8 Target size (minimum) | Meets | The booking link is at least 2.75rem (44 px) tall (min-height in packages/components/event-card/event-card.css). Manual test, 2026-10-07: no focusable control under 24 by 24 CSS px at 1280 px or at 390 px with touch, in all three registers; the small "Map" link sits inline in a sentence, which the criterion excepts, and measured at least 24 px tall besides (throwaway Playwright script). |
| 2.2.2 Pause, stop, hide | Not applicable | Nothing on a card moves by itself: the playful stub lifts only on hover or focus and settles back, and nothing loops (event-card.check.mjs: "playful: nothing loops (no infinite animation)"). |
| 2.4.3 Focus order | Meets | Manual test, 2026-10-07 (throwaway Playwright script): the event card demo at 390 px in quiet, warm and playful, Tab pressed through every stop (7 stops in each register); each focused control was on screen and not covered (the element at its centre is the control itself) and every stop came after the previous one in document order. The same script on a page with a full-screen fixed layer added reported every stop covered, so it can fail. The clock changes which link exists (a finished event has no booking link, a sold-out one has the alternative), and event-card.check.mjs asserts it: "a finished event: Tab never lands on a booking link". |
| 2.4.11 Focus not obscured (minimum) | packages/components/event-card/event-card.css has no position: fixed or sticky, so the component never covers a focused control itself. Manual test, 2026-10-07 (throwaway Playwright script): the event-card demo at 390 px in three registers, every Tab stop was on screen and not covered (the element at its centre is the control itself); the same script with a full-screen fixed layer added reported every stop covered, so it can fail. | |
| 4.1.2 Name, role, value | Meets | A named article, native links, a <time>. event-card.check.mjs: axe with 0 violations in light and dark, in each register, and with JavaScript off. |
The page author owns:
- The event's words, the price, the venue and the link texts, in the language of the page, and
langon a passage in another language (3.1.2). - Link texts that name the event, or an
aria-labelthat begins with the visible text, so a list of links makes sense (2.4.4). - The heading level of the card's title, so the card fits the page's outline.
- The
start,endandtimezoneof the event, since the clock reads them. - Sticky headers and banners that could cover the booking link when it takes focus (2.4.11).
- The colours the page sets behind the card, if it overrides the tokens.
How it behaves
- A named article; a real
<time datetime>with the offset. - The clock state is words with a shape beside it, not colour alone.
- The booking link takes Tab, shows a focus ring, and leaves the tab order when the event is over.
- The tear line is an
aria-hiddendrawing. - Without JavaScript the written markup reads fine and the quiet look applies.