ConversionBreakdown
- Status
- Implemented
- Family
- 4 of 13
- Registry
- @lopifi/conversion-breakdown
npx shadcn@latest add @lopifi/theme @lopifi/conversion-breakdownThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
Wise's honesty pattern, as a component. Every line visible.
Amount to convert 1,000.00 USD
Our fee −4.50 USD ← itemized, named
Amount we'll convert 995.50 USD
────────── ← single rule
Rate 1 USD = 0.91842 EUR · 09:12 UTC
Recipient gets 914.29 EUR
══════════ ← double rule
- Every fee named and itemized. Never a lump "Fees".
- The rate line carries its timestamp.
- Uses
Rule— the same grammar as the statements, which is what makes the library feel like one system. - Percentage-of-total splits use largest-remainder allocation, so the parts sum to the total exactly.
Lifted verbatim from Swaps & FX. The doc and this page are the same paragraphs, so they cannot disagree.
What lands in your repository
One component is never one file. Everything below is copied into your project, where you own it.
The whole component
No compiled bundle, no black box. This is the file the registry copies, and the file you will edit.
import * as React from "react";
import { cn } from "@/lib/ledger/cn";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { Money } from "@/components/ledger/money";
import { RateLine } from "@/components/ledger/rate-line";
import { Rule } from "@/components/ledger/rule";
export interface ConversionBreakdownProps extends React.ComponentPropsWithoutRef<"div"> {
amount: MoneyValue;
converted: MoneyValue;
/** Every fee named and itemized. Never a lump "Fees". */
fees: { label: string; amount: MoneyValue }[];
from: string;
rate: number;
rateAsOf: Date;
recipientGets: MoneyValue;
to: string;
}
/** The honesty pattern, as a component. Every line visible. */
export const ConversionBreakdown = React.forwardRef<HTMLDivElement, ConversionBreakdownProps>(
({ className, amount, fees, converted, from, to, rate, rateAsOf, recipientGets, ...props }, ref) => (
<div className={cn("w-full", className)} ref={ref} {...props}>
<table className="w-full">
<caption className="sr-only">Conversion breakdown</caption>
<tbody>
<Line amount={amount} label="Amount to convert" showCode />
{fees.map((f) => (
<Line amount={f.amount} key={f.label} label={f.label} negative showCode />
))}
<tr>
<td />
<td className="py-1">
<Rule variant="subtotal" />
</td>
</tr>
<Line amount={converted} emphasis label="Amount we’ll convert" showCode />
<tr>
<th className="pt-3 text-left" colSpan={2} scope="row">
<RateLine asOf={rateAsOf} from={from} rate={rate} to={to} />
</th>
</tr>
<Line amount={recipientGets} emphasis label="Recipient gets" showCode size="md" />
<tr>
<td />
<td className="pt-1">
<Rule variant="total" />
</td>
</tr>
</tbody>
</table>
</div>
),
);
ConversionBreakdown.displayName = "ConversionBreakdown";
function Line({
label,
amount,
showCode,
emphasis,
negative,
size = "sm",
}: {
label: string;
amount: MoneyValue;
showCode?: boolean;
emphasis?: boolean;
negative?: boolean;
size?: "sm" | "md";
}) {
return (
<tr>
<th
className={cn(
"py-1 pr-6 text-left text-body font-normal",
emphasis ? "font-medium text-text-primary" : "text-text-secondary",
)}
scope="row"
>
{label}
</th>
<td className="py-1 text-right">
<Money
showCode={showCode}
size={size}
value={negative ? { ...amount, amount: -Math.abs(Number(amount.amount)) } : amount}
/>
</td>
</tr>
);
}
The accounting it encodes
Concepts this component renders. Each one is defined once, in the lexicon, and used identically in the code and the copy.
Also in Swaps & FX
- SwapWidgetFrom/to with the flip. The signature component.
- RateLineA rate with its timestamp. Never one without the other.
- RateLockLocked rate with a countdown and expiry behavior.
- CurrencyPairChartRate history with a period selector.
- RateTickerLive multi-pair ticker with value flash.
- SlippageControlTolerance setting with an explicit worst case.
- SwapRouteMulti-hop path visualization.
- FxExposurePosition by currency with unrealized gain/loss.
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Swaps & FX — the family specThe four-layer specification this component was built against, before it was written.Doc
- FX, swaps and rate componentsThe family running, with real figures in it, in both themes and at every density.Live
- CatalogAll 179 components, specified before they are written.Doc
- StatementP&L, balance sheet, or cash flowTerm
Elsewhere in the system
Where ConversionBreakdown sits in the rest of the system — the live section it renders in, the calculators that compute what it displays, and the ledger payloads it is fed from.
- ConversionBreakdown, runningThe swaps showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- FX conversion & gain/lossThe rate is the one in your policy, so you type it. No live rate, no network call, no stale surprise.Tool
- Swaps & FXThe governing rule for this entire family: A rate is a perishable fact. It never appears without a timestamp, and it is never transacted on without a lock. Specs for 9 React components: SwapWidget, RateLine, RateLock, ConversionBreakdown and 5 more.Doc
Components are copied into your repository and meant to be edited — rounding policy, fiscal calendar and compliance copy differ per company.
Told when Swaps & FX changes
Components are copied into your repo, so a fix here does not reach you on its own. One email when a component in this family changes in a way that needs a migration — and nothing when it does not.