Demo
Your stay
- 9 nights
- €960.00
- Weekly stay discount (10%)
- −€96.00
- Cleaning
- €35.00
- Service fee12% of the nights and cleaning
- €107.88
- Lisbon tourist tax2 guests × 7 nights
- €56.00
- Total
- €1,062.88
A demo: no money moves.
- 3 nights
- ¥62,000
- Cleaning
- ¥5,000
- Service fee
- ¥8,040
- Accommodation tax
- ¥1,800
- Total (JPY)
- ¥76,840
Get it
It needs theme.qwe, as every component does; or take the whole kit, quillo-ui.qwe. Each component brings its own styles to the pages that show it.
$ curl -O https://quillolang.org/components/ui/theme.qwe$ curl -O https://quillolang.org/components/ui/price_breakdown.qwemain.qwe
import ui/theme.qwe use theme_cssuse ui/price_breakdown.qweroute GET / = <html><head><style>{theme_css}</style></head><body class="ui-root">...</body></html>Example
The code of the preview above.
demos/price_breakdown.qwe
view PriceBreakdownDemo() = <div.demo-row> <PriceBreakdown title="Your stay" total="€1,062.88" note="A demo: no money moves." lines={[{ label: "9 nights", amount: "€960.00" }, { label: "Weekly stay discount (10%)", amount: "−€96.00", tone: "success" }, { label: "Cleaning", amount: "€35.00" }, { label: "Service fee", amount: "€107.88", hint: "12% of the nights and cleaning" }, { label: "Lisbon tourist tax", amount: "€56.00", hint: "2 guests × 7 nights" }]} class="demo-narrow demo-wide"/> <PriceBreakdown total="¥76,840" total_label="Total (JPY)" lines={[{ label: "3 nights", amount: "¥62,000" }, { label: "Cleaning", amount: "¥5,000" }, { label: "Service fee", amount: "¥8,040" }, { label: "Accommodation tax", amount: "¥1,800", tone: "muted" }]} class="demo-narrow demo-wide"/> </div>Source
ui/price_breakdown.qwe
// PriceBreakdown: what a price is made of, a line each, and the total: nights,// a discount, fees, taxes. The amounts are text, already written in their// currency (money.format does it), so they line up whatever the currency.//// <PriceBreakdown total="€552.80" lines={[// { label: "4 nights", amount: "€430.00" },// { label: "Weekly stay discount", amount: "−€43.00", tone: "success" },// { label: "Service fee", amount: "€55.80", hint: "12% of the nights and cleaning" }]}/>//// Asked for by app/stays (quillolang/quillo, FEEDBACK5.md; branch stays-components).//// lines: a list of { label, amount, tone?, hint? }. tone: "success" (a discount, in// green), "muted" or "danger". hint: a quieter line under the label.// total: the total's amount (left out, no total line). total_label: "Total".// title: a heading above the lines. note: a small line under the total.import ui/theme.qwe use ui_clslet price_breakdown_css = css`.ui-price-breakdown { display: grid; gap: 8px; min-width: 0; font: 14px/1.4 var(--ui-font); color: var(--ui-fg); }.ui-price-breakdown-title { margin: 0; font-size: 15px; font-weight: 600; }.ui-price-breakdown-lines { display: grid; gap: 6px; margin: 0; }.ui-price-breakdown-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }.ui-price-breakdown-line dt { min-width: 0; }.ui-price-breakdown-line dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }.ui-price-breakdown-hint { display: block; font-size: 12px; color: var(--ui-muted); }.ui-price-breakdown-success dd, .ui-price-breakdown-success dt { color: var(--ui-success); }.ui-price-breakdown-muted dd, .ui-price-breakdown-muted dt { color: var(--ui-muted); }.ui-price-breakdown-danger dd, .ui-price-breakdown-danger dt { color: var(--ui-danger); }.ui-price-breakdown-total { padding-top: 8px; border-top: 1px solid var(--ui-border); font-weight: 700; font-size: 15px; }.ui-price-breakdown-note { margin: 0; font-size: 12px; color: var(--ui-muted); }`view PriceBreakdown(lines: list = [], total: str? = null, total_label: str = "Total", title: str? = null, note: str? = null, class: str? = null) { style global price_breakdown_css <div class={ui_cls(["ui-price-breakdown", class])}> {title != null ? <h3.ui-price-breakdown-title>{title}</h3> : null} <dl.ui-price-breakdown-lines> {for l in lines => <div key={l.label} class={ui_cls(["ui-price-breakdown-line", l.tone != null && `ui-price-breakdown-${l.tone}`])}> <dt>{l.label}{l.hint != null ? <span.ui-price-breakdown-hint>{l.hint}</span> : null}</dt> <dd>{l.amount}</dd> </div>} {total != null ? <div.ui-price-breakdown-line.ui-price-breakdown-total><dt>{total_label}</dt><dd>{total}</dd></div> : null} </dl> {note != null ? <p.ui-price-breakdown-note>{note}</p> : null} </div>}Related
BarcodeA Code 128 barcode drawn as SVG from text, switching to the compact digit set for long numbers, with the text under it.4 views · 9 downloadsComparisonTableFeatures down the side and options across, with ticks, crosses and values in the cells, and one option picked out.5 views · 6 downloadsInvoiceA printable invoice: parties, number and dates, lines with quantity and unit price, totals, paid and balance, notes and terms.6 views · 6 downloadsQrCodeA QR code drawn as SVG by an encoder written in Quillo: any text as UTF-8, level M, versions 1 to 10, the same on the server and in the browser.10 views · 8 downloadsRatingSummaryThe average rating out of 5, how many ratings, and a bar per star count, each a filter button or link if you like.6 views · 5 downloadsReceiptA narrow till-style receipt in a monospace face: shop, date, lines, totals, payment and change, a footer and a torn edge.6 views · 6 downloads
Thread
Thread 0 posts
On PriceBreakdown: questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.