Vote ballot — Storefront block
Prostorefront-vote-ballot · for landing, catalog pages
Vote ballot
A list of candidates and supplied standings with a vote action; the merchant's own votes and dates only.
Documentation
Installation
One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).
pnpm dlx shadcn-vue@latest add @trame/storefront-vote-ballotUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import StorefrontVoteBallot from '@/components/trame/blocks/storefront/storefront-vote-ballot.vue'
const props = {
title: "Which piece would you like to see back?",
intro: "Tell the workshop which one you’d like.",
entries: [
{
id: "besace",
name: "The wayfarer’s satchel",
summary: "A soft shape that sits close to the body.",
period: "First collection",
image: "https://images.unsplash.com/photo-1473188588951-666fce8e7c68?w=1600&q=80",
alt: "A satchel in weathered brown leather, resting on a stone"
},
{
id: "pochette",
name: "The tool pouch",
summary: "A place for all the little essentials."
}
],
voteAction: "vote-reissue",
note: "Fictional demo: no votes are recorded in the playground."
}
</script>
<template>
<StorefrontVoteBallot v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title* | string | Wordsthe section’s heading |
| intro | string | Wordsa sentence or two under the heading |
| entries* | Entry[] | Datathe entries shown, in order |
| voteAction | string | Actioncasts the visitor’s vote for one candidate |
| closesAt | string | Datathe actual closing date as supplied by the host |
| closed | boolean | true: the vote is closed |
| votedId | string | number | Datathe id of the entry the customer voted for, if any |
| pendingId | string | number | Datathe id of the entry whose vote is under way: it shows as busy |
| note | string | Wordsa short note under the section |
| error | string | Wordswhat went wrong with the last vote, as the host words it |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Entry entries[] · 8 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the tool that answers it |
| name* | string | Wordsthe product’s name |
| image | string | null | Picturethe main picture; null or absent: the product has none yet |
| alt | string | Wordswhat the main picture shows |
| summary | string | Wordsone short line on the product |
| period | string | Wordsthe period it comes from, e.g. "1998" |
| votes | number | Dataactual recorded votes, never optimistically incremented |
| share | number | Dataactual share supplied by the voting service |
Options options · 1 props
| Prop | Type | Description |
|---|---|---|
| mood | 'inverse' | 'brand' | 'warm' | 'tint' | string | a band of the page that redefines the theme surfaces inside it |
What it asks your app for
The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).
| Member | What it is for |
|---|---|
| href | the address an action leads to, or null to hide what leads there |
| act | runs a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error } |
| can | whether the page has this action |
| cartCount | the cart badge’s number |
| cartDrawer | whether your app has a cart drawer |
| cartOpen | whether the cart drawer is open |
| label | your word for an interface key, or undefined to keep the block’s own |
The words it says itself, in English and French; label(key) replaces any of them:
| Key | English | French |
|---|---|---|
| newsletter.already | You are already subscribed. | Vous êtes déjà inscrit. |
| newsletter.done | Done: you are subscribed. | C’est noté : vous êtes inscrit. |
| newsletter.invalid | Check the email address. | Vérifiez l’adresse e-mail. |
| newsletter.tooMany | Too many attempts, try again in a moment. | Trop de tentatives, réessayez dans un moment. |
Features
- Every word in the server HTML
- Same markup in Vue and React
- Theme tokens only: every theme, light and dark
- Shows what you give it, invents nothing
- Subtle motion: one short reveal; still under reduced motion
- Real buttons and links, a visible focus
- Asks your app through actions:
vote.cast - Reads
votesfrom your app
A storefront section, for landing, catalog pages; it uses @lucide/vue, class-variance-authority, clsx, reka-ui, tailwind-merge.
Built with
The components this block is made of; each one installs on its own too.
More storefront blocks
- Usage guide do dont: Separate recommended and prohibited gestures into two readable columns; the merchant's own guidance only.
- Usage guide schedule: A practical table of timing, task, product and optional steps; the merchant's own guidance only.
- Variant stock alert grid: a product with many sizes or colours: a grid showing each one’s state, the sold-out ones can be ticked for one alert.
- Viewed products compact rail: small compact cards in a tight rail: the "Recently viewed" section on a product or cart page.
- Welcome offer led: a welcome offer is traded for the address: the offer as the headline, the form beside it.
- Wishlist alerts beside list: the alert settings beside the watched products: a customer who wants to choose what they are told.
- Wishlist board: a long list of things to look at, not to compare: a moodboard of pictures at their own proportions with the actions on the picture (a fashion or decoration shop).
- Wishlist grid: product cards with a way off the list and a way to the cart: the default for any shop.