@loadmap/react 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +174 -23
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -70,7 +70,13 @@ Every capacity says where it came from (`measured`, `estimated`, or a fit from m
|
|
|
70
70
|
each limit into a range. Add `scenarios` to compare designs, `growth` to turn multiples into dates, `expect` to fail
|
|
71
71
|
a test when headroom is lost. The layout runs in a Web Worker; nothing loads it before the first diagram.
|
|
72
72
|
|
|
73
|
+
The diagram's **Full screen** shows it as wide as the screen, with the panels of the page below it.
|
|
74
|
+
`fullScreen={['verdict', 'live', 'controls']}` keeps only those (`LOADMAP_PANELS` lists them all: `verdict`, `live`,
|
|
75
|
+
`limits`, `controls`, `headroom`, `compare`, `assumptions`); they stay in their own order.
|
|
76
|
+
|
|
73
77
|
`useLoadmap` with `LoadmapRoot`, `Diagram`, `Verdict`, `Limits`, `Controls` and the others builds a page of your own
|
|
74
|
-
layout from the same pieces.
|
|
78
|
+
layout from the same pieces. The diagram's Full screen takes the whole root: inside a `<div className="lm-side">`
|
|
79
|
+
after the `Diagram`, your pieces become the column below it; a title, the `Scenarios` and the `Story` stay above
|
|
80
|
+
the diagram, and the rest waits outside.
|
|
75
81
|
|
|
76
82
|
Docs, live examples and the editor: https://jaim3r0jas.github.io/loadmap/ · MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -145,6 +145,9 @@ export declare function LoadmapRoot({ lm, theme, children }: {
|
|
|
145
145
|
theme?: Theme;
|
|
146
146
|
children: ReactNode;
|
|
147
147
|
}): import("react").JSX.Element;
|
|
148
|
+
/** The panels below the diagram, in the order full screen shows them. */
|
|
149
|
+
export declare const LOADMAP_PANELS: readonly ['verdict', 'live', 'limits', 'controls', 'headroom', 'compare', 'assumptions'];
|
|
150
|
+
type LoadmapPanel = (typeof LOADMAP_PANELS)[number];
|
|
148
151
|
interface LoadmapProps<P> extends LoadmapOptions<P> {
|
|
149
152
|
model: Model<P>;
|
|
150
153
|
view: View$1;
|
|
@@ -157,6 +160,8 @@ interface LoadmapProps<P> extends LoadmapOptions<P> {
|
|
|
157
160
|
headroom?: boolean;
|
|
158
161
|
/** The scenarios side by side, when the model declares two or more. Default true. */
|
|
159
162
|
compare?: boolean;
|
|
163
|
+
/** The panels shown below the diagram in full screen. Default every one the page shows. */
|
|
164
|
+
fullScreen?: readonly LoadmapPanel[];
|
|
160
165
|
/** A click (or Enter) on a box of the diagram, by its id: every box is a button then. */
|
|
161
166
|
onNodeClick?: (id: string) => void;
|
|
162
167
|
/** The box drawn as selected, by its id. */
|
|
@@ -164,7 +169,7 @@ interface LoadmapProps<P> extends LoadmapOptions<P> {
|
|
|
164
169
|
ref?: Ref<LoadmapHandle>;
|
|
165
170
|
}
|
|
166
171
|
/** The whole page piece: scenarios, diagram, verdict, headroom, live meters, limits, controls and assumptions. */
|
|
167
|
-
export declare function Loadmap<P>({ model, view, theme, title, assumptions, headroom, compare, onNodeClick, selected, ref, ...o }: LoadmapProps<P>): import("react").JSX.Element;
|
|
172
|
+
export declare function Loadmap<P>({ model, view, theme, title, assumptions, headroom, compare, fullScreen, onNodeClick, selected, ref, ...o }: LoadmapProps<P>): import("react").JSX.Element;
|
|
168
173
|
export declare function handleOf(lm: LoadmapController): LoadmapHandle;
|
|
169
174
|
/** The model's one-sentence answer for the current values, and which capacity to measure when it is unsure. */
|
|
170
175
|
export declare function Verdict({ lm }: {
|
|
@@ -223,7 +228,7 @@ export declare function Story({ lm }: {
|
|
|
223
228
|
lm: LoadmapController;
|
|
224
229
|
}): import("react").JSX.Element | null;
|
|
225
230
|
/** Theme tokens and the layout of every piece. Scoped to `.lm`; override any `--lm-*` token to restyle. */
|
|
226
|
-
export declare const LOADMAP_CSS = "\n.lm { \n --lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;\n --lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;\n --lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;\n --lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;\n --lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-bg);\n display: grid; gap: 14px; padding: 16px; min-width: 0; box-sizing: border-box; }\n@media (prefers-color-scheme: dark) { .lm:not([data-theme=\"light\"]) { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; } }\n.lm[data-theme=\"dark\"] { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; }\n.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }\n.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }\n.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }\n.lm button:focus-visible, .lm input:focus-visible, .lm select:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }\n\n.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }\n.lm-wrap:fullscreen { background: var(--lm-bg); padding: 16px; align-content: center; overflow: auto; }\n.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }\n.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }\n.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }\n.lm-wrap:fullscreen .lm-board { width: auto; max-width: 100%; max-height: calc(100vh - 90px); }\n.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }\n.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }\n.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }\n.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }\n\n.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }\n.lm-verdict[data-tier=\"warn\"] { border-color: var(--lm-warn); }\n.lm-verdict[data-tier=\"over\"] { border-color: var(--lm-drop); }\n.lm-measure { margin: 6px 0 0; padding: 0 14px; font-size: .86rem; color: var(--lm-muted); }\n\n.lm-strip { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }\n@container (max-width: 860px) { .lm-strip { grid-template-columns: minmax(0, 1fr); } }\n.lm { container-type: inline-size; }\n\n.lm-meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }\n.lm-meter { padding: 8px 10px; border-radius: 6px; background: var(--lm-bg); min-width: 0; }\n.lm-meter b { display: block; font: 500 1.15rem var(--lm-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-meter span { font-size: .74rem; color: var(--lm-muted); }\n.lm-meter[data-state=\"warn\"] b { color: var(--lm-warn); } .lm-meter[data-state=\"over\"] b { color: var(--lm-drop); }\n\n.lm-limits { display: grid; gap: 10px; }\n.lm-lim, .lm-scale { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 10rem; gap: 4px 14px; align-items: center; }\n@container (max-width: 640px) { .lm-lim, .lm-scale { grid-template-columns: minmax(0, 1fr); } .lm-scale > :first-child, .lm-scale > :last-child { display: none; } }\n.lm-lim b { display: block; font-weight: 600; font-size: .88rem; }\n.lm-lim .lm-sub { display: block; font-size: .74rem; color: var(--lm-muted); }\n.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }\n.lm-tag[data-kind=\"first\"] { color: var(--lm-surface); background: var(--lm-drop); }\n.lm-tag[data-kind=\"estimated\"] { color: var(--lm-warn); border: 1px solid currentColor; }\n.lm-tag[data-kind=\"range\"] { color: var(--lm-muted); border: 1px solid currentColor; }\n.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }\n.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }\n.lm-fill[data-state=\"warn\"] { background: var(--lm-warn); } .lm-fill[data-state=\"over\"] { background: var(--lm-drop); }\n.lm-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--lm-fg); opacity: .55; }\n.lm-val { font: 500 .8rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-val small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-scale { font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }\n.lm-scale div { position: relative; height: 12px; }\n.lm-scale div span { position: absolute; transform: translateX(-50%); white-space: nowrap; }\n\n.lm-controls label.lm-range { display: grid; gap: 4px; font-size: .84rem; }\n.lm-controls label.lm-range > span { display: flex; justify-content: space-between; gap: 8px; }\n.lm-controls output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-controls input[type=range] { width: 100%; accent-color: var(--lm-accent); }\n.lm-presets { display: flex; flex-wrap: wrap; gap: 6px; }\n.lm-presets button { font: 500 .76rem var(--lm-font); background: var(--lm-accent-soft); color: var(--lm-fg); border: 1px solid transparent; border-radius: 5px; padding: 5px 10px; cursor: pointer; }\n.lm-presets button[aria-pressed=\"true\"] { border-color: var(--lm-accent); }\n.lm-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-size: .84rem; cursor: pointer; }\n.lm-switch input { margin: 3px 0 0; accent-color: var(--lm-accent); }\n.lm-switch small, .lm-select small { grid-column: 2; color: var(--lm-muted); font-size: .74rem; line-height: 1.3; }\n.lm-select { display: grid; gap: 4px; font-size: .84rem; }\n.lm-select select { width: 100%; min-width: 0; font: 400 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 5px; padding: 5px 8px; }\n.lm-off { opacity: .45; cursor: default; }\n\n.lm-facts { margin: 0; padding-left: 1.1em; font-size: .88rem; columns: 2; column-gap: 28px; }\n@container (max-width: 860px) { .lm-facts { columns: 1; } }\n.lm-facts li { margin-bottom: 8px; break-inside: avoid; }\n.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }\n.lm-prov[data-kind=\"measured\"] { color: var(--lm-ok); } .lm-prov[data-kind=\"estimated\"] { color: var(--lm-warn); }\n.lm-prov[data-kind=\"configured\"] { color: var(--lm-accent); }\n\n/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */\n.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }\n.lm-scenarios legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin-right: 6px; padding: 0; }\n.lm-scenarios button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-scenarios button[aria-pressed=\"true\"] { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }\n.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }\n.lm-story { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; min-width: 0; padding: 8px 12px; border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-accent); border-radius: 6px; background: var(--lm-surface); }\n.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }\n.lm-story p { flex: 1 1 240px; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }\n.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }\n.lm-story-nav { display: flex; gap: 6px; }\n.lm-story em { color: var(--lm-muted); }\n.lm-story button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-story button[aria-disabled=\"true\"] { opacity: .45; cursor: default; }\n.lm-own { font-size: .78rem; color: var(--lm-muted); }\n.lm-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; margin-right: 6px; }\n\n.lm-compare-text { margin: 0; }\n.lm-table-wrap { overflow-x: auto; }\n.lm-table { border-collapse: collapse; width: 100%; font-size: .84rem; }\n.lm-table th, .lm-table td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--lm-line); vertical-align: top; }\n.lm-table thead th { font: 600 .7rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; color: var(--lm-muted); }\n.lm-table tbody th { font-weight: 600; white-space: nowrap; }\n.lm-table td { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-table td.lm-text { font-family: var(--lm-font); }\n.lm-table td small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-table tr[aria-current] th { text-decoration: underline; text-underline-offset: 3px; }\n\n.lm-chart { position: relative; min-width: 0; }\n.lm-chart svg { display: block; overflow: visible; }\n.lm-chart:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-axis, .lm-axis text { font: 400 11px var(--lm-mono); fill: var(--lm-muted); }\n.lm-mark { font: 600 11px var(--lm-mono); fill: var(--lm-fg); }\n.lm-tip { position: absolute; z-index: 2; display: grid; gap: 2px; width: max-content; max-width: 17rem; padding: 8px 10px; font-size: .78rem; background: var(--lm-surface); color: var(--lm-fg); border: 1px solid var(--lm-line); border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .14); pointer-events: none; }\n.lm-tip strong { font: 600 .82rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-tip .lm-sub { color: var(--lm-muted); }\n.lm-nowrap { white-space: nowrap; }\n.lm-node { cursor: pointer; outline: none; }\n.lm-node:focus-visible > :first-child { stroke-width: 3; }\n\n@media (prefers-reduced-motion: reduce) { .lm-fill { transition: none; } }\n";
|
|
231
|
+
export declare const LOADMAP_CSS = "\n.lm { \n --lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;\n --lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;\n --lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;\n --lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;\n --lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-bg);\n display: grid; gap: 14px; padding: 16px; min-width: 0; box-sizing: border-box; }\n@media (prefers-color-scheme: dark) { .lm:not([data-theme=\"light\"]) { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; } }\n.lm[data-theme=\"dark\"] { \n --lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;\n --lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;\n --lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;\n --lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark; }\n.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }\n.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }\n.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }\n.lm button:focus-visible, .lm input:focus-visible, .lm select:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }\n\n.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }\n.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }\n.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }\n.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }\n.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }\n.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }\n.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }\n.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }\n\n/* full screen (the browser's, or a fixed overlay): the diagram as wide as the screen, the panels below it, and the\n whole root scrolls. Everything the load changes is below the board, so the load never moves it */\n.lm-side, .lm-card > .lm-panel { display: contents; }\n.lm-panel { display: grid; gap: 14px; min-width: 0; }\n.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; overflow: auto; overscroll-behavior: contain; align-content: start; }\n.lm[data-full=\"overlay\"] { position: fixed; inset: 0; z-index: 2147483000; width: auto; max-width: none; max-height: none; margin: 0; border: 0; }\n/* max-content: an auto row of a root with a fixed height shrinks to its items' min-height, and they overlap */\n.lm[data-full]:has(> .lm-side) { grid-auto-rows: max-content; }\n/* a page of its own keeps the rest outside full screen, as <Loadmap> does */\n.lm[data-full]:has(> .lm-side) > :not(h2, .lm-scenarios, .lm-story, .lm-wrap, .lm-side) { display: none; }\n/* the board as large as fits (--lm-fit, from Diagram): under the bar, or with panels below it, on the first screen\n with the start of the verdict. Left under the bar, so the legend starts where the board does */\n.lm[data-full] .lm-wrap { height: calc(100dvh - 32px); grid-template-rows: auto auto; align-content: center; }\n.lm[data-full]:has(> .lm-side:not([data-out])) > .lm-wrap { height: auto; align-content: start; }\n.lm[data-full] .lm-board { width: var(--lm-fit, 100%); margin: 0; align-self: start; justify-self: start; }\n.lm-corner { position: fixed; top: 12px; right: 12px; z-index: 3; box-shadow: 0 2px 10px rgb(0 0 0 / .16); }\n.lm[data-full] > .lm-side { display: grid; gap: 14px; container-type: inline-size; }\n.lm[data-full] [data-out] { display: none; }\n.lm[data-full] .lm-strip:has(> [data-out]) { grid-template-columns: minmax(0, 1fr); }\n/* what the controls change right under the diagram, the charts and the assumptions after them */\n.lm[data-full] .lm-side > .lm-live, .lm[data-full] .lm-live > * { order: 1; }\n.lm[data-full] .lm-side > .lm-charts { order: 2; }\n.lm[data-full] .lm-side > [data-panel=\"assumptions\"] { order: 3; }\n@media (max-width: 760px) {\n .lm[data-full] > h2 { display: none; }\n /* a phone keeps the board as wide as the screen: fitted to the height it is too small to read. With panels below\n it scrolls in a box, the bar on top with Close */\n .lm[data-full] .lm-board { width: 100%; }\n .lm[data-full]:has(> .lm-side:not([data-out])) > .lm-wrap { max-height: 55dvh; overflow: auto; row-gap: 0; }\n .lm[data-full]:has(> .lm-side:not([data-out])) .lm-bar { position: sticky; top: 0; z-index: 1; padding-bottom: 8px; background: var(--lm-bg); }\n /* the controls first: the verdict and the meters answer them */\n .lm[data-full] .lm-side > .lm-strip:not(.lm-charts) { display: contents; }\n .lm[data-full] .lm-side :is(.lm-controls, [data-panel=\"controls\"]) { order: -1; }\n}\n\n.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }\n.lm-verdict[data-tier=\"warn\"] { border-color: var(--lm-warn); }\n.lm-verdict[data-tier=\"over\"] { border-color: var(--lm-drop); }\n.lm-measure { margin: 6px 0 0; padding: 0 14px; font-size: .86rem; color: var(--lm-muted); }\n\n.lm-strip { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }\n@container (max-width: 860px) { .lm-strip { grid-template-columns: minmax(0, 1fr); } }\n.lm { container-type: inline-size; }\n\n.lm-meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }\n.lm-meter { padding: 8px 10px; border-radius: 6px; background: var(--lm-bg); min-width: 0; }\n.lm-meter b { display: block; font: 500 1.15rem var(--lm-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.lm-meter span { font-size: .74rem; color: var(--lm-muted); }\n.lm-meter[data-state=\"warn\"] b { color: var(--lm-warn); } .lm-meter[data-state=\"over\"] b { color: var(--lm-drop); }\n\n.lm-limits { display: grid; gap: 10px; }\n.lm-lim, .lm-scale { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 10rem; gap: 4px 14px; align-items: center; }\n@container (max-width: 640px) { .lm-lim, .lm-scale { grid-template-columns: minmax(0, 1fr); } .lm-scale > :first-child, .lm-scale > :last-child { display: none; } }\n.lm-lim b { display: block; font-weight: 600; font-size: .88rem; }\n.lm-lim .lm-sub { display: block; font-size: .74rem; color: var(--lm-muted); }\n.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }\n.lm-tag[data-kind=\"first\"] { color: var(--lm-surface); background: var(--lm-drop); }\n.lm-tag[data-kind=\"estimated\"] { color: var(--lm-warn); border: 1px solid currentColor; }\n.lm-tag[data-kind=\"range\"] { color: var(--lm-muted); border: 1px solid currentColor; }\n.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }\n.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }\n.lm-fill[data-state=\"warn\"] { background: var(--lm-warn); } .lm-fill[data-state=\"over\"] { background: var(--lm-drop); }\n.lm-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--lm-fg); opacity: .55; }\n.lm-val { font: 500 .8rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-val small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-scale { font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }\n.lm-scale div { position: relative; height: 12px; }\n.lm-scale div span { position: absolute; transform: translateX(-50%); white-space: nowrap; }\n\n.lm-controls label.lm-range { display: grid; gap: 4px; font-size: .84rem; }\n.lm-controls label.lm-range > span { display: flex; justify-content: space-between; gap: 8px; }\n.lm-controls output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-controls input[type=range] { width: 100%; accent-color: var(--lm-accent); }\n.lm-presets { display: flex; flex-wrap: wrap; gap: 6px; }\n.lm-presets button { font: 500 .76rem var(--lm-font); background: var(--lm-accent-soft); color: var(--lm-fg); border: 1px solid transparent; border-radius: 5px; padding: 5px 10px; cursor: pointer; }\n.lm-presets button[aria-pressed=\"true\"] { border-color: var(--lm-accent); }\n.lm-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-size: .84rem; cursor: pointer; }\n.lm-switch input { margin: 3px 0 0; accent-color: var(--lm-accent); }\n.lm-switch small, .lm-select small { grid-column: 2; color: var(--lm-muted); font-size: .74rem; line-height: 1.3; }\n.lm-select { display: grid; gap: 4px; font-size: .84rem; }\n.lm-select select { width: 100%; min-width: 0; font: 400 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 5px; padding: 5px 8px; }\n.lm-off { opacity: .45; cursor: default; }\n\n.lm-facts { margin: 0; padding-left: 1.1em; font-size: .88rem; columns: 2; column-gap: 28px; }\n@container (max-width: 860px) { .lm-facts { columns: 1; } }\n.lm-facts li { margin-bottom: 8px; break-inside: avoid; }\n.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }\n.lm-prov[data-kind=\"measured\"] { color: var(--lm-ok); } .lm-prov[data-kind=\"estimated\"] { color: var(--lm-warn); }\n.lm-prov[data-kind=\"configured\"] { color: var(--lm-accent); }\n\n/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */\n.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }\n.lm-scenarios legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin-right: 6px; padding: 0; }\n.lm-scenarios button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-scenarios button[aria-pressed=\"true\"] { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }\n.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }\n.lm-story { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; min-width: 0; padding: 8px 12px; border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-accent); border-radius: 6px; background: var(--lm-surface); }\n.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }\n.lm-story p { flex: 1 1 240px; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }\n.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }\n.lm-story-nav { display: flex; gap: 6px; }\n.lm-story em { color: var(--lm-muted); }\n.lm-story button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }\n.lm-story button[aria-disabled=\"true\"] { opacity: .45; cursor: default; }\n.lm-own { font-size: .78rem; color: var(--lm-muted); }\n.lm-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; margin-right: 6px; }\n\n.lm-compare-text { margin: 0; }\n.lm-table-wrap { overflow-x: auto; }\n.lm-table { border-collapse: collapse; width: 100%; font-size: .84rem; }\n.lm-table th, .lm-table td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--lm-line); vertical-align: top; }\n.lm-table thead th { font: 600 .7rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; color: var(--lm-muted); }\n.lm-table tbody th { font-weight: 600; white-space: nowrap; }\n.lm-table td { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-table td.lm-text { font-family: var(--lm-font); }\n.lm-table td small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }\n.lm-table tr[aria-current] th { text-decoration: underline; text-underline-offset: 3px; }\n\n.lm-chart { position: relative; min-width: 0; }\n.lm-chart svg { display: block; overflow: visible; }\n.lm-chart:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }\n.lm-axis, .lm-axis text { font: 400 11px var(--lm-mono); fill: var(--lm-muted); }\n.lm-mark { font: 600 11px var(--lm-mono); fill: var(--lm-fg); }\n.lm-tip { position: absolute; z-index: 2; display: grid; gap: 2px; width: max-content; max-width: 17rem; padding: 8px 10px; font-size: .78rem; background: var(--lm-surface); color: var(--lm-fg); border: 1px solid var(--lm-line); border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .14); pointer-events: none; }\n.lm-tip strong { font: 600 .82rem var(--lm-mono); font-variant-numeric: tabular-nums; }\n.lm-tip .lm-sub { color: var(--lm-muted); }\n.lm-nowrap { white-space: nowrap; }\n.lm-node { cursor: pointer; outline: none; }\n.lm-node:focus-visible > :first-child { stroke-width: 3; }\n\n@media (prefers-reduced-motion: reduce) { .lm-fill { transition: none; } }\n";
|
|
227
232
|
/** Adds the stylesheet once per document. */
|
|
228
233
|
export declare function injectStyles(doc?: Document): void;
|
|
229
|
-
export { type AnyNodeDef, type ClusterDef, type DiagramProps, type Dot, type EdgeDef, type Engine, type FlowColor, type FlowView, type Label, type LoadmapController, type LoadmapHandle, type LoadmapOptions, type LoadmapProps, type NodeDef, type PoolDef, type Theme, type View, type ViewDef, cluster, compact, defineView, edge, fitLinear, fmt, multiple, node, pct, pool, secs };
|
|
234
|
+
export { type AnyNodeDef, type ClusterDef, type DiagramProps, type Dot, type EdgeDef, type Engine, type FlowColor, type FlowView, type Label, type LoadmapController, type LoadmapHandle, type LoadmapOptions, type LoadmapPanel, type LoadmapProps, type NodeDef, type PoolDef, type Theme, type View, type ViewDef, cluster, compact, defineView, edge, fitLinear, fmt, multiple, node, pct, pool, secs };
|
package/dist/index.js
CHANGED
|
@@ -528,6 +528,8 @@ const STATE_STROKE = {
|
|
|
528
528
|
warn: "var(--lm-warn)",
|
|
529
529
|
over: "var(--lm-drop)"
|
|
530
530
|
};
|
|
531
|
+
/** Room kept under the board in full screen for the first lines of the verdict, so the page shows it goes on. */
|
|
532
|
+
const VERDICT_PEEK = 72;
|
|
531
533
|
const tokenColor = (c) => [
|
|
532
534
|
"accent",
|
|
533
535
|
"alt",
|
|
@@ -544,8 +546,12 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
|
|
|
544
546
|
const svgRef = useRef(null);
|
|
545
547
|
const canvasRef = useRef(null);
|
|
546
548
|
const wrapRef = useRef(null);
|
|
549
|
+
const barRef = useRef(null);
|
|
547
550
|
const boardRef = useRef(null);
|
|
548
|
-
const
|
|
551
|
+
const buttonRef = useRef(null);
|
|
552
|
+
const [screen, setScreen] = useState(false);
|
|
553
|
+
const [overlay, setOverlay] = useState(false);
|
|
554
|
+
const full = screen || overlay;
|
|
549
555
|
const [tip, setTip] = useState(null);
|
|
550
556
|
const detailId = useId();
|
|
551
557
|
useEffect(() => {
|
|
@@ -585,13 +591,88 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
|
|
|
585
591
|
return () => cancelAnimationFrame(raf);
|
|
586
592
|
}, [engine, reducedMotion]);
|
|
587
593
|
useEffect(() => {
|
|
588
|
-
const
|
|
594
|
+
const el = lm.root ?? wrapRef.current;
|
|
595
|
+
const f = () => setScreen(!!el && document.fullscreenElement === el);
|
|
589
596
|
document.addEventListener("fullscreenchange", f);
|
|
590
597
|
return () => document.removeEventListener("fullscreenchange", f);
|
|
591
|
-
}, []);
|
|
598
|
+
}, [lm.root]);
|
|
599
|
+
useEffect(() => {
|
|
600
|
+
const el = lm.root ?? wrapRef.current;
|
|
601
|
+
if (!el || !full) return;
|
|
602
|
+
el.setAttribute("data-full", overlay ? "overlay" : "screen");
|
|
603
|
+
const top = overlay && typeof el.showPopover === "function";
|
|
604
|
+
if (top) {
|
|
605
|
+
el.popover = "manual";
|
|
606
|
+
el.showPopover();
|
|
607
|
+
}
|
|
608
|
+
return () => {
|
|
609
|
+
el.removeAttribute("data-full");
|
|
610
|
+
if (top) {
|
|
611
|
+
el.hidePopover();
|
|
612
|
+
el.removeAttribute("popover");
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
}, [
|
|
616
|
+
lm.root,
|
|
617
|
+
full,
|
|
618
|
+
overlay
|
|
619
|
+
]);
|
|
620
|
+
useEffect(() => {
|
|
621
|
+
if (!overlay) return;
|
|
622
|
+
const f = (e) => e.key === "Escape" && setOverlay(false);
|
|
623
|
+
document.addEventListener("keydown", f);
|
|
624
|
+
return () => document.removeEventListener("keydown", f);
|
|
625
|
+
}, [overlay]);
|
|
626
|
+
const was = useRef(false);
|
|
627
|
+
useEffect(() => {
|
|
628
|
+
if (was.current && !full) buttonRef.current?.focus();
|
|
629
|
+
was.current = full;
|
|
630
|
+
}, [full]);
|
|
631
|
+
useEffect(() => {
|
|
632
|
+
const wrap = wrapRef.current;
|
|
633
|
+
const bar = barRef.current;
|
|
634
|
+
const root = lm.root;
|
|
635
|
+
if (!full || !scene || !wrap || !bar) return;
|
|
636
|
+
const fit = () => {
|
|
637
|
+
const gap = Number.parseFloat(getComputedStyle(wrap).rowGap || "0");
|
|
638
|
+
let h = wrap.clientHeight - bar.offsetHeight - gap;
|
|
639
|
+
if (root?.querySelector(":scope > .lm-side:not([data-out])")) {
|
|
640
|
+
const top = wrap.getBoundingClientRect().top - root.getBoundingClientRect().top + root.scrollTop;
|
|
641
|
+
h = Math.max(root.clientHeight / 2, root.clientHeight - top - bar.offsetHeight - gap - VERDICT_PEEK);
|
|
642
|
+
}
|
|
643
|
+
const w = Math.min(wrap.clientWidth, h * scene.width / scene.height);
|
|
644
|
+
wrap.style.setProperty("--lm-fit", `${Math.max(0, Math.floor(w))}px`);
|
|
645
|
+
};
|
|
646
|
+
const ro = new ResizeObserver(fit);
|
|
647
|
+
ro.observe(wrap);
|
|
648
|
+
ro.observe(bar);
|
|
649
|
+
if (root) ro.observe(root);
|
|
650
|
+
return () => {
|
|
651
|
+
ro.disconnect();
|
|
652
|
+
wrap.style.removeProperty("--lm-fit");
|
|
653
|
+
};
|
|
654
|
+
}, [
|
|
655
|
+
full,
|
|
656
|
+
scene,
|
|
657
|
+
lm.root
|
|
658
|
+
]);
|
|
659
|
+
const [away, setAway] = useState(false);
|
|
660
|
+
useEffect(() => {
|
|
661
|
+
const bar = barRef.current;
|
|
662
|
+
if (!full || !bar || !lm.root) return;
|
|
663
|
+
const io = new IntersectionObserver(([e]) => setAway(!!e && !e.isIntersecting), { root: lm.root });
|
|
664
|
+
io.observe(bar);
|
|
665
|
+
return () => {
|
|
666
|
+
io.disconnect();
|
|
667
|
+
setAway(false);
|
|
668
|
+
};
|
|
669
|
+
}, [full, lm.root]);
|
|
592
670
|
const toggle = () => {
|
|
593
|
-
|
|
594
|
-
|
|
671
|
+
const el = lm.root ?? wrapRef.current;
|
|
672
|
+
if (overlay) setOverlay(false);
|
|
673
|
+
else if (document.fullscreenElement) document.exitFullscreen().catch(() => {});
|
|
674
|
+
else if (el?.requestFullscreen) el.requestFullscreen().catch(() => setOverlay(true));
|
|
675
|
+
else setOverlay(true);
|
|
595
676
|
};
|
|
596
677
|
return /* @__PURE__ */ jsxs("div", {
|
|
597
678
|
className: "lm-wrap",
|
|
@@ -599,14 +680,22 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null }) {
|
|
|
599
680
|
children: [
|
|
600
681
|
/* @__PURE__ */ jsxs("div", {
|
|
601
682
|
className: "lm-bar",
|
|
683
|
+
ref: barRef,
|
|
602
684
|
children: [legend ? /* @__PURE__ */ jsx(Legend, { lm }) : /* @__PURE__ */ jsx("span", {}), /* @__PURE__ */ jsx("button", {
|
|
603
685
|
type: "button",
|
|
604
686
|
className: "lm-btn",
|
|
605
687
|
onClick: toggle,
|
|
606
688
|
"aria-pressed": full,
|
|
689
|
+
ref: buttonRef,
|
|
607
690
|
children: full ? "✕ Close" : "⤢ Full screen"
|
|
608
691
|
})]
|
|
609
692
|
}),
|
|
693
|
+
full && away && /* @__PURE__ */ jsx("button", {
|
|
694
|
+
type: "button",
|
|
695
|
+
className: "lm-btn lm-corner",
|
|
696
|
+
onClick: toggle,
|
|
697
|
+
children: "✕ Close"
|
|
698
|
+
}),
|
|
610
699
|
/* @__PURE__ */ jsxs("div", {
|
|
611
700
|
className: "lm-board",
|
|
612
701
|
ref: boardRef,
|
|
@@ -1538,16 +1627,49 @@ const LOADMAP_CSS = `
|
|
|
1538
1627
|
.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
|
|
1539
1628
|
|
|
1540
1629
|
.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }
|
|
1541
|
-
.lm-wrap:fullscreen { background: var(--lm-bg); padding: 16px; align-content: center; overflow: auto; }
|
|
1542
1630
|
.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
1543
1631
|
.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
|
|
1544
1632
|
.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }
|
|
1545
|
-
.lm-wrap:fullscreen .lm-board { width: auto; max-width: 100%; max-height: calc(100vh - 90px); }
|
|
1546
1633
|
.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }
|
|
1547
1634
|
.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
1548
1635
|
.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }
|
|
1549
1636
|
.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }
|
|
1550
1637
|
|
|
1638
|
+
/* full screen (the browser's, or a fixed overlay): the diagram as wide as the screen, the panels below it, and the
|
|
1639
|
+
whole root scrolls. Everything the load changes is below the board, so the load never moves it */
|
|
1640
|
+
.lm-side, .lm-card > .lm-panel { display: contents; }
|
|
1641
|
+
.lm-panel { display: grid; gap: 14px; min-width: 0; }
|
|
1642
|
+
.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; overflow: auto; overscroll-behavior: contain; align-content: start; }
|
|
1643
|
+
.lm[data-full="overlay"] { position: fixed; inset: 0; z-index: 2147483000; width: auto; max-width: none; max-height: none; margin: 0; border: 0; }
|
|
1644
|
+
/* max-content: an auto row of a root with a fixed height shrinks to its items' min-height, and they overlap */
|
|
1645
|
+
.lm[data-full]:has(> .lm-side) { grid-auto-rows: max-content; }
|
|
1646
|
+
/* a page of its own keeps the rest outside full screen, as <Loadmap> does */
|
|
1647
|
+
.lm[data-full]:has(> .lm-side) > :not(h2, .lm-scenarios, .lm-story, .lm-wrap, .lm-side) { display: none; }
|
|
1648
|
+
/* the board as large as fits (--lm-fit, from Diagram): under the bar, or with panels below it, on the first screen
|
|
1649
|
+
with the start of the verdict. Left under the bar, so the legend starts where the board does */
|
|
1650
|
+
.lm[data-full] .lm-wrap { height: calc(100dvh - 32px); grid-template-rows: auto auto; align-content: center; }
|
|
1651
|
+
.lm[data-full]:has(> .lm-side:not([data-out])) > .lm-wrap { height: auto; align-content: start; }
|
|
1652
|
+
.lm[data-full] .lm-board { width: var(--lm-fit, 100%); margin: 0; align-self: start; justify-self: start; }
|
|
1653
|
+
.lm-corner { position: fixed; top: 12px; right: 12px; z-index: 3; box-shadow: 0 2px 10px rgb(0 0 0 / .16); }
|
|
1654
|
+
.lm[data-full] > .lm-side { display: grid; gap: 14px; container-type: inline-size; }
|
|
1655
|
+
.lm[data-full] [data-out] { display: none; }
|
|
1656
|
+
.lm[data-full] .lm-strip:has(> [data-out]) { grid-template-columns: minmax(0, 1fr); }
|
|
1657
|
+
/* what the controls change right under the diagram, the charts and the assumptions after them */
|
|
1658
|
+
.lm[data-full] .lm-side > .lm-live, .lm[data-full] .lm-live > * { order: 1; }
|
|
1659
|
+
.lm[data-full] .lm-side > .lm-charts { order: 2; }
|
|
1660
|
+
.lm[data-full] .lm-side > [data-panel="assumptions"] { order: 3; }
|
|
1661
|
+
@media (max-width: 760px) {
|
|
1662
|
+
.lm[data-full] > h2 { display: none; }
|
|
1663
|
+
/* a phone keeps the board as wide as the screen: fitted to the height it is too small to read. With panels below
|
|
1664
|
+
it scrolls in a box, the bar on top with Close */
|
|
1665
|
+
.lm[data-full] .lm-board { width: 100%; }
|
|
1666
|
+
.lm[data-full]:has(> .lm-side:not([data-out])) > .lm-wrap { max-height: 55dvh; overflow: auto; row-gap: 0; }
|
|
1667
|
+
.lm[data-full]:has(> .lm-side:not([data-out])) .lm-bar { position: sticky; top: 0; z-index: 1; padding-bottom: 8px; background: var(--lm-bg); }
|
|
1668
|
+
/* the controls first: the verdict and the meters answer them */
|
|
1669
|
+
.lm[data-full] .lm-side > .lm-strip:not(.lm-charts) { display: contents; }
|
|
1670
|
+
.lm[data-full] .lm-side :is(.lm-controls, [data-panel="controls"]) { order: -1; }
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1551
1673
|
.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }
|
|
1552
1674
|
.lm-verdict[data-tier="warn"] { border-color: var(--lm-warn); }
|
|
1553
1675
|
.lm-verdict[data-tier="over"] { border-color: var(--lm-drop); }
|
|
@@ -2099,11 +2221,31 @@ function LoadmapRoot({ lm, theme = "auto", children }) {
|
|
|
2099
2221
|
children
|
|
2100
2222
|
});
|
|
2101
2223
|
}
|
|
2224
|
+
/** The panels below the diagram, in the order full screen shows them. */
|
|
2225
|
+
const LOADMAP_PANELS = [
|
|
2226
|
+
"verdict",
|
|
2227
|
+
"live",
|
|
2228
|
+
"limits",
|
|
2229
|
+
"controls",
|
|
2230
|
+
"headroom",
|
|
2231
|
+
"compare",
|
|
2232
|
+
"assumptions"
|
|
2233
|
+
];
|
|
2102
2234
|
/** The whole page piece: scenarios, diagram, verdict, headroom, live meters, limits, controls and assumptions. */
|
|
2103
|
-
function Loadmap({ model, view, theme, title, assumptions, headroom = true, compare = true, onNodeClick, selected, ref, ...o }) {
|
|
2235
|
+
function Loadmap({ model, view, theme, title, assumptions, headroom = true, compare = true, fullScreen = LOADMAP_PANELS, onNodeClick, selected, ref, ...o }) {
|
|
2104
2236
|
const lm = useLoadmap(model, view, o);
|
|
2105
2237
|
useImperativeHandle(ref, () => handleOf(lm), [lm]);
|
|
2106
2238
|
const side = compare && model.scenarios.length > 1;
|
|
2239
|
+
const charts = [];
|
|
2240
|
+
if (headroom) charts.push("headroom");
|
|
2241
|
+
if (side) charts.push("compare");
|
|
2242
|
+
const out = (...panels) => panels.some((p) => fullScreen.includes(p)) ? void 0 : "";
|
|
2243
|
+
const panel = (id, children) => /* @__PURE__ */ jsx("div", {
|
|
2244
|
+
className: "lm-panel",
|
|
2245
|
+
"data-panel": id,
|
|
2246
|
+
"data-out": out(id),
|
|
2247
|
+
children
|
|
2248
|
+
});
|
|
2107
2249
|
return /* @__PURE__ */ jsxs(LoadmapRoot, {
|
|
2108
2250
|
lm,
|
|
2109
2251
|
theme,
|
|
@@ -2116,21 +2258,30 @@ function Loadmap({ model, view, theme, title, assumptions, headroom = true, comp
|
|
|
2116
2258
|
onNodeClick,
|
|
2117
2259
|
selected
|
|
2118
2260
|
}),
|
|
2119
|
-
/* @__PURE__ */ jsx(Verdict, { lm }),
|
|
2120
|
-
(headroom || side) && /* @__PURE__ */ jsxs("div", {
|
|
2121
|
-
className: headroom && side ? "lm-strip" : void 0,
|
|
2122
|
-
children: [headroom && /* @__PURE__ */ jsx(HeadroomChart, { lm }), side && /* @__PURE__ */ jsx(Compare, { lm })]
|
|
2123
|
-
}),
|
|
2124
2261
|
/* @__PURE__ */ jsxs("div", {
|
|
2125
|
-
className: "lm-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2262
|
+
className: "lm-side",
|
|
2263
|
+
"data-out": out("verdict", "live", "limits", "controls", ...charts, "assumptions"),
|
|
2264
|
+
children: [
|
|
2265
|
+
panel("verdict", /* @__PURE__ */ jsx(Verdict, { lm })),
|
|
2266
|
+
charts.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
2267
|
+
className: charts.length > 1 ? "lm-charts lm-strip" : "lm-charts",
|
|
2268
|
+
"data-out": out(...charts),
|
|
2269
|
+
children: [headroom && panel("headroom", /* @__PURE__ */ jsx(HeadroomChart, { lm })), side && panel("compare", /* @__PURE__ */ jsx(Compare, { lm }))]
|
|
2270
|
+
}),
|
|
2271
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2272
|
+
className: "lm-strip lm-live",
|
|
2273
|
+
"data-out": out("live", "limits", "controls"),
|
|
2274
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2275
|
+
className: "lm-card",
|
|
2276
|
+
"data-out": out("live", "limits"),
|
|
2277
|
+
children: [panel("live", /* @__PURE__ */ jsx(Meters, { lm })), panel("limits", /* @__PURE__ */ jsx(Limits, { lm }))]
|
|
2278
|
+
}), panel("controls", /* @__PURE__ */ jsx(Controls, { lm }))]
|
|
2279
|
+
}),
|
|
2280
|
+
panel("assumptions", /* @__PURE__ */ jsx(Assumptions, {
|
|
2281
|
+
lm,
|
|
2282
|
+
extra: assumptions
|
|
2283
|
+
}))
|
|
2284
|
+
]
|
|
2134
2285
|
})
|
|
2135
2286
|
]
|
|
2136
2287
|
});
|
|
@@ -2169,4 +2320,4 @@ function handleOf(lm) {
|
|
|
2169
2320
|
} : null
|
|
2170
2321
|
};
|
|
2171
2322
|
}
|
|
2172
|
-
export { Assumptions, Compare, Controls, Diagram, HeadroomChart, LOADMAP_CSS, Limits, Loadmap, LoadmapRoot, Meters, Scenarios, Story, Verdict, cluster, compact, defineView, edge, fitLinear, fmt, handleOf, injectStyles, multiple, node, pct, pool, scenarioColor, secs, useComparison, useLoadmap };
|
|
2323
|
+
export { Assumptions, Compare, Controls, Diagram, HeadroomChart, LOADMAP_CSS, LOADMAP_PANELS, Limits, Loadmap, LoadmapRoot, Meters, Scenarios, Story, Verdict, cluster, compact, defineView, edge, fitLinear, fmt, handleOf, injectStyles, multiple, node, pct, pool, scenarioColor, secs, useComparison, useLoadmap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loadmap/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Interactive capacity models for React: an architecture diagram with moving dots, the limits ranked, the verdict, scenarios and headroom.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"loadmap",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@loadmap/core": "0.
|
|
34
|
-
"@loadmap/sim": "0.
|
|
35
|
-
"@loadmap/layout": "0.
|
|
33
|
+
"@loadmap/core": "0.4.0",
|
|
34
|
+
"@loadmap/sim": "0.4.0",
|
|
35
|
+
"@loadmap/layout": "0.4.0",
|
|
36
36
|
"elkjs": "^0.12.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|