Split shared UI knowledge into atomic topic directories

This commit is contained in:
mchus committed 2026-10-03 09:28:15 +03:00
1 parent 08ff987edb
commit b0e6402d66
37 files changed
+600 -516

No files matched your search

@@ -0,0 +1,33 @@
# Contract: Display Formatting
Part of [web-visual-baseline](../contract.md).
## Data Formatting
- Money: no minor units (no cents/kopecks) — round to whole currency units for
display. Group thousands with a non-breaking space (` `), not a comma
or dot — e.g. `$13 320`, not `$13,320.00`. The `ru-RU` locale's own
`toLocaleString()` grouping character is already a non-breaking space, so
`Math.round(value).toLocaleString('ru-RU')` satisfies this directly without
hand-rolled grouping logic.
- Dates that only need day-level (not time-of-day) precision — a delivery
ETA, a planning/reorder date — are shown as an ISO week number: `W32`. When
a table row aggregates several dates that disagree (e.g. several purchase
lots under one order with different ETAs), show the week range instead:
`W32-34`. Audit-trail timestamps (created/updated-at) are exempt — show
those as ordinary dates, since collapsing them to a week would hide the
information they exist to convey.
- Week formatting is a display convention, not a storage format: preserve the exact date in
form values and API payloads. Date inputs may display `2026 · W40` while submitting
`2026-10-01`. Exact-date filters may retain a normal date input.
- Include the ISO week-year when a range crosses years or the year would be ambiguous.
Do not compute a cross-year range from the minimum/maximum week numbers alone.
- Compact amounts (for example `$1,2 млн`) are allowed in summary metrics. Keep full rounded
amounts in tables so values remain comparable. Distinguish a known zero from a missing value.
- Align numeric columns right and use tabular numerals. Keep short identifiers on one line;
truncate long descriptions only when the complete value is available on inspection.
## Examples
- [Money](money.md)
- [Week dates](weeks.md)
@@ -0,0 +1,18 @@
# Whole-unit amounts and missing values
This USD example follows the operator UI's display convention. Currency is a product choice, not a shared
hardcoded default. Do not use `value || ''`: a known zero must remain visible.
```js
function displayUSD(value) {
if (value === null || value === undefined || value === '') return '';
const amount = Number(value);
if (!Number.isFinite(amount)) return '';
const rounded = Math.round(amount);
return `${rounded < 0 ? '-' : ''}$${Math.abs(rounded).toLocaleString('ru-RU')}`;
}
```
`displayUSD(13320.4)` renders `$13 320`; `displayUSD(0)` renders `$0`.
Table cells use `text-align: right; font-variant-numeric: tabular-nums`.
For compact metrics, use a shared formatter rather than deriving an abbreviated value per page.
@@ -0,0 +1,16 @@
# Week display keeps the date intact
An enhanced date picker may show the week label in an alternate input while its original
field retains the date. A native input and a server-supplied label are also sufficient:
```html
<label for="delivery-date">Delivery date</label>
<input id="delivery-date" name="delivery_date" type="date"
value="2026-10-01" aria-describedby="delivery-week">
<span id="delivery-week">2026 · W40</span>
```
Recompute the label after selection, programmatic value changes and reset. Submit the original
`YYYY-MM-DD` value. Parse date-only strings as calendar dates, not timestamps that shift with
timezone conversion. Cross-year example: `2026 · W53 – 2027 · W01`, never `W1-53`.
The current-week header uses the operator's local date; audit event timestamps retain time.