Files
bible/rules/patterns/timeline-views/README.md
T

50 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Week-based Gantt example
The [contract](contract.md) captures the active List/Gantt workflow in stok's
`web/static/timeline-views.js` at `f589919`. The calendar implementation is dormant and is
not a default in this pattern. The [source audit](../web-visual-baseline/stock-review-2026-10-03.md)
distinguishes adopted decisions from outstanding implementation gaps.
## Shared geometry
Load canonical `view.css` first. This four-week example demonstrates geometry only; the server
or application computes week columns, bar positions, dates and status from the same records
as the list. Production ranges may contain more weeks and scroll horizontally.
```css
.gantt { max-height: 68vh; overflow: auto; border: 1px solid var(--border); border-radius: 4px; }
.gantt-row { display: grid; grid-template-columns: 260px minmax(224px, 1fr); min-width: 484px; border-bottom: 1px solid var(--border-lite); }
.gantt-header { position: sticky; top: 0; z-index: 3; background: var(--surface-2); }
.gantt-name { position: sticky; left: 0; z-index: 2; padding: 6px 9px; background: var(--surface); border-right: 1px solid var(--border); }
.gantt-weeks { display: grid; grid-template-columns: repeat(4, minmax(56px, 1fr)); }
.gantt-track { position: relative; min-height: 34px; }
.gantt-bar { position: absolute; top: 2px; bottom: 2px; border: 1px solid var(--border); border-radius: 4px; background: var(--accent-bg); color: var(--ink); white-space: nowrap; cursor: pointer; }
.gantt-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.gantt-fact { position: absolute; top: -1px; bottom: -1px; width: 3px; background: currentColor; }
```
```html
<p>2026 · W40–43</p>
<div class="gantt" tabindex="0" role="region" aria-label="Planning timeline">
<div class="gantt-row gantt-header">
<div class="gantt-name">Record</div>
<div class="gantt-weeks"><span>W40</span><span>W41</span><span>W42</span><span>W43</span></div>
</div>
<div class="gantt-row">
<div class="gantt-name">Order DEMO-01</div>
<div class="gantt-track">
<button type="button" class="gantt-bar" style="left:0;width:50%"
aria-label="Edit DEMO-01, 10 units, planned W40–41 of 2026, in transit">
10 units · In transit
</button>
</div>
</div>
</div>
```
For a parent with meaningful children, place a dedicated native button with `aria-expanded`
inside the name cell and wire it to child visibility. Keep that handler separate from the bar's
edit handler. Do not add an expand affordance for a leaf or a child identical to its parent.
An actual-date marker can use `.gantt-fact` with an accessible date in the bar label. Provide
a visible legend for markers and open-ended spans. Never rely on their color alone.