cart-checkout
Skill0 starsChanged 46 days agoApache-2.0View on GitHub
Web-app storefront cart and checkout: `useCartDrawer`, a Radix Dialog `CartDrawer` mounted once in the shell, a `CartButton` for header actions, a mock-payment checkout page and an order-confirmation page. Clears the cart on place-order. Use when building the buying flow after commerce-core.
In this repository15 other files it gives its agents.
- authSkill
- chartSkill
- commerce-adminSkill
- commerce-coreSkill
- dashboard-motionSkill
- drawerSkill
- formSkill
- kanbanSkill
- mediaSkill
- metric-cardSkill
- modalSkill
- product-catalogSkill
- product-detailSkill
- sidenavSkill
- tableSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 145
Do NOT use transition-* and do NOT use tailwindcss-animate classes (animate-in, fade-in-0, slide-in-from-right): radix-vue's Presence only …
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cart & Checkout Skill (web app storefront)
When to use
The cart + checkout surface for a web-app storefront. Depends on the
commerce-core skill (useCart,
useCartDrawer).
Frontend + mock data only — no backend, no real payment. Checkout is UI that clears the cart and shows a mock confirmation.
Architecture
Generate FOUR files (useCartDrawer is provided by commerce-core — import it, don't recreate it):
| File | Purpose |
app/components/features/shop/CartDrawer.vue | Radix Dialog slide-in cart; mount once in default.vue |
app/components/features/shop/CartButton.vue | Header cart button + count badge (add to HeaderActions) |
app/pages/checkout.vue | Contact/shipping/mock-payment + order summary |
app/pages/order-confirmation.vue | Mock success screen |
app/components/features/shop/CartDrawer.vue
Radix DialogRoot bound to the shared state; slide/fade are CSS transitions keyed off Radix
data-[state], so open/close stay symmetric (Radix keeps it mounted through the close transition).
<script setup lang="ts">
import { DialogRoot, DialogPortal, DialogOverlay, DialogContent, DialogTitle, DialogClose } from 'radix-vue'
import { X, Minus, Plus, ShoppingCart } from 'lucide-vue-next'
import { useCart } from '~/composables/useCart'
import { useCartDrawer } from '~/composables/useCartDrawer'
const cart = useCart()
const drawer = useCartDrawer()
function fmt(n: number, currency = 'USD') { return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(n) }
</script>
<template>
<DialogRoot :open="drawer.isOpen.value" @update:open="(v) => (v ? drawer.open() : drawer.close())">
<DialogPortal>
<DialogOverlay class="fixed inset-0 z-40 bg-black/40 backdrop-blur-sm data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out" />
<DialogContent class="fixed inset-y-0 right-0 z-50 flex w-full max-w-md flex-col bg-card shadow-2xl data-[state=open]:animate-drawer-in-right data-[state=closed]:animate-drawer-out-right focus:outline-none">
<div class="flex items-center justify-between border-b border-border px-5 py-4">
<DialogTitle class="text-base font-semibold text-foreground">Cart ({{ cart.count.value }})</DialogTitle>
<DialogClose class="p-1 text-muted-foreground hover:text-foreground" aria-label="Close"><X class="h-5 w-5" /></DialogClose>
</div>
<div v-if="cart.isEmpty.value" class="flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center">
<ShoppingCart class="h-9 w-9 text-muted-foreground/50" />
<p class="text-sm text-muted-foreground">Your cart is empty.</p>
<DialogClose as-child><NuxtLink to="/shop" class="rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:brightness-110">Browse catalog</NuxtLink></DialogClose>
</div>
<template v-else>
<div class="flex-1 space-y-4 overflow-y-auto px-5 py-4">
<div v-for="line in cart.lines.value" :key="line.id" class="flex gap-3">
<div class="h-20 w-16 shrink-0 overflow-hidden rounded-lg bg-muted"><img v-if="line.image" :src="line.image" :alt="line.name" class="h-full w-full object-cover" /></div>
<div class="flex min-w-0 flex-1 flex-col">
<div class="flex items-start justify-between gap-2">
<div class="min-w-0"><p class="truncate text-sm font-medium text-foreground">{{ line.name }}</p><p v-if="line.variantLabel" class="text-xs text-muted-foreground">{{ line.variantLabel }}</p></div>
<button class="text-muted-foreground hover:text-foreground" aria-label="Remove" @click="cart.remove(line.id)"><X class="h-4 w-4" /></button>
</div>
<div class="mt-auto flex items-center justify-between pt-2">
<div class="flex items-center rounded-lg border border-border">
<button class="p-1.5 text-foreground hover:text-primary" aria-label="Decrease" @click="cart.decrement(line.id)"><Minus class="h-3.5 w-3.5" /></button>
<span class="w-7 text-center text-sm tabular-nums text-foreground">{{ line.quantity }}</span>
<button class="p-1.5 text-foreground hover:text-primary" aria-label="Increase" @click="cart.increment(line.id)"><Plus class="h-3.5 w-3.5" /></button>
</div>
<span class="text-sm font-semibold tabular-nums text-foreground">{{ fmt(line.price * line.quantity, line.currency) }}</span>
</div>
</div>
</div>
</div>
<div class="border-t border-border px-5 py-4">
<div class="mb-3 flex items-center justify-between"><span class="text-sm text-muted-foreground">Subtotal</span><span class="text-base font-semibold tabular-nums text-foreground">{{ fmt(cart.subtotal.value) }}</span></div>
<DialogClose as-child><NuxtLink to="/checkout" class="block rounded-lg bg-primary py-3 text-center text-sm font-medium text-primary-foreground hover:brightness-110">Checkout</NuxtLink></DialogClose>
</div>
</template>
</DialogContent>
</DialogPortal>
</DialogRoot>
</template>app/components/features/shop/CartButton.vue
<script setup lang="ts">
import { ShoppingCart } from 'lucide-vue-next'
import { useCart } from '~/composables/useCart'
import { useCartDrawer } from '~/composables/useCartDrawer'
const cart = useCart()
const drawer = useCartDrawer()
</script>
<template>
<button class="relative rounded-lg p-2 text-foreground transition-colors hover:bg-muted" aria-label="Open cart" @click="drawer.open()">
<ShoppingCart class="h-5 w-5" />
<span v-if="cart.count.value > 0" class="absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold tabular-nums text-primary-foreground">{{ cart.count.value }}</span>
</button>
</template>app/pages/checkout.vue
Renders in layout: default. Same logic as the storefront checkout: contact + shipping + mock
payment fields, a live order summary from useCart(), required-field validation, and on submit
cart.clear() + router.push({ path: '/order-confirmation', query: { order } }) with a generated mock
order number. Include an honest "Demo checkout — no real payment" note. Guard the empty cart with a link
to /shop. Keep the standard checkout structure with app-shell spacing.
app/pages/order-confirmation.vue
Renders in layout: default. Centered success card: check icon, "Thank you for your order", the mock
order number from route.query.order, "(Demo order — no payment processed.)", and a link back to /shop.
Wiring
app/layouts/default.vue: mount<CartDrawer />once.app/components/layout/HeaderActions.vue: add<CartButton />beside the theme toggle.
Non-negotiables
- All cart reads/writes via
useCart(); drawer open state viauseCartDrawer(). No local cart state. CartDrawermounted once indefault.vue; use RadixDialogRoot/DialogContentwith CSS animations frommain.css(data-[state=open]:animate-drawer-in-right,data-[state=closed]:animate-drawer-out-right; overlayanimate-overlay-in/animate-overlay-out— these utilities are pre-defined inmain.css). Do NOT usetransition-*and do NOT use tailwindcss-animate classes (animate-in,fade-in-0,slide-in-from-right): radix-vue'sPresenceonly waits for CSS animations on exit, so a transition makes the drawer vanish instantly instead of sliding out. (You may instead reuse the scaffolded~/components/shared/DrawerRoot.vue, which already implements this correctly.) Never hand-roll a GSAP open/close timeline.- No real payment — mock fields + honest note;
placeOrderclears the cart and routes to/order-confirmation. - Empty-cart guards on both the drawer and the checkout page.
- Money via
Intl.NumberFormat+tabular-nums; all colours via tokens.
Colour & polish
- Step indicator: done / current / upcoming.
- Render category colour as a tinted chip:
bg-[hsl(var(--chart-N)/0.12)] text-[hsl(var(--chart-N))]. - Clear primary-vs-secondary button hierarchy; visible disabled states.
success/destructiveare for genuine good/bad meaning only — never decoration.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

