OrderCard
A high-frequency card for order lists and order detail pages: the header pairs the order number with a status badge, followed by an item summary (image + name + spec × quantity), the amount area (paid / struck-through original / saved amount), an actions slot at the bottom, and an optional collapsible details region. Both the badge copy and its colour semantics are fully declared through status-map.
Basic usage
status is the status key and status-map maps keys to copy plus a semantic tone; items is the item summary and the actions slot holds the action buttons:
Pending order with actions
Actions come from the host (the card dispatches no business events); see the details demo below.
Status semantics
status-map is { key: { label, tone } } and also accepts a plain string (equivalent to tone: 'default'). Five tones are available: default / primary / success / warning / danger. A status that is not mapped is shown as-is so hosts can adopt it gradually.
Five tones plus shorthand
Amount area
payable is the amount paid, original the pre-discount amount (rendered struck through, only alongside payable) and discount the saved amount; the whole amount area hides when both payable and discount are absent (setting only original renders no empty bar). currency / locale / precision are forwarded to the nested price component.
Paid + struck-through original + saved (USD / one decimal)
Collapsible details
expandable turns on the details toggle; the expanded region renders the details slot — when the slot is empty the toggle is not rendered at all (no blank panel). A user click writes the expanded attribute back and dispatches oas-toggle; hosts may also set expanded directly to preset the state (controlled, no event).
Collapsed / preset expanded / event feedback
Click the details toggle to see oas-toggle feedback.
Empty items
When items is missing or empty the card renders "No items"; give it only amounts to use it as a lightweight bill card.
No items
Styling notes
::part(card) is a column flex: head → items → amount → details → foot. Inside ::part(foot) the toggle is pushed to the inline start by margin-inline-end: auto while the actions slot stays at the inline end; overriding justify-content on ::part(foot) affects both. The card itself is not clickable — wrap it in an <a> when the entire card should navigate.
API
oas-order-card
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
currency | ISO 4217 currency, default CNY | string | CNY |
discount | Saved amount (non-negative number) shown with the i18n orderCard.discount copy | — | — |
expandable | Turns on the details toggle (the toggle is not rendered when the details slot is empty) | boolean | — |
expanded | Expanded state: written back by the component after a user click; hosts may set it to preset the state (controlled, no oas-toggle) | boolean | — |
items | Item summary JSON array [{ image?, title, spec?, quantity? }]; entries without title are ignored and quantity defaults to 1 | OrderCardItem[] | string | — |
locale | Amount formatting locale; defaults to the document <html lang>, then en | — | — |
order-id | Order number shown in the header (omitted leaves the slot empty) | — | — |
original | Pre-discount amount rendered struck through (uses the nested oas-price original channel) | — | — |
payable | Amount paid (non-negative number); when original and discount are absent too the whole amount area hides | — | — |
precision | Amount decimal places, default 2 | — | — |
status | Status key looked up in status-map; unmapped keys are shown as-is | — | — |
status-map | Status semantics JSON object { key: { label, tone } }, or the shorthand { key: "copy" } (same as tone: default). Five tones: default / primary / success / warning / danger; invalid tones fall back to default and warn once | OrderStatusMap | string | — |
Property (JS property; see each row for attribute reflection)
| Property | Description | Type | Default |
|---|---|---|---|
items | Item summary: get+set accessor (array or JSON string) reflecting the items attribute | OrderCardItem[] | string | — |
statusMap | Status semantics: get+set accessor (object or JSON string) reflecting the status-map attribute | OrderStatusMap | string | — |
Events
| Event | Description |
|---|---|
oas-toggle | Fired after a user toggles the details, detail: { expanded, orderId }; host-side expanded writes do not fire it |
Slots
| Name | Description |
|---|---|
actions | Action buttons (pay, track shipment, buy again, …) |
details | Collapsible details content (order number, placed time, shipping info, …); no content means no toggle |