Saved cards card faces — Storefront block

Free

storefront-saved-cards-card-faces · for account, checkout pages

Saved cards card faces

Each saved card beside a neutral drawn face (its label, a chip mark, the last four digits, the expiry; no network logo): a customer with two or three cards who recognises them by sight.

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-saved-cards-card-faces

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import StorefrontSavedCardsCardFaces from '@/components/trame/blocks/storefront/storefront-saved-cards-card-faces.vue'

const props = {
title: "Your payment methods",
cards: [
{
id: "method-a",
brand: "Bank card",
last4: "1842",
expiry: "08/2028",
default: true
},
{
id: "method-b",
brand: "Bank card",
last4: "7059",
expiry: "02/2025",
expired: true
}
],
explainer: "In this demo shop, the payment provider keeps your payment method. Your account only shows its name, its last digits and its expiry date.",
actions: {
remove: "remove-payment-method",
setDefault: "default-payment-method"
},
add: {
label: "Add a payment method",
action: "add-payment-method"
}
}
</script>

<template>
<StorefrontSavedCardsCardFaces v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
title*stringWordsthe section’s heading
cards*Card[]Datathe customer’s saved payment cards
explainer*stringWordsthe actual storage arrangement, supplied by the merchant
actions*Actionsthe page actions the block runs, each described below
addAddthe add link: its words and where it leads
pendingIdstringDatathe id of the card whose action is under way: it shows as busy
errorstringWordswhat went wrong with the last action, as the host words it
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Card cards[] · 6 props
PropTypeDescription
id*stringDatathe card’s id
brand*stringDatathe card’s brand, e.g. "visa"
last4*stringDatathe last four digits of the card number
expirystringDataits expiry date, e.g. "08/27"
expiredbooleantrue: the card has expired
defaultbooleantrue: the card used by default
Actions actions · 2 props
PropTypeDescription
remove*stringActionremoves the card the customer confirms
setDefaultstringActionmakes a card the default one
Add add · 4 props
PropTypeDescription
label*stringWordsthe link’s words, e.g. "See the collection"
actionstringActiona named action of the page
recordRecord<string, unknown>Datathe record the action applies to, passed to the host with it, if any
urlstringDesignan address outside the app
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
Linkyour router’s link component
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
  • No motion; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: record.remove, record.default, add
  • Reads payment_methods from your app

A storefront section, for account, checkout 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

  • Review snapshot distribution: a product page that wants the average and the five star bars at a glance, with a link to every review.
  • Reviews summary bars: a product page: the average, the count and one bar per star beside the list of reviews; the merchant’s own only.
  • Reviews summary cards grid: a home or a landing: many short reviews as cards, each with its stars, author and product; the merchant’s own only.
  • Reviews summary pair: a product page that wants to be believed: the most helpful positive review beside the most helpful critical one; the merchant’s own only.
  • Reviews summary photo wall: reviews that come with customers’ photos: a wall of pictures, each opening its full review; the merchant’s own only.
  • Saved for later folded: a single line "Saved for later (3)" that opens on compact rows: a cart drawer or a long cart page where the saved products must not compete with the cart.
  • Saved for later rows: a quiet list under the cart: a row per product with its picture, options, price (and how it moved since it was set aside) and the two buttons: the default for any shop.
  • Saved for later shelf: picture cards in a row that scrolls sideways, the buttons under each: a shop whose products are recognised by their picture (fashion, decoration).

All 409 storefront blocks