Prediction Market
Market Cards
PredictionMarketCard.vueOn the radar
Demo markets · simulated prices
Boston Celtics vs. Los Angeles Lakers
Sunday · 7:30 PM·Basketball
Tampa Bay Rays vs. Atlanta Braves
Mid 6th·MLB
Where will interest rates land by the end of the year?
Dec 31·Economics
<script setup lang="ts">
import { ButtonBase, PredictionMarketCard } from 'beui-vue'
import { computed, shallowRef } from 'vue'
// Demo markets use team marks and the Federal Reserve seal, loaded from public hosts.
const markets = [
{
id: 'basketball', title: 'Boston Celtics vs. Los Angeles Lakers', category: 'Basketball', status: 'Sunday · 7:30 PM', volume: '$2.4M', live: false,
image: 'https://a.espncdn.com/i/teamlogos/nba/500/bos.png', history: [12, 18, 15, 26, 20, 32, 29, 38, 34, 48, 43, 58],
outcomes: [
{ id: 'boston', label: 'Celtics', probability: 0.51, next: 0.56, color: '#34d399', image: 'https://a.espncdn.com/i/teamlogos/nba/500/bos.png' },
{ id: 'lakers', label: 'Lakers', probability: 0.49, next: 0.44, color: '#fbbf24', image: 'https://a.espncdn.com/i/teamlogos/nba/500/lal.png' },
],
},
{
id: 'baseball', title: 'Tampa Bay Rays vs. Atlanta Braves', category: 'MLB', status: 'Mid 6th', volume: '$458K', live: true,
image: 'https://a.espncdn.com/i/teamlogos/mlb/500/tb.png', history: [8, 12, 10, 19, 15, 28, 23, 34, 30, 40, 36, 45],
outcomes: [
{ id: 'rays', label: 'Rays', probability: 0.46, next: 0.52, color: '#60a5fa', image: 'https://a.espncdn.com/i/teamlogos/mlb/500/tb.png' },
{ id: 'braves', label: 'Braves', probability: 0.54, next: 0.48, color: '#fb7185', image: 'https://a.espncdn.com/i/teamlogos/mlb/500/atl.png' },
],
},
{
id: 'rates', title: 'Where will interest rates land by the end of the year?', category: 'Economics', status: 'Dec 31', volume: '$347K', live: false,
image: 'https://upload.wikimedia.org/wikipedia/commons/7/73/Seal_of_the_United_States_Federal_Reserve_Board.svg', history: [15, 11, 17, 14, 24, 21, 30, 25, 32, 29, 39, 42],
outcomes: [
{ id: 'below', label: 'Below 3.5%', probability: 0.68, next: 0.72, color: '#34d399', image: null },
{ id: 'above', label: 'Above 4.0%', probability: 0.23, next: 0.18, color: '#60a5fa', image: null },
],
},
]
const updated = shallowRef(false)
const saved = shallowRef<Record<string, boolean>>({})
const shown = computed(() => markets.map(market => ({
...market,
outcomes: market.outcomes.map(outcome => ({ ...outcome, probability: updated.value ? outcome.next : outcome.probability })),
})))
</script>
<template>
<div class="market-cards">
<div class="market-cards-head">
<div>
<p class="market-cards-title">On the radar</p>
<p class="market-cards-sub">Demo markets · simulated prices</p>
</div>
<ButtonBase variant="secondary" size="sm" class="market-cards-update" @click="updated = !updated">Update odds</ButtonBase>
</div>
<div class="market-cards-grid">
<PredictionMarketCard
v-for="market in shown" :key="market.id"
:title="market.title" :category="market.category" :status="market.status" :live="market.live" :volume="market.volume" :volume-history="market.history"
:bookmarked="saved[market.id] ?? false" :outcomes="market.outcomes"
@bookmark-change="value => saved = { ...saved, [market.id]: value }"
>
<template #icon><img :src="market.image" alt="" width="48" height="48" :class="['market-cards-img', { 'is-seal': market.id === 'rates' }]"></template>
<template #outcome-icon="{ outcome }"><img v-if="(outcome as typeof market.outcomes[number]).image" :src="(outcome as typeof market.outcomes[number]).image!" alt="" width="32" height="32" class="market-cards-logo"></template>
</PredictionMarketCard>
</div>
</div>
</template>
<style scoped>
.market-cards { container-type: inline-size; box-sizing: border-box; width: 100%; max-width: 48rem; }
.market-cards > * + * { margin-top: 1.25rem; }
.market-cards-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.market-cards-head p { margin: 0; }
.market-cards-title { font-size: .875rem; line-height: 1.25rem; font-weight: 500; }
.market-cards-sub { margin-top: .25rem !important; font-size: .75rem; line-height: 1rem; color: var(--beui-muted-foreground); }
.market-cards-update { flex: none; }
.market-cards-grid { display: grid; grid-auto-rows: 1fr; gap: 1rem; }
@container (min-width: 640px) { .market-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.market-cards-img { display: block; width: 100%; height: 100%; box-sizing: border-box; padding: .25rem; object-fit: contain; }
.market-cards-img.is-seal { background: #fff; }
.market-cards-logo { display: block; width: 100%; height: 100%; box-sizing: border-box; padding: .125rem; object-fit: contain; }
</style><script setup lang="ts">
import { AnimatePresence, motion } from 'motion-v'
import { useReducedMotion } from '../core/reduced-motion'
import { Comment, computed, Fragment, shallowRef, useId, type VNode } from 'vue'
import { useValue } from '../agents/shared'
import FloatingPanel from '../controls/FloatingPanel.vue'
import { easeOut, pressSpring, swapSpring } from '../core/motion'
import { useMountedMedia } from '../core/mounted-media'
import { formatMessage, predictionMarketCardMessages } from './messages'
export interface PredictionMarketCardOutcome { id: string, label: string, probability: number, color?: string }
export interface PredictionMarketCardSelection { outcomeId: string, side: 'yes' | 'no' }
const props = withDefaults(defineProps<{
title: string
category?: string
volume: string
/** Chronological volume samples for the optional footer sparkline. */
volumeHistory?: number[]
/** A scheduled time or live match status. */
status?: string
live?: boolean
/** Probability is between 0 and 1; `color` tints the compact probability line. */
outcomes: PredictionMarketCardOutcome[]
bookmarked?: boolean
defaultBookmarked?: boolean
labels?: Partial<typeof predictionMarketCardMessages>
className?: string
}>(), { bookmarked: undefined, defaultBookmarked: false, live: false })
const emit = defineEmits<{
'update:bookmarked': [value: boolean]
bookmarkChange: [value: boolean]
outcomeClick: [selection: PredictionMarketCardSelection]
}>()
const slots = defineSlots<{
/** Round mark in the header. */
icon?(): unknown
/** Round mark beside an outcome. */
'outcome-icon'?(props: { outcome: PredictionMarketCardOutcome }): unknown
}>()
// An outcome whose slot renders nothing (a `v-if` that is false) gets no empty circle.
const Nodes = (nodeProps: { nodes: VNode[] }) => nodeProps.nodes
function mark(outcome: PredictionMarketCardOutcome) {
const output = slots['outcome-icon']?.({ outcome }) as VNode[] | undefined
const rendered = output?.filter((node: VNode) => node.type !== Comment && !(node.type === Fragment && Array.isArray(node.children) && node.children.every((child: unknown) => (child as VNode).type === Comment)))
return rendered?.length ? rendered : undefined
}
const t = computed(() => ({ ...predictionMarketCardMessages, ...props.labels }))
const titleId = useId()
const chartId = useId()
const reduce = useReducedMotion()
const canHover = useMountedMedia('(hover: hover) and (pointer: fine)')
const { value: saved, set: setSaved } = useValue(() => props.bookmarked, props.defaultBookmarked, value => {
emit('update:bookmarked', value)
emit('bookmarkChange', value)
})
function probability(value: number) {
return Number.isFinite(value) ? Math.max(0, Math.min(1, value)) : 0
}
const chartPoints = computed(() => {
const samples = props.volumeHistory?.filter(Number.isFinite) ?? []
if (samples.length < 2) return null
const low = Math.min(...samples)
const range = Math.max(...samples) - low
return samples.map((sample, index) => `${2 + (index / (samples.length - 1)) * 44},${18 - (range ? (sample - low) / range : 0.5) * 14}`).join(' ')
})
// Hover and keyboard focus swap an odds button's percentage for its action word.
const hovered = shallowRef<string | null>(null)
const focused = shallowRef<string | null>(null)
const showAction = (id: string) => (canHover.value && hovered.value === id) || focused.value === id
const cents = (outcome: PredictionMarketCardOutcome) => Math.round(probability(outcome.probability) * 100)
const oddsLabel = (outcome: PredictionMarketCardOutcome, index: number) => showAction(outcome.id)
? (index % 2 === 0 ? t.value.yes : t.value.no)
: formatMessage(t.value.percent, { percent: cents(outcome) })
// Roll swap of the odds label, as `ActionSwapText` does in the original.
const ROLL_BLUR = 'blur(3px)'
const roll = {
initial: { opacity: 0, y: '90%', filter: ROLL_BLUR },
animate: { opacity: 1, y: '0%', filter: 'blur(0px)', transition: swapSpring },
exit: { opacity: 0, y: '-90%', filter: ROLL_BLUR, transition: { duration: 0.14, ease: easeOut } },
}
const settled = { opacity: 1, filter: 'blur(0px)', y: 0 }
// Payout hint tooltip.
const payoutAnchors = shallowRef<Record<string, HTMLElement | null>>({})
const tipFor = shallowRef<string | null>(null)
let tipTimer: ReturnType<typeof setTimeout> | undefined
function showTip(id: string, wait = 0) {
clearTimeout(tipTimer)
if (wait) tipTimer = setTimeout(() => { tipFor.value = id }, wait)
else tipFor.value = id
}
function hideTip(wait = 0) {
clearTimeout(tipTimer)
if (wait) tipTimer = setTimeout(() => { tipFor.value = null }, wait)
else tipFor.value = null
}
</script>
<template>
<article :aria-labelledby="titleId" class="be-pmc" :class="className">
<header class="be-pmc-header">
<div v-if="$slots.icon" aria-hidden="true" class="be-pmc-mark"><slot name="icon" /></div>
<div class="be-pmc-heading">
<h3 :id="titleId" class="be-pmc-title">{{ title }}</h3>
<p class="be-pmc-meta">
<span v-if="status" class="be-pmc-status" :class="{ 'is-live': live }"><span v-if="live" aria-hidden="true" class="be-pmc-live" />{{ status }}</span>
<span v-if="status && category" aria-hidden="true">·</span>
<span v-if="category">{{ category }}</span>
</p>
</div>
</header>
<div class="be-pmc-body">
<div class="be-pmc-outcomes">
<div v-for="(outcome, index) in outcomes" :key="outcome.id" class="be-pmc-outcome">
<div class="be-pmc-row">
<span v-if="mark(outcome)" aria-hidden="true" class="be-pmc-outcome-mark"><Nodes :nodes="mark(outcome)!" /></span>
<span class="be-pmc-label">{{ outcome.label }}</span>
<button
:ref="el => { payoutAnchors[outcome.id] = el as HTMLElement | null }" type="button" class="be-pmc-payout"
:aria-label="formatMessage(t.payoutFor, { outcome: outcome.label })"
@pointerenter="(event: PointerEvent) => { if (event.pointerType === 'mouse') showTip(outcome.id, 350) }"
@pointerleave="hideTip(160)"
@focus="(event: FocusEvent) => { if ((event.currentTarget as HTMLElement).matches(':focus-visible')) showTip(outcome.id) }"
@blur="hideTip()"
@pointerup="(event: PointerEvent) => { if (event.pointerType === 'touch') tipFor === outcome.id ? hideTip() : showTip(outcome.id) }"
>{{ probability(outcome.probability) > 0 ? `${(1 / probability(outcome.probability)).toFixed(1)}×` : '—' }}</button>
<FloatingPanel
:open="tipFor === outcome.id" :anchor="payoutAnchors[outcome.id]" side="top" align="center" :gap="5" variant="tip"
class="be-pmc-tip" role="tooltip" @dismiss="hideTip()" @pointerenter="showTip(outcome.id)" @pointerleave="hideTip(120)"
>{{ t.payoutHint }}</FloatingPanel>
<motion.button
type="button" class="be-pmc-odds" :class="index % 2 === 0 ? 'is-positive' : 'is-negative'"
:aria-label="formatMessage(t.trade, { outcome: outcome.label, percent: cents(outcome) })"
:while-press="reduce ? undefined : { scale: 0.96 }" :transition="pressSpring"
@click="emit('outcomeClick', { outcomeId: outcome.id, side: 'yes' })"
@pointerenter="(event: PointerEvent) => { if (event.pointerType !== 'touch') hovered = outcome.id }"
@pointerleave="hovered = null"
@focus="(event: FocusEvent) => { focused = (event.currentTarget as HTMLElement).matches(':focus-visible') ? outcome.id : null }"
@blur="focused = null"
>
<span class="be-pmc-swap">
<span aria-hidden="true" class="be-pmc-swap-sizer">{{ oddsLabel(outcome, index) }}</span>
<AnimatePresence :initial="false">
<motion.span
:key="showAction(outcome.id) ? 'action' : String(cents(outcome))" class="be-pmc-swap-layer"
:initial="reduce ? false : roll.initial" :animate="reduce ? settled : roll.animate" :exit="reduce ? undefined : roll.exit"
>{{ oddsLabel(outcome, index) }}</motion.span>
</AnimatePresence>
</span>
</motion.button>
</div>
<div aria-hidden="true" class="be-pmc-line">
<motion.div
class="be-pmc-line-fill" :initial="false" :animate="{ scaleX: probability(outcome.probability) }"
:transition="reduce ? { duration: 0 } : { duration: 0.25, ease: easeOut }" :style="outcome.color ? { backgroundColor: outcome.color } : undefined"
/>
</div>
</div>
</div>
<footer class="be-pmc-footer">
<svg v-if="chartPoints" aria-hidden="true" viewBox="0 0 48 22" class="be-pmc-chart" fill="none">
<defs>
<linearGradient :id="chartId" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="currentColor" stop-opacity="0.22" />
<stop offset="100%" stop-color="currentColor" stop-opacity="0" />
</linearGradient>
</defs>
<polygon :points="`2,22 ${chartPoints} 46,22`" :fill="`url(#${chartId})`" />
<polyline :points="chartPoints" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" />
</svg>
<span class="be-pmc-volume">{{ formatMessage(t.volume, { volume }) }}</span>
<motion.button
type="button" class="be-pmc-bookmark" :class="{ 'is-saved': saved }" :aria-label="formatMessage(t.bookmark, { title })" :aria-pressed="saved"
:while-press="reduce ? undefined : { scale: 0.85 }" :transition="pressSpring" @click="setSaved(!saved)"
>
<motion.span :animate="{ scale: saved && !reduce ? [1, 1.2, 1] : 1 }" :transition="{ duration: 0.22, ease: easeOut }" class="be-pmc-bookmark-icon">
<svg aria-hidden="true" viewBox="0 0 24 24" width="16" height="16" :fill="saved ? 'currentColor' : 'none'" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z" /></svg>
</motion.span>
</motion.button>
</footer>
</div>
</article>
</template>
<style scoped>
.be-pmc { display: flex; flex-direction: column; box-sizing: border-box; width: 100%; height: 100%; min-width: 0; overflow: hidden; border-radius: 1.5rem; background: var(--beui-card); color: var(--beui-foreground); font-size: 1rem; line-height: 1.5; text-align: start; }
.be-pmc-header { display: flex; flex: none; align-items: center; gap: .75rem; padding: .75rem 1rem; }
.be-pmc-mark { display: flex; flex: none; align-items: center; justify-content: center; box-sizing: border-box; width: 3rem; height: 3rem; overflow: hidden; border: 1px solid var(--beui-border); border-radius: 9999px; background: var(--beui-background); color: var(--beui-foreground); }
.be-pmc-mark :deep(img) { display: block; width: 100%; height: 100%; }
.be-pmc-heading { min-width: 0; flex: 1; }
/* Explicit resets: a host stylesheet's heading and paragraph rules must not reshape the card. */
.be-pmc-title { margin: 0; padding: 0; border: 0; overflow-wrap: anywhere; font-family: var(--beui-font-display, inherit); font-size: 1rem; line-height: 1.375; font-weight: 500; letter-spacing: -.025em; color: inherit; }
.be-pmc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; margin: .25rem 0 0; font-size: .75rem; line-height: 1rem; color: var(--beui-muted-foreground); }
.be-pmc-status { display: inline-flex; align-items: center; gap: .375rem; }
.be-pmc-status.is-live { color: oklch(64.5% .246 16.439); }
.be-pmc-live { width: .375rem; height: .375rem; border-radius: 9999px; background: currentColor; }
.be-pmc-body { display: flex; flex: 1; flex-direction: column; margin: 0 .5rem .5rem; padding: .75rem 1rem; border-radius: 1.5rem; background: var(--beui-background); }
.be-pmc-outcomes { display: flex; flex: 1; flex-direction: column; justify-content: center; gap: .75rem; }
.be-pmc-outcome > * + * { margin-top: .25rem; }
.be-pmc-row { display: flex; align-items: center; gap: .5rem; min-height: 2.5rem; }
.be-pmc-outcome-mark { display: flex; flex: none; align-items: center; justify-content: center; width: 2rem; height: 2rem; overflow: hidden; border-radius: 9999px; background: var(--beui-muted); }
.be-pmc-outcome-mark :deep(img) { display: block; width: 100%; height: 100%; }
.be-pmc-label { min-width: 0; flex: 1; overflow-wrap: anywhere; font-size: .875rem; line-height: 1.25rem; font-weight: 500; }
.be-pmc-payout { flex: none; padding: .5rem 0; border: 0; border-radius: .375rem; background: transparent; color: var(--beui-muted-foreground); font: inherit; font-size: .875rem; line-height: 1.25rem; font-variant-numeric: tabular-nums; cursor: pointer; }
.be-pmc-payout:focus-visible, .be-pmc-bookmark:focus-visible { outline: 2px solid var(--beui-ring); }
.be-pmc-odds {
--odds-ink: var(--beui-foreground); --odds-shadow: currentColor; --odds-border: var(--beui-border); --odds-bg: var(--beui-background); --odds-hover: var(--beui-muted);
position: relative; display: flex; flex: none; align-items: center; justify-content: center; box-sizing: border-box; min-width: 4rem; min-height: 2.5rem; padding: 0 .75rem; overflow: hidden;
border: 1px solid var(--odds-border); border-radius: .75rem; background: var(--odds-bg); color: var(--odds-ink); font: inherit; font-size: .875rem; line-height: 1.25rem; font-weight: 600;
box-shadow: 0 3px 0 var(--odds-shadow); cursor: pointer; transition: background-color .15s;
}
.be-pmc-odds.is-positive { --odds-ink: oklch(50.8% .118 165.612); --odds-shadow: oklch(69.6% .17 162.48 / .2); --odds-border: oklch(69.6% .17 162.48 / .25); --odds-bg: oklch(69.6% .17 162.48 / .1); --odds-hover: oklch(69.6% .17 162.48 / .15); }
.be-pmc-odds.is-negative { --odds-ink: oklch(51.4% .222 16.935); --odds-shadow: oklch(64.5% .246 16.439 / .2); --odds-border: oklch(64.5% .246 16.439 / .25); --odds-bg: oklch(64.5% .246 16.439 / .1); --odds-hover: oklch(64.5% .246 16.439 / .15); }
:global(:is(.dark, [data-beui-theme='dark']) .be-pmc-odds.is-positive) { --odds-ink: oklch(76.5% .177 163.223); }
:global(:is(.dark, [data-beui-theme='dark']) .be-pmc-odds.is-negative) { --odds-ink: oklch(71.2% .194 13.428); }
@media (hover: hover) { .be-pmc-odds:hover { background: var(--odds-hover); } }
.be-pmc-odds:focus-visible { outline: 2px solid var(--beui-ring); outline-offset: 2px; }
.be-pmc-swap { position: relative; display: inline-block; max-width: 100%; margin-block: -.08em; padding-block: .08em; white-space: nowrap; vertical-align: bottom; clip-path: inset(0 -999px); }
.be-pmc-swap-sizer { display: inline-block; visibility: hidden; white-space: nowrap; }
.be-pmc-swap-layer { position: absolute; top: .08em; left: 0; display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; will-change: opacity, filter, transform; }
.be-pmc-line { box-sizing: border-box; width: 6rem; height: .125rem; overflow: hidden; border-radius: 9999px; }
.be-pmc-line-fill { width: 100%; height: 100%; transform-origin: left; border-radius: 9999px; background: oklch(84.5% .143 164.978 / .7); }
:global(:is(.dark, [data-beui-theme='dark']) .be-pmc-line-fill) { background: oklch(76.5% .177 163.223 / .4); }
.be-pmc-footer { display: flex; flex: none; align-items: center; gap: .5rem; margin-top: .5rem; font-size: .75rem; line-height: 1rem; color: var(--beui-muted-foreground); }
.be-pmc-chart { flex: none; width: 3rem; height: 1.25rem; color: oklch(69.6% .17 162.48); }
:global(:is(.dark, [data-beui-theme='dark']) .be-pmc-chart) { color: oklch(76.5% .177 163.223); }
.be-pmc-volume { flex: none; }
.be-pmc-bookmark { display: flex; flex: none; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; margin-left: auto; padding: 0; border: 0; border-radius: .75rem; background: transparent; color: inherit; cursor: pointer; transition: background-color .15s; }
.be-pmc-bookmark.is-saved { color: var(--beui-foreground); }
@media (hover: hover) { .be-pmc-bookmark:hover { background: var(--beui-muted); } }
.be-pmc-bookmark-icon { display: inline-flex; }
</style>
<style>
/* The tooltip is teleported to <body>, outside this component's scope. */
.be-pmc-tip.be-pmc-tip.be-pmc-tip { box-sizing: border-box; width: 11rem; padding: .25rem .625rem; border: 1px solid var(--beui-border); border-radius: .5rem; background: var(--beui-background); color: var(--beui-foreground); font-size: .75rem; line-height: 1.625; font-weight: 500; text-align: center; white-space: normal; overflow: visible; box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1); }
</style>Install
Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide
$ bunx --bun shadcn-vue@latest add @beui-vue/prediction-market-card$ bun add beui-vueDownload the release archive to your project root, then install the local file.
$ bun add ./beui-vue-0.1.0.tgzImport the shared styles once in your application.
import PredictionMarketCard from '@/components/beui/blocks/PredictionMarketCard.vue'
import '@/components/beui/styles.css'API Reference
titlestring—#icon?slotRound mark in the header.
—category?string—volumestring—volumeHistory?number[]Chronological volume samples for the optional footer sparkline.
—status?stringA scheduled time or live match status.
—live?booleanfalseoutcomesPredictionMarketCardOutcome[]Probability is between 0 and 1; `color` tints the compact probability line.
—@outcome-click?(selection: PredictionMarketCardSelection) => voidCalled on each outcome CTA click; the card keeps no selected state.
—v-model:bookmarked?booleanundefineddefaultBookmarked?booleanfalse@bookmark-change?(value: boolean) => void—labels?Partial<typeof predictionMarketCardMessages>Override any built-in string.
—className?string—#outcome-icon?{ outcome: PredictionMarketCardOutcome }Round mark beside an outcome.
—Trade Ticket
PredictionMarket.vueAvg. Price 16.7¢
<script setup lang="ts">
import { PredictionMarket, type PredictionMarketOrderValue } from 'beui-vue'
import { shallowRef } from 'vue'
const outcomes = [
{ id: 'yes', label: 'Yes', price: 0.167 },
{ id: 'no', label: 'No', price: 0.834 },
]
const order = shallowRef<PredictionMarketOrderValue>({ mode: 'buy', outcomeId: 'yes', amount: '115' })
</script>
<template>
<div class="ticket-demo">
<PredictionMarket
:outcomes="outcomes" :value="order" :balance="500" :positions="{ yes: 125, no: 48 }" :quick-amounts="[1, 5, 10, 100]"
@value-change="order = $event"
/>
</div>
</template>
<style scoped>
.ticket-demo { display: flex; width: 100%; align-items: center; justify-content: center; }
</style><script setup lang="ts">
import { AnimatePresence, LayoutGroup, animate, motion } from 'motion-v'
import { useReducedMotion } from '../core/reduced-motion'
import { computed, onBeforeUnmount, shallowRef, useId, useTemplateRef } from 'vue'
import StatefulButton, { type ButtonState } from '../actions/StatefulButton.vue'
import { useValue } from '../agents/shared'
import { easeOut, tabsSpring } from '../core/motion'
import NumberTicker from '../numeric/NumberTicker.vue'
import { formatMessage, predictionMarketMessages } from './messages'
export type PredictionMarketMode = 'buy' | 'sell'
export interface PredictionMarketOutcome { id: string, label: string, price: number }
export interface PredictionMarketOrderValue { mode: PredictionMarketMode, outcomeId: string, amount: string }
export interface PredictionMarketQuote { valid: boolean, amount: number, price: number, shares: number, payout: number, error?: string }
export interface PredictionMarketClassNames { root?: string, header?: string, tabs?: string, outcomes?: string, amount?: string, chips?: string, footer?: string, action?: string }
const props = withDefaults(defineProps<{
outcomes?: PredictionMarketOutcome[]
modelValue?: PredictionMarketOrderValue
/** Alias of `modelValue`, kept from the original port. */
value?: PredictionMarketOrderValue
defaultValue?: Partial<PredictionMarketOrderValue>
authenticated?: boolean
orderTypeLabel?: string
balance?: number
positions?: Record<string, number>
quickAmounts?: number[]
minTrade?: number
/** Override any built-in string. `{price}` fills `avgPrice`, `{amount}` fills `minimum`. */
labels?: Partial<typeof predictionMarketMessages>
className?: string
classNames?: PredictionMarketClassNames
}>(), {
outcomes: () => [{ id: 'up', label: 'Up', price: 0.09 }, { id: 'down', label: 'Down', price: 0.91 }],
authenticated: true, balance: 500, positions: () => ({ up: 24, down: 16 }), quickAmounts: () => [10, 50, 100, 500], minTrade: 1,
})
const emit = defineEmits<{
'update:modelValue': [value: PredictionMarketOrderValue]
valueChange: [value: PredictionMarketOrderValue]
trade: [order: PredictionMarketOrderValue, quote: PredictionMarketQuote]
signIn: []
}>()
const MODES: PredictionMarketMode[] = ['buy', 'sell']
const t = computed(() => ({ ...predictionMarketMessages, ...props.labels }))
const inputId = useId()
const reduce = useReducedMotion()
const amountBox = useTemplateRef<HTMLElement>('amountBox')
const status = shallowRef<'idle' | 'placing' | 'filled'>('idle')
const shakeKey = shallowRef(0)
let timer: ReturnType<typeof setTimeout> | undefined
const { value: order, set: setOrder } = useValue<PredictionMarketOrderValue>(
() => props.modelValue ?? props.value,
{ mode: props.defaultValue?.mode ?? 'buy', outcomeId: props.defaultValue?.outcomeId ?? props.outcomes[0]?.id ?? '', amount: props.defaultValue?.amount ?? '' },
next => { emit('update:modelValue', next); emit('valueChange', next) },
)
function sanitizeAmount(value: string) {
const [whole, ...decimalParts] = value.replace(/[^\d.]/g, '').split('.')
if (decimalParts.length === 0) return whole
return `${whole}.${decimalParts.join('').slice(0, 2)}`
}
const parseAmount = (value: string) => Number(value) || 0
function formatCurrency(value: number, maximumFractionDigits = 2) {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits }).format(value)
}
const formatCompactCurrency = (value: number) => value >= 100 ? formatCurrency(value, 0) : formatCurrency(value, value % 1 === 0 ? 0 : 2)
function formatCents(value: number) {
const cents = value * 100
return `${cents.toFixed(Number.isInteger(cents) ? 0 : 1)}¢`
}
const selectedOutcome = computed(() => props.outcomes.find(outcome => outcome.id === order.value.outcomeId) ?? props.outcomes[0])
const position = computed(() => props.positions[selectedOutcome.value.id] ?? 0)
const quote = computed<PredictionMarketQuote>(() => {
const amount = parseAmount(order.value.amount)
const price = Math.max(0.01, Math.min(0.99, selectedOutcome.value.price))
const buying = order.value.mode === 'buy'
const shares = buying ? amount / price : amount
const payout = buying ? shares : amount * price
if (amount <= 0) return { valid: false, amount, price, shares: 0, payout: 0, error: t.value.enterAmount }
if (buying && amount < props.minTrade) return { valid: false, amount, price, shares, payout, error: formatMessage(t.value.minimum, { amount: formatCompactCurrency(props.minTrade) }) }
if (buying && amount > props.balance) return { valid: false, amount, price, shares, payout, error: t.value.insufficientBalance }
if (!buying && amount > position.value) return { valid: false, amount, price, shares, payout, error: t.value.notEnoughShares }
return { valid: true, amount, price, shares, payout }
})
function setOrderValue(next: Partial<PredictionMarketOrderValue>) {
clearTimeout(timer)
status.value = 'idle'
setOrder({ ...order.value, ...next })
}
function addAmount(increment: number) { setOrderValue({ amount: String(parseAmount(order.value.amount) + increment) }) }
function setMax() {
if (order.value.mode === 'buy') setOrderValue({ amount: String(Math.floor(props.balance)) })
else setOrderValue({ amount: position.value.toFixed(position.value % 1 === 0 ? 0 : 2) })
}
function submit() {
if (!props.authenticated) { emit('signIn'); return }
if (!quote.value.valid) {
shakeKey.value += 1
if (!reduce.value && amountBox.value) animate(amountBox.value, { x: [0, -5, 5, -3, 3, -1, 0] }, { duration: 0.38, ease: easeOut })
return
}
status.value = 'placing'
timer = setTimeout(() => {
status.value = 'filled'
emit('trade', { ...order.value }, { ...quote.value })
}, 650)
}
onBeforeUnmount(() => clearTimeout(timer))
// Digits are keyed by character and occurrence so a typed digit rolls in without re-rolling its neighbours.
const displayValue = computed(() => order.value.amount || '0')
const chars = computed(() => {
const seen = new Map<string, number>()
return displayValue.value.split('').map(char => {
const count = seen.get(char) ?? 0
seen.set(char, count + 1)
return { id: `${char}-${count}`, char }
})
})
const sizeClass = computed(() => {
const length = order.value.amount.replace(/\D/g, '').length
return length >= 10 ? 'is-s3' : length >= 8 ? 'is-s2' : length >= 6 ? 'is-s1' : 'is-s0'
})
const payoutClass = computed(() => {
const length = formatCurrency(quote.value.payout).length
return length >= 16 ? 'is-p3' : length >= 13 ? 'is-p2' : length >= 10 ? 'is-p1' : 'is-p0'
})
const digitIn = computed(() => reduce.value ? { opacity: 0 } : { opacity: 0, y: 18, filter: 'blur(10px)' })
const digitSettled = computed(() => reduce.value ? { opacity: 1 } : { opacity: 1, y: 0, filter: 'blur(0px)' })
const digitOut = computed(() => reduce.value ? { opacity: 0 } : { opacity: 0, y: -14, filter: 'blur(10px)' })
const digitTransition = { duration: 0.18, ease: easeOut } as const
const actionState = computed<ButtonState>(() => status.value === 'placing' ? 'loading' : status.value === 'filled' ? 'success' : quote.value.valid ? 'idle' : 'error')
const amountLabel = computed(() => order.value.mode === 'buy' ? t.value.amount : t.value.shares)
const isNo = (outcome: PredictionMarketOutcome) => ['no', 'down'].includes(outcome.label.toLowerCase())
const indicatorTransition = computed(() => reduce.value ? { duration: 0 } : tabsSpring)
// Roving tab lists: arrows, Home and End move and select, like the original Tabs.
function onTabsKey(event: KeyboardEvent) {
const list = event.currentTarget as HTMLElement
const tabs = Array.from(list.querySelectorAll<HTMLButtonElement>('[role="tab"]:not(:disabled)'))
const at = tabs.indexOf(event.target as HTMLButtonElement)
if (at < 0) return
const rtl = getComputedStyle(list).direction === 'rtl'
const next = event.key === (rtl ? 'ArrowLeft' : 'ArrowRight') ? tabs[(at + 1) % tabs.length]
: event.key === (rtl ? 'ArrowRight' : 'ArrowLeft') ? tabs[(at - 1 + tabs.length) % tabs.length]
: event.key === 'Home' ? tabs[0] : event.key === 'End' ? tabs[tabs.length - 1] : null
if (!next) return
event.preventDefault()
next.focus()
next.click()
}
const modeGroup = useId()
const outcomeGroup = useId()
</script>
<template>
<div class="be-pm" :class="[className, classNames?.root]">
<div class="be-pm-header" :class="classNames?.header">
<div class="be-pm-header-row">
<LayoutGroup :id="modeGroup">
<div role="tablist" class="be-pm-modes" :class="classNames?.tabs" @keydown="onTabsKey">
<button
v-for="mode in MODES" :key="mode" type="button" role="tab" class="be-pm-mode" :class="{ 'is-active': order.mode === mode }"
:aria-selected="order.mode === mode" :tabindex="order.mode === mode ? 0 : -1" @click="setOrderValue({ mode, amount: '' })"
>
{{ t[mode] }}
<motion.span v-if="order.mode === mode" layout :layout-id="`${modeGroup}-underline`" class="be-pm-underline" :transition="indicatorTransition" />
</button>
</div>
</LayoutGroup>
<button type="button" class="be-pm-order-type" :disabled="status === 'placing'">
{{ orderTypeLabel ?? t.orderType }}
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6" /></svg>
</button>
</div>
</div>
<div class="be-pm-body">
<LayoutGroup :id="outcomeGroup">
<div role="tablist" class="be-pm-outcomes" :class="classNames?.outcomes" @keydown="onTabsKey">
<div v-for="outcome in outcomes" :key="outcome.id" class="be-pm-outcome-cell">
<motion.span
v-if="outcome.id === selectedOutcome.id" layout :layout-id="`${outcomeGroup}-pill`" class="be-pm-pill" :class="isNo(outcome) ? 'is-no' : 'is-yes'"
:style="{ borderRadius: '9999px' }" :transition="indicatorTransition"
/>
<button
type="button" role="tab" class="be-pm-outcome" :class="[isNo(outcome) ? 'is-no' : 'is-yes', { 'is-selected': outcome.id === selectedOutcome.id }]"
:aria-selected="outcome.id === selectedOutcome.id" :tabindex="outcome.id === selectedOutcome.id ? 0 : -1" @click="setOrderValue({ outcomeId: outcome.id })"
>{{ outcome.label }} {{ formatCents(outcome.price) }}</button>
</div>
</div>
</LayoutGroup>
<div ref="amountBox" class="be-pm-amount" :class="classNames?.amount">
<div class="be-pm-amount-main">
<label :for="inputId" class="be-pm-amount-label">{{ amountLabel }}</label>
<div class="be-pm-amount-field">
<div class="be-pm-amount-row">
<span v-if="order.mode === 'buy'" aria-hidden="true" class="be-pm-dollar" :class="sizeClass">$</span>
<div class="be-pm-input-wrap">
<input
:id="inputId" class="be-pm-input" :class="sizeClass" :value="order.amount" :disabled="status === 'placing'" placeholder="0" inputmode="decimal"
:aria-label="amountLabel" autocomplete="off" :style="{ '--amount-chars': String(chars.length) }"
@input="setOrderValue({ amount: sanitizeAmount(($event.target as HTMLInputElement).value) })"
>
<div aria-hidden="true" class="be-pm-digits" :class="[sizeClass, { 'is-empty': !order.amount }]" :style="{ '--amount-chars': String(chars.length) }">
<AnimatePresence :initial="false" mode="popLayout">
<motion.span
v-for="item in chars" :key="item.id" :layout="reduce ? false : 'position'" class="be-pm-digit"
:initial="digitIn" :animate="digitSettled" :exit="digitOut" :transition="digitTransition"
>{{ item.char }}</motion.span>
</AnimatePresence>
</div>
</div>
</div>
</div>
</div>
<div class="be-pm-chips" :class="classNames?.chips">
<button v-for="amount in quickAmounts" :key="amount" type="button" class="be-pm-chip" :disabled="status === 'placing'" @click="addAmount(amount)">+{{ order.mode === 'buy' ? formatCompactCurrency(amount) : amount }}</button>
<button type="button" class="be-pm-chip" :disabled="status === 'placing'" @click="setMax">{{ t.max }}</button>
</div>
</div>
</div>
<div v-if="authenticated" class="be-pm-footer" :class="classNames?.footer">
<div class="be-pm-quote">
<div class="be-pm-quote-copy">
<div class="be-pm-quote-title">
{{ order.mode === 'buy' ? t.toWin : t.toReceive }}
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="be-pm-banknote"><rect width="20" height="12" x="2" y="6" rx="2" /><circle cx="12" cy="12" r="2" /><path d="M6 12h.01M18 12h.01" /></svg>
</div>
<p class="be-pm-avg">{{ formatMessage(t.avgPrice, { price: formatCents(quote.price) }) }}</p>
</div>
<div class="be-pm-payout" :class="payoutClass">
<NumberTicker :value="quote.payout * 100" :start-on-view="false" :duration="0.45" :stagger="0" blur :format="cents => formatCurrency(cents / 100)" />
</div>
</div>
<StatefulButton
:state="actionState" variant="primary" size="lg" :press-scale="0.98" :loading-text="t.trading" :success-text="t.tradeFilled" :error-text="quote.error ?? t.enterAmount"
class="be-pm-action" :class="classNames?.action" @click="submit"
>{{ t.trade }}</StatefulButton>
</div>
<div v-else class="be-pm-connect">
<StatefulButton state="idle" variant="primary" size="lg" :press-scale="0.98" class="be-pm-action is-connect" :class="classNames?.action" @click="submit">{{ t.connect }}</StatefulButton>
</div>
</div>
</template>
<style scoped>
.be-pm { box-sizing: border-box; width: 100%; max-width: 400px; overflow: hidden; border: 1px solid var(--beui-border); border-radius: 1.5rem; background: var(--beui-background); color: var(--beui-foreground); font-size: 1rem; line-height: 1.5; text-align: start; }
.be-pm button { font-family: inherit; }
.be-pm-header { padding: 1rem 1rem 0; border-bottom: 1px solid color-mix(in srgb, var(--beui-border) 80%, transparent); }
.be-pm-header-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.be-pm-modes { display: inline-flex; flex: none; align-items: center; gap: 1.25rem; }
.be-pm-mode { position: relative; isolation: isolate; display: inline-flex; flex: none; align-items: center; min-height: 44px; margin: 0 0 -1px; padding: 0 0 .75rem; border: 0; background: transparent; color: var(--beui-muted-foreground); font-size: 1.5rem; line-height: 2rem; font-weight: 600; white-space: nowrap; cursor: pointer; transition: color .15s; }
.be-pm-mode.is-active { color: var(--beui-foreground); }
@media (hover: hover) { .be-pm-mode:hover { color: var(--beui-foreground); } }
.be-pm-mode:focus-visible, .be-pm-outcome:focus-visible, .be-pm-chip:focus-visible, .be-pm-order-type:focus-visible { outline: 2px solid var(--beui-ring); outline-offset: 2px; }
.be-pm-underline { position: absolute; right: 0; bottom: 0; left: 0; height: 2px; background: var(--beui-foreground); }
.be-pm-order-type { display: inline-flex; align-items: center; gap: .5rem; margin: 0 0 .75rem; padding: 0; border: 0; background: transparent; color: var(--beui-foreground); font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; cursor: pointer; transition: opacity .15s; }
.be-pm-order-type:disabled { opacity: .5; }
.be-pm-body { padding: .75rem; }
.be-pm-body > * + * { margin-top: 1rem; }
.be-pm-outcomes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; gap: .5rem; width: 100%; box-sizing: border-box; padding: .375rem; border-radius: 9999px; background: var(--beui-card); }
.be-pm-outcome-cell { position: relative; flex: none; min-width: 0; }
.be-pm-pill { position: absolute; inset: 0; border-radius: 9999px; }
.be-pm-pill.is-yes { background: oklch(69.6% .17 162.48 / .2); }
.be-pm-pill.is-no { background: oklch(63.7% .237 25.331 / .1); }
:global(:is(.dark, [data-beui-theme='dark']) .be-pm-pill.is-no) { background: oklch(63.7% .237 25.331 / .15); }
.be-pm-outcome { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; width: 100%; height: 3.5rem; padding: 0; border: 0; border-radius: 1.35rem; background: transparent; font-size: 1rem; line-height: 1.5; font-weight: 600; white-space: nowrap; cursor: pointer; transition: color .15s, transform .1s; }
.be-pm-outcome:active { transform: scale(.99); }
.be-pm-outcome.is-yes { color: var(--beui-muted-foreground); }
.be-pm-outcome.is-no { color: oklch(80.8% .114 19.571 / .55); }
/* The selected label is drawn over the pill in the primary foreground, as the original tab overlay does. */
.be-pm-outcome.is-selected { color: var(--beui-primary-foreground); }
.be-pm-amount { padding: 1rem; border-radius: 1.5rem; background: var(--beui-card); }
.be-pm-amount-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem; min-height: 6rem; text-align: center; }
.be-pm-amount-label { margin-right: 1.5rem; font-size: 1.25rem; line-height: 1.75rem; font-weight: 500; color: var(--beui-foreground); }
.be-pm-amount-field { width: 100%; min-width: 0; }
.be-pm-amount-row { display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden; }
.be-pm-dollar { flex: none; font-weight: 600; line-height: 1; letter-spacing: normal; color: color-mix(in srgb, var(--beui-muted-foreground) 65%, transparent); font-variant-numeric: tabular-nums; transition: font-size .2s; }
.be-pm-input-wrap { position: relative; flex: 0 1 auto; min-width: 0; }
.be-pm-input { box-sizing: content-box; display: block; width: calc((var(--amount-chars) + 1) * .62em); min-width: .8em; max-width: 260px; margin: 0; padding: 0; border: 0; background: transparent; text-align: left; font: inherit; font-weight: 600; line-height: 1; letter-spacing: normal; color: transparent; caret-color: var(--beui-foreground); outline: none; font-variant-numeric: tabular-nums; transition: font-size .2s; }
.be-pm-input::placeholder { color: transparent; }
.be-pm-input::selection { background: color-mix(in srgb, var(--beui-foreground) 10%, transparent); }
.be-pm-input:disabled { cursor: not-allowed; }
.be-pm-digits { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-start; min-width: 0; overflow: hidden; pointer-events: none; font-weight: 600; line-height: 1; letter-spacing: normal; color: var(--beui-foreground); font-variant-numeric: tabular-nums; transition: font-size .2s; }
.be-pm-digits.is-empty { color: color-mix(in srgb, var(--beui-muted-foreground) 55%, transparent); }
.be-pm-digit { display: inline-block; min-width: .55em; text-align: center; will-change: transform, opacity, filter; }
.is-s0 { font-size: 3rem; } .is-s1 { font-size: 44px; } .is-s2 { font-size: 2.25rem; } .is-s3 { font-size: 1.875rem; }
@media (min-width: 640px) { .is-s0 { font-size: 3.75rem; } .is-s1 { font-size: 56px; } .is-s2 { font-size: 3rem; } .is-s3 { font-size: 2.25rem; } }
.be-pm-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: 2rem; }
.be-pm-chip { height: 2.25rem; padding: 0 .875rem; border: 0; border-radius: .75rem; background: var(--beui-background); color: var(--beui-foreground); font-size: .875rem; line-height: 1.25rem; font-weight: 600; cursor: pointer; transition: background-color .15s, transform .15s; }
.be-pm-chip:active { transform: scale(.95); }
.be-pm-chip:disabled { pointer-events: none; opacity: .5; }
.be-pm-footer { padding: 1rem; border-top: 1px solid color-mix(in srgb, var(--beui-border) 80%, transparent); }
.be-pm-quote { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.be-pm-quote-copy { min-width: 0; flex: 0 1 auto; }
.be-pm-quote-title { display: flex; align-items: center; gap: .5rem; font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; color: var(--beui-foreground); }
.be-pm-banknote { color: oklch(69.6% .17 162.48); }
.be-pm-avg { margin: 0; font-size: .875rem; line-height: 1.25rem; font-weight: 500; color: var(--beui-muted-foreground); }
.be-pm-payout { display: flex; justify-content: flex-end; flex: none; min-width: 0; margin-left: auto; white-space: nowrap; text-align: right; font-weight: 600; line-height: 1; letter-spacing: -.025em; color: oklch(69.6% .17 162.48); font-variant-numeric: tabular-nums; transition: font-size .2s; }
.be-pm-payout.is-p0 { font-size: 2.25rem; } .be-pm-payout.is-p1 { font-size: 1.875rem; } .be-pm-payout.is-p2 { font-size: 1.5rem; } .be-pm-payout.is-p3 { font-size: 1.25rem; }
@media (min-width: 640px) { .be-pm-payout.is-p3 { font-size: 1.5rem; } }
.be-pm-action { width: 100%; height: 3rem; border-radius: 1rem !important; font-size: 1rem; font-weight: 600; }
.be-pm-connect { padding: 0 1rem 1.25rem; }
.be-pm-action.is-connect { height: 3.5rem; }
</style>Install
Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide
$ bunx --bun shadcn-vue@latest add @beui-vue/prediction-market$ bun add beui-vueDownload the release archive to your project root, then install the local file.
$ bun add ./beui-vue-0.1.0.tgzImport the shared styles once in your application.
import PredictionMarket from '@/components/beui/blocks/PredictionMarket.vue'
import '@/components/beui/styles.css'API Reference
outcomes?PredictionMarketOutcome[][{ id: "up", label: "Up", price: 0.09 }, { id: "down", label: "Down", price: 0.91 }]value?PredictionMarketOrderValueAlias of `modelValue`, kept from the original port.
—defaultValue?Partial<PredictionMarketOrderValue>—@update:model-value?(value: PredictionMarketOrderValue) => void—@trade?(order: PredictionMarketOrderValue, quote: PredictionMarketQuote) => void—@sign-in?() => void—authenticated?booleantrueorderTypeLabel?string—balance?number500positions?Record<string, number>{ up: 24, down: 16 }quickAmounts?number[][10, 50, 100, 500]minTrade?number1labels?Partial<typeof predictionMarketMessages>Override any built-in string. `{price}` fills `avgPrice`, `{amount}` fills `minimum`.
—className?string—classNames?PredictionMarketClassNames—v-model?PredictionMarketOrderValue—@value-change?(value: PredictionMarketOrderValue) => void—Related components
Wallet Card
Wallet overview card with an account switcher and search that morph open from their triggers, a cascading balance with a live change pill and privacy toggle, copy-address, and Send / Deposit / Swap / Buy actions.
Multi-chain Swap
Cross-chain swap widget with chain + token selectors, morphing views, animated flip and quote.
Card Dealer
A card table with a face-down deck, a fanned hand and a discard pile. Cards arc across the table between them and flip in flight, hop over each other when the hand is sorted, and lift on hover. Data-driven by each card's zone, with custom faces and backs, keyboard-playable hand cards and reduced-motion support.
Updated