Vote ballot — Storefront block

Pro

storefront-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-ballot

Usage

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.

PropTypeDescription
title*stringWordsthe section’s heading
introstringWordsa sentence or two under the heading
entries*Entry[]Datathe entries shown, in order
voteActionstringActioncasts the visitor’s vote for one candidate
closesAtstringDatathe actual closing date as supplied by the host
closedbooleantrue: the vote is closed
votedIdstring | numberDatathe id of the entry the customer voted for, if any
pendingIdstring | numberDatathe id of the entry whose vote is under way: it shows as busy
notestringWordsa short note under the section
errorstringWordswhat went wrong with the last vote, as the host words it
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Entry entries[] · 8 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe product’s name
imagestring | nullPicturethe main picture; null or absent: the product has none yet
altstringWordswhat the main picture shows
summarystringWordsone short line on the product
periodstringWordsthe period it comes from, e.g. "1998"
votesnumberDataactual recorded votes, never optimistically incremented
sharenumberDataactual share supplied by the voting service
Options options · 1 props
PropTypeDescription
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa 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).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour 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:

KeyEnglishFrench
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo 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 votes from 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.

All 409 storefront blocks