mirror of
https://github.com/Such-Software/smirk-website.git
synced 2026-11-30 12:03:58 +01:00
feat(website): illustrate two-chain swap flows
This commit is contained in:
+26
-2
@@ -108,6 +108,30 @@ body {
|
||||
|
||||
/* Dedicated educational pages preserve the landing page composition. */
|
||||
.demo-page { width: 100%; max-width: 56rem; margin: 0 auto; padding: 3rem 1.5rem 5rem; }
|
||||
.demo-assets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
|
||||
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible { outline: 2px solid var(--smirk-yellow); outline-offset: 4px; }
|
||||
@media (max-width: 380px) { .demo-page { padding-left: 1rem; padding-right: 1rem; } .demo-assets { gap: .5rem; } }
|
||||
@media (max-width: 380px) { .demo-page { padding-left: 1rem; padding-right: 1rem; } }
|
||||
|
||||
.demo-progress { display: flex; gap: .35rem; margin-bottom: 1rem; }
|
||||
.demo-progress span { height: 3px; flex: 1; border-radius: 2px; background: #3f3f46; transition: background-color .25s ease; }
|
||||
.demo-progress span[data-reached="true"] { background: var(--smirk-yellow); }
|
||||
.swap-flow { display: grid; gap: .75rem; }
|
||||
.flow-chain { border: 1px solid #3f3f46; border-radius: .75rem; padding: .85rem .65rem; }
|
||||
.flow-caption { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .8rem; margin-bottom: .7rem; }
|
||||
.flow-status { color: var(--smirk-yellow); font-size: .7rem; }
|
||||
.flow-track { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); position: relative; gap: .3rem; }
|
||||
.flow-path { position: absolute; top: 1rem; left: 16.666%; right: 16.666%; height: 1px; background: #71717a; }
|
||||
.flow-token { position: absolute; top: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--smirk-yellow); transform: translateX(-50%); transition: left .4s ease; box-shadow: 0 0 9px #fbeb0a80; }
|
||||
.flow-node { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
|
||||
.flow-symbol { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1px solid #71717a; border-radius: 50%; background: #171717; color: #a1a1aa; transition: border-color .25s ease, color .25s ease, background-color .25s ease; }
|
||||
.flow-symbol svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
|
||||
.flow-node[data-active="true"] .flow-symbol { color: var(--smirk-yellow); border-color: var(--smirk-yellow); background: #292805; }
|
||||
.flow-node-label { margin-top: .4rem; font-size: .7rem; color: #ededed; }
|
||||
.flow-person { margin-top: .2rem; max-width: 9rem; font-size: .65rem; line-height: 1.4; color: #a1a1aa; }
|
||||
.demo-step-picker { margin: 1rem 0 1.4rem; font-size: .75rem; color: #a1a1aa; }
|
||||
.demo-step-picker summary { cursor: pointer; padding: .4rem 0; }
|
||||
@media (min-width: 640px) { .swap-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
@media (prefers-reduced-motion: reduce) { .flow-token, .flow-symbol, .demo-progress span { transition: none; } }
|
||||
|
||||
.flow-arrow { position: absolute; top: -4px; width: 8px; height: 8px; fill: none; stroke: #a1a1aa; stroke-width: 1.5; }
|
||||
.flow-arrow-first { left: 25%; }
|
||||
.flow-arrow-second { left: 75%; }
|
||||
|
||||
@@ -4,15 +4,41 @@ import { advanceDemo, INITIAL_DEMO_STATE, setDemoEvidence, simulatedAssetState,
|
||||
export default function SwapWalkthrough({ demo }: { demo: SwapDemo }) {
|
||||
const [state, setState] = useState(INITIAL_DEMO_STATE);
|
||||
const current = demo.steps[state.step];
|
||||
return <div className="mt-10">
|
||||
<div className="demo-assets">{demo.assets.map((asset, side) => <div key={asset} className="rounded-xl border border-zinc-800 p-5">
|
||||
<p className="text-xs text-zinc-400">{demo.people[side]}</p><p className="mt-2 text-2xl font-bold">{asset}</p>
|
||||
<p className="mt-2 text-sm text-[#fbeb0a]">{simulatedAssetState(state.step, side)}</p>
|
||||
</div>)}</div>
|
||||
<ol aria-label="Swap steps" className="my-8 grid gap-2 sm:grid-cols-2">{demo.steps.map((step, index) => <li key={step.label} aria-current={index === state.step ? 'step' : undefined}
|
||||
className={`rounded-lg border px-4 py-3 text-sm ${index === state.step ? 'border-[#fbeb0a] text-[#fbeb0a]' : 'border-zinc-800 text-zinc-400'}`}>
|
||||
<span className="mr-3 tabular-nums">{index + 1}.</span>{step.label}
|
||||
</li>)}</ol>
|
||||
const chainNames: Record<string, string> = { LTC: 'Litecoin', WOW: 'Wownero', BTC: 'Bitcoin', XMR: 'Monero' };
|
||||
const holders = demo.assets.map(asset => `${chainNames[asset]} holder`);
|
||||
return <div className="mt-7">
|
||||
<div className="demo-progress" aria-hidden="true">{demo.steps.map((step, index) => <span key={step.label} data-reached={index <= state.step} />)}</div>
|
||||
<div className="swap-flow" role="group" aria-label="Simulated asset flow">
|
||||
{demo.assets.map((asset, side) => {
|
||||
const status = simulatedAssetState(state.step, side);
|
||||
const position = status === 'Not locked' ? 0 : status === 'Locked' ? 1 : 2;
|
||||
return <figure key={asset} className="flow-chain" aria-label={`${chainNames[asset]}: ${status}. From ${holders[side]} to ${holders[1 - side]}.`}>
|
||||
<figcaption className="flow-caption"><span>{chainNames[asset]} <span className="text-zinc-400">{asset}</span></span><span className="flow-status">{status}</span></figcaption>
|
||||
<div className="flow-track">
|
||||
<div className="flow-path" aria-hidden="true">
|
||||
<svg className="flow-arrow flow-arrow-first" viewBox="0 0 8 8"><path d="m2 1 3 3-3 3" /></svg>
|
||||
<svg className="flow-arrow flow-arrow-second" viewBox="0 0 8 8"><path d="m2 1 3 3-3 3" /></svg>
|
||||
<span className="flow-token" style={{ left: `${position * 50}%` }} />
|
||||
</div>
|
||||
{['Wallet', 'Shared lock', 'Recipient'].map((label, index) => <div key={label} className="flow-node" data-active={position === index}>
|
||||
<span className="flow-symbol" aria-hidden="true">{index === 1 ? <svg viewBox="0 0 24 24"><path d="M7 10V7a5 5 0 0 1 10 0v3M5 10h14v11H5z" /></svg> : <svg viewBox="0 0 24 24"><path d="M3 5h16v15H3zM3 5l13-3v3M15 11h6v5h-6z" /></svg>}</span>
|
||||
<span className="flow-node-label">{label}</span>
|
||||
<span className="flow-person">{index === 0 ? holders[side] : index === 2 ? holders[1 - side] : 'Agreed swap'}</span>
|
||||
</div>)}
|
||||
</div>
|
||||
</figure>;
|
||||
})}
|
||||
</div>
|
||||
<details className="demo-step-picker">
|
||||
<summary>Step {state.step + 1} of {demo.steps.length}<span className="ml-3 text-[#fbeb0a]">Jump to a step</span></summary>
|
||||
<ol aria-label="Swap steps" className="mt-3 grid grid-cols-2 gap-2">
|
||||
{demo.steps.map((step, index) => <li key={step.label}><button type="button" aria-current={index === state.step ? 'step' : undefined}
|
||||
disabled={state.evidenceUnknown} onClick={() => setState(value => value.evidenceUnknown ? value : { ...value, step: index })}
|
||||
className={`h-full w-full rounded-lg border px-3 py-2 text-left text-xs disabled:cursor-not-allowed disabled:opacity-50 ${index === state.step ? 'border-[#fbeb0a] text-[#fbeb0a]' : 'border-zinc-700 text-zinc-300'}`}>
|
||||
{index + 1}. {step.label}
|
||||
</button></li>)}
|
||||
</ol>
|
||||
</details>
|
||||
<section aria-live="polite" aria-atomic="true" className="min-h-36">
|
||||
<p className="text-xs text-zinc-400">Simulated step {state.step + 1} of {demo.steps.length}</p>
|
||||
<h2 className="mt-3 text-xl font-semibold">{current.label}</h2><p className="mt-3 leading-relaxed text-zinc-300">{current.detail}</p>
|
||||
|
||||
Reference in New Issue
Block a user