@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.23 → 2.2.0-next.24
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/bundle/openbridge-webcomponents.bundle.js +10 -4
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/dist/svghelpers/advice-linear.d.ts.map +1 -1
- package/dist/svghelpers/advice-linear.js +10 -4
- package/dist/svghelpers/advice-linear.js.map +1 -1
- package/llms/docs/building-blocks-advice.md +1 -0
- package/llms/llms-full.txt +1 -0
- package/package.json +1 -1
- package/src/building-blocks/advice/advice.stories.ts +34 -0
- package/src/building-blocks/external-scale/external-scale.spec.ts +15 -0
- package/src/svghelpers/advice-linear.ts +16 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advice-linear.d.ts","sourceRoot":"","sources":["../../src/svghelpers/advice-linear.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAC,OAAO,EAAO,KAAK,iBAAiB,EAAC,MAAM,KAAK,CAAC;AACzD,OAAO,EAeL,KAAK,WAAW,EAChB,KAAK,cAAc,EAEpB,MAAM,aAAa,CAAC;AAIrB,oFAAoF;AACpF,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,QAAQ,EAAE,OAAO,CAAC;IAClB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,kGAAkG;IAClG,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,GAAG,cAAc,CAAC;IACrC,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"advice-linear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B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,GAAG,cAAc,CAAC;IACrC,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,CAAC,EAAE,uBAAuB,GACzB,iBAAiB,CAwCnB;AAED,iGAAiG;AACjG,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,iGAAiG;IACjG,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,GAAG,cAAc,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,yFAAyF;AACzF,wBAAgB,sBAAsB,CACpC,CAAC,EAAE,uBAAuB,GACzB,iBAAiB,CAWnB"}
|
|
@@ -19,6 +19,11 @@ var point = (vertical, main, perp) => vertical ? `${perp} ${main}` : `${main} ${
|
|
|
19
19
|
* coordinate is the advice's start cap when `mainStart <= mainEnd`, as on a
|
|
20
20
|
* horizontal scale, and its end cap otherwise, as on a vertical scale whose
|
|
21
21
|
* values grow upward.
|
|
22
|
+
*
|
|
23
|
+
* TODO(designer): the sets draw no go-to range shorter than the pill and its
|
|
24
|
+
* two tip insets, 16 px. The code keeps the pill's round ends down to 8 px
|
|
25
|
+
* so a short range on a small tank stays marked, and drops the band below
|
|
26
|
+
* that. The ring drops a range of 16 or less.
|
|
22
27
|
*/
|
|
23
28
|
function bandPath(o, advice) {
|
|
24
29
|
const t = o.thickness ?? 8;
|
|
@@ -29,13 +34,14 @@ function bandPath(o, advice) {
|
|
|
29
34
|
const capLo = ascending ? caps.start : caps.end;
|
|
30
35
|
const capHi = ascending ? caps.end : caps.start;
|
|
31
36
|
const u = o.unitsPerPx ?? 1;
|
|
32
|
-
const inset = 4 * u;
|
|
33
|
-
const edgeLo = capLo === AdviceCap.pill ? lo + inset : lo;
|
|
34
|
-
const edgeHi = capHi === AdviceCap.pill ? hi - inset : hi;
|
|
35
37
|
const radius = (cap) => cap === AdviceCap.pill ? t / 2 : cap === AdviceCap.square ? 2 * u : 0;
|
|
36
38
|
const rLo = radius(capLo);
|
|
37
39
|
const rHi = radius(capHi);
|
|
38
|
-
if (
|
|
40
|
+
if (hi - lo < rLo + rHi) return null;
|
|
41
|
+
const pills = Number(capLo === AdviceCap.pill) + Number(capHi === AdviceCap.pill);
|
|
42
|
+
const inset = pills ? Math.min(4 * u, (hi - lo - rLo - rHi) / pills) : 0;
|
|
43
|
+
const edgeLo = capLo === AdviceCap.pill ? lo + inset : lo;
|
|
44
|
+
const edgeHi = capHi === AdviceCap.pill ? hi - inset : hi;
|
|
39
45
|
const p0 = o.perpStart;
|
|
40
46
|
const p1 = o.perpStart + t;
|
|
41
47
|
const v = o.vertical;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advice-linear.js","names":[],"sources":["../../src/svghelpers/advice-linear.ts"],"sourcesContent":["/**\n * The linear advice renderer, shared by the external scale, the thruster\n * column and the linear instrument scales: a band along a main axis at a\n * fixed perpendicular offset, a point marker on the band centreline, and the\n * area between the limit lines across a bar. What a band looks like comes\n * from `advice.ts`; the caller maps its values to main-axis coordinates and\n * says where the band sits.\n *\n * @module\n */\n\nimport {nothing, svg, type SVGTemplateResult} from 'lit';\nimport {\n ADVICE_ALERT_CORNER_RADIUS,\n ADVICE_AREA_DASH,\n ADVICE_BAND_THICKNESS,\n ADVICE_CAP_INSET,\n ADVICE_POINT_DOT_DIAMETER,\n ADVICE_POINT_TICK,\n AdviceCap,\n ADVICE_STRIPE,\n AdviceCategory,\n AdviceState,\n adviceCaps,\n adviceStyle,\n asResolvedAdvice,\n isGoToCategory,\n type AdviceInput,\n type ResolvedAdvice,\n ADVICE_ICON_SIZE_LINEAR,\n} from './advice.js';\nimport {dotPattern, hairlinePattern, stripePattern} from './advice-patterns.js';\nimport {renderAdviceIcon} from './advice-icons.js';\n\n/** Where a band sits: its range along the main axis and its near edge across it. */\nexport interface LinearAdviceBandOptions {\n /** The main axis is y (a vertical scale) rather than x. */\n vertical: boolean;\n /** Main-axis coordinate of the advice's `min`. */\n mainStart: number;\n /** Main-axis coordinate of the advice's `max`. */\n mainEnd: number;\n /** The band's edge with the lower perpendicular coordinate; it extends `thickness` from there. */\n perpStart: number;\n thickness?: number;\n advice: AdviceInput | ResolvedAdvice;\n /** Unique in the document; only a hatched band uses it. */\n maskId: string;\n /** The band is drawn under a reflection, so the hatch is mirrored back. */\n mirrorPattern?: boolean;\n /**\n * ViewBox units per CSS pixel when the band is pixel-fixed inside a scaled\n * drawing: the hatch tile is enlarged by it so the stripes keep their pitch.\n */\n unitsPerPx?: number;\n}\n\nconst point = (vertical: boolean, main: number, perp: number) =>\n vertical ? `${perp} ${main}` : `${main} ${perp}`;\n\n/**\n * The band outline, one cap per end. The cap at the lower main-axis\n * coordinate is the advice's start cap when `mainStart <= mainEnd`, as on a\n * horizontal scale, and its end cap otherwise, as on a vertical scale whose\n * values grow upward.\n */\nfunction bandPath(o: LinearAdviceBandOptions, advice: ResolvedAdvice) {\n const t = o.thickness ?? ADVICE_BAND_THICKNESS;\n const caps = adviceCaps(advice);\n const ascending = o.mainStart <= o.mainEnd;\n const lo = Math.min(o.mainStart, o.mainEnd);\n const hi = Math.max(o.mainStart, o.mainEnd);\n const capLo = ascending ? caps.start : caps.end;\n const capHi = ascending ? caps.end : caps.start;\n // The caps are pixel geometry like the band: a scaled drawing holds them\n // in the band's own units.\n const u = o.unitsPerPx ?? 1;\n const inset = ADVICE_CAP_INSET * u;\n const edgeLo = capLo === AdviceCap.pill ? lo + inset : lo;\n const edgeHi = capHi === AdviceCap.pill ? hi - inset : hi;\n const radius = (cap: AdviceCap) =>\n cap === AdviceCap.pill\n ? t / 2\n : cap === AdviceCap.square\n ? ADVICE_ALERT_CORNER_RADIUS * u\n : 0;\n const rLo = radius(capLo);\n const rHi = radius(capHi);\n if (edgeHi - edgeLo < rLo + rHi) return null;\n const p0 = o.perpStart;\n const p1 = o.perpStart + t;\n const v = o.vertical;\n const sw = v ? 0 : 1;\n const P = (main: number, perp: number) => point(v, main, perp);\n const cap = (\n main: number,\n r: number,\n c: AdviceCap,\n from: number,\n to: number,\n dir: 1 | -1\n ) => {\n // `dir` is +1 at the high end, -1 at the low end; the cap bulges that way.\n if (c === AdviceCap.pill) {\n return `A ${r} ${r} 0 0 ${sw} ${P(main - dir * r, to)}`;\n }\n if (c === AdviceCap.square) {\n const inward = from < to ? 1 : -1;\n return `A ${r} ${r} 0 0 ${sw} ${P(main, from + inward * r)} L ${P(main, to - inward * r)} A ${r} ${r} 0 0 ${sw} ${P(main - dir * r, to)}`;\n }\n return `L ${P(main, from)} L ${P(main, to)}`;\n };\n return [\n `M ${P(edgeLo + rLo, p0)}`,\n `L ${P(edgeHi - rHi, p0)}`,\n cap(edgeHi, rHi, capHi, p0, p1, 1),\n `L ${P(edgeLo + rLo, p1)}`,\n cap(edgeLo, rLo, capLo, p1, p0, -1),\n 'Z',\n ].join(' ');\n}\n\n/** One advice band. `nothing` when the range is too short for its caps. */\nexport function renderLinearAdviceBand(\n o: LinearAdviceBandOptions\n): SVGTemplateResult | typeof nothing {\n const advice = asResolvedAdvice(o.advice);\n const style = adviceStyle(advice.category, advice.state);\n const d = bandPath(o, advice);\n if (d === null) return nothing;\n if (style.pattern === 'none') {\n return svg`<path class=\"advice-band\" d=${d} fill=${style.fill} stroke=${style.stroke} stroke-width=\"1\" vector-effect=\"non-scaling-stroke\"/>`;\n }\n const t = o.thickness ?? ADVICE_BAND_THICKNESS;\n const lo = Math.min(o.mainStart, o.mainEnd);\n const hi = Math.max(o.mainStart, o.mainEnd);\n const patternId = `${o.maskId}-pattern`;\n const mirrored = o.mirrorPattern ?? false;\n const unitsPerPx = o.unitsPerPx ?? 1;\n const pattern =\n style.pattern === 'hairline'\n ? hairlinePattern(patternId, style.patternColor, mirrored, unitsPerPx)\n : stripePattern(\n patternId,\n style.patternColor,\n ADVICE_STRIPE.width,\n mirrored,\n unitsPerPx\n );\n const cover = o.vertical\n ? svg`<rect x=${o.perpStart} y=${lo} width=${t} height=${hi - lo} fill=${style.fill}/><rect x=${o.perpStart} y=${lo} width=${t} height=${hi - lo} fill=\"url(#${patternId})\"/>`\n : svg`<rect x=${lo} y=${o.perpStart} width=${hi - lo} height=${t} fill=${style.fill}/><rect x=${lo} y=${o.perpStart} width=${hi - lo} height=${t} fill=\"url(#${patternId})\"/>`;\n return svg`\n <defs>\n ${pattern}\n <mask id=${o.maskId} maskUnits=\"userSpaceOnUse\" x=\"-4096\" y=\"-4096\" width=\"8192\" height=\"8192\">\n <path d=${d} fill=\"white\"/>\n </mask>\n </defs>\n <g mask=\"url(#${o.maskId})\">${cover}</g>\n <path class=\"advice-band\" d=${d} fill=\"none\" stroke=${style.stroke} stroke-width=\"1\" vector-effect=\"non-scaling-stroke\"/>`;\n}\n\n/** Where a point marker sits: on the band centreline at its value. */\nexport interface LinearAdvicePointOptions {\n vertical: boolean;\n /** Main-axis coordinate of the advice's `value`. */\n main: number;\n /** Perpendicular coordinate of the band centreline. */\n perpCenter: number;\n advice: AdviceInput | ResolvedAdvice;\n /** ViewBox units per CSS pixel when the marker is pixel-fixed inside a scaled drawing. */\n unitsPerPx?: number;\n}\n\n/**\n * A point advice: a dot for a go-to category, a thick tick across the band\n * for a no-go one. The caution point takes the tick-mark primary colour while\n * triggered, never the caution yellow.\n */\nexport function renderLinearAdvicePoint(\n o: LinearAdvicePointOptions\n): SVGTemplateResult {\n const advice = asResolvedAdvice(o.advice);\n const style = adviceStyle(advice.category, advice.state);\n const cx = o.vertical ? o.perpCenter : o.main;\n const cy = o.vertical ? o.main : o.perpCenter;\n const u = o.unitsPerPx ?? 1;\n if (isGoToCategory(advice.category)) {\n return svg`<circle cx=${cx} cy=${cy} r=${(ADVICE_POINT_DOT_DIAMETER / 2) * u} fill=${style.fill} stroke=${style.stroke} stroke-width=\"1\" vector-effect=\"non-scaling-stroke\"/>`;\n }\n const grey =\n advice.category === AdviceCategory.caution\n ? advice.state === AdviceState.triggered\n ? 'var(--instrument-tick-mark-primary-color)'\n : style.stroke\n : undefined;\n const {length, thickness, radius} = ADVICE_POINT_TICK;\n const w = (o.vertical ? length : thickness) * u;\n const h = (o.vertical ? thickness : length) * u;\n return svg`<rect x=${cx - w / 2} y=${cy - h / 2} width=${w} height=${h} rx=${radius * u} fill=${grey ?? style.fill} stroke=${grey ?? style.stroke} stroke-width=\"1\" vector-effect=\"non-scaling-stroke\"/>`;\n}\n\n/** Where an area sits: the advice's range along the main axis, the bar across it. */\nexport interface LinearAdviceAreaOptions {\n vertical: boolean;\n mainStart: number;\n mainEnd: number;\n perpStart: number;\n perpEnd: number;\n advice: AdviceInput | ResolvedAdvice;\n /** Unique in the document; the pattern tile's id. */\n patternId: string;\n}\n\n/**\n * The area layer across a bar: the category's tint or pattern between the\n * limits and the limit lines in the category's dash; for a point one line.\n */\nexport function renderLinearAdviceArea(\n o: LinearAdviceAreaOptions\n): SVGTemplateResult {\n const advice = asResolvedAdvice(o.advice);\n const style = adviceStyle(advice.category, advice.state);\n const v = o.vertical;\n const dash =\n style.areaOutline === 'dotted'\n ? ADVICE_AREA_DASH.dotted\n : style.areaOutline === 'dashed'\n ? ADVICE_AREA_DASH.dashed\n : undefined;\n const line = (main: number) => {\n const d = `M ${point(v, main, o.perpStart)} L ${point(v, main, o.perpEnd)}`;\n return svg`\n ${\n dash\n ? svg`<path d=${d} fill=\"none\" stroke=\"var(--instrument-frame-primary-color)\" stroke-width=\"1\" vector-effect=\"non-scaling-stroke\"/>`\n : nothing\n }\n <path d=${d} fill=\"none\" stroke=${style.stroke} stroke-width=\"1\" stroke-dasharray=${dash ?? nothing} vector-effect=\"non-scaling-stroke\"/>`;\n };\n if (advice.point) return line(o.mainStart);\n const lo = Math.min(o.mainStart, o.mainEnd);\n const hi = Math.max(o.mainStart, o.mainEnd);\n const pLo = Math.min(o.perpStart, o.perpEnd);\n const pHi = Math.max(o.perpStart, o.perpEnd);\n const rect = (fill: string) =>\n v\n ? svg`<rect x=${pLo} y=${lo} width=${pHi - pLo} height=${hi - lo} fill=${fill}/>`\n : svg`<rect x=${lo} y=${pLo} width=${hi - lo} height=${pHi - pLo} fill=${fill}/>`;\n const pattern =\n style.areaPattern === 'dots'\n ? dotPattern(o.patternId, style.stroke)\n : style.areaPattern === 'hairline'\n ? hairlinePattern(o.patternId, style.stroke)\n : nothing;\n return svg`\n ${pattern}\n ${style.areaFill === 'none' ? nothing : rect(style.areaFill)}\n ${pattern === nothing ? nothing : rect(`url(#${o.patternId})`)}\n ${line(o.mainStart)} ${line(o.mainEnd)}`;\n}\n\n/** Where an icon sits: the advice's midpoint along the main axis, the label column across it. */\nexport interface LinearAdviceIconOptions {\n vertical: boolean;\n /** Main-axis coordinates of the advice's `min` and `max`; a point gives the same value twice. */\n mainStart: number;\n mainEnd: number;\n /** Perpendicular coordinate of the icon box's centre. */\n perpCenter: number;\n advice: AdviceInput | ResolvedAdvice;\n size?: number;\n /** Unique in the document; the glyph's own ids are prefixed with it. */\n id?: string;\n}\n\n/** The category's icon beside the band, centred on the range, in the responsive size. */\nexport function renderLinearAdviceIcon(\n o: LinearAdviceIconOptions\n): SVGTemplateResult {\n const advice = asResolvedAdvice(o.advice);\n const main = (o.mainStart + o.mainEnd) / 2;\n return renderAdviceIcon({\n category: advice.category,\n state: advice.state,\n x: o.vertical ? o.perpCenter : main,\n y: o.vertical ? main : o.perpCenter,\n size: o.size ?? ADVICE_ICON_SIZE_LINEAR,\n id: o.id,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyDA,IAAM,SAAS,UAAmB,MAAc,SAC9C,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG;;;;;;;AAQ5C,SAAS,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AAO;EACd,GAAG,EAAE,WAAW,EAAE,aAAa;EAC/B,GAAG,EAAE,WAAW,OAAO,EAAE;EACzB,MAAM,EAAE,QAAA;EACR,IAAI,EAAE;CACR,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"advice-linear.js","names":[],"sources":["../../src/svghelpers/advice-linear.ts"],"sourcesContent":["/**\n * The linear advice renderer, shared by the external scale, the thruster\n * column and the linear instrument scales: a band along a main axis at a\n * fixed perpendicular offset, a point marker on the band centreline, and the\n * area between the limit lines across a bar. What a band looks like comes\n * from `advice.ts`; the caller maps its values to main-axis coordinates and\n * says where the band sits.\n *\n * @module\n */\n\nimport {nothing, svg, type SVGTemplateResult} from 'lit';\nimport {\n ADVICE_ALERT_CORNER_RADIUS,\n ADVICE_AREA_DASH,\n ADVICE_BAND_THICKNESS,\n ADVICE_CAP_INSET,\n ADVICE_POINT_DOT_DIAMETER,\n ADVICE_POINT_TICK,\n AdviceCap,\n ADVICE_STRIPE,\n AdviceCategory,\n AdviceState,\n adviceCaps,\n adviceStyle,\n asResolvedAdvice,\n isGoToCategory,\n type AdviceInput,\n type ResolvedAdvice,\n ADVICE_ICON_SIZE_LINEAR,\n} from './advice.js';\nimport {dotPattern, hairlinePattern, stripePattern} from './advice-patterns.js';\nimport {renderAdviceIcon} from './advice-icons.js';\n\n/** Where a band sits: its range along the main axis and its near edge across it. */\nexport interface LinearAdviceBandOptions {\n /** The main axis is y (a vertical scale) rather than x. */\n vertical: boolean;\n /** Main-axis coordinate of the advice's `min`. */\n mainStart: number;\n /** Main-axis coordinate of the advice's `max`. */\n mainEnd: number;\n /** The band's edge with the lower perpendicular coordinate; it extends `thickness` from there. */\n perpStart: number;\n thickness?: number;\n advice: AdviceInput | ResolvedAdvice;\n /** Unique in the document; only a hatched band uses it. */\n maskId: string;\n /** The band is drawn under a reflection, so the hatch is mirrored back. */\n mirrorPattern?: boolean;\n /**\n * ViewBox units per CSS pixel when the band is pixel-fixed inside a scaled\n * drawing: the hatch tile is enlarged by it so the stripes keep their pitch.\n */\n unitsPerPx?: number;\n}\n\nconst point = (vertical: boolean, main: number, perp: number) =>\n vertical ? `${perp} ${main}` : `${main} ${perp}`;\n\n/**\n * The band outline, one cap per end. The cap at the lower main-axis\n * coordinate is the advice's start cap when `mainStart <= mainEnd`, as on a\n * horizontal scale, and its end cap otherwise, as on a vertical scale whose\n * values grow upward.\n *\n * TODO(designer): the sets draw no go-to range shorter than the pill and its\n * two tip insets, 16 px. The code keeps the pill's round ends down to 8 px\n * so a short range on a small tank stays marked, and drops the band below\n * that. The ring drops a range of 16 or less.\n */\nfunction bandPath(o: LinearAdviceBandOptions, advice: ResolvedAdvice) {\n const t = o.thickness ?? ADVICE_BAND_THICKNESS;\n const caps = adviceCaps(advice);\n const ascending = o.mainStart <= o.mainEnd;\n const lo = Math.min(o.mainStart, o.mainEnd);\n const hi = Math.max(o.mainStart, o.mainEnd);\n const capLo = ascending ? caps.start : caps.end;\n const capHi = ascending ? caps.end : caps.start;\n // The caps are pixel geometry like the band: a scaled drawing holds them\n // in the band's own units.\n const u = o.unitsPerPx ?? 1;\n const radius = (cap: AdviceCap) =>\n cap === AdviceCap.pill\n ? t / 2\n : cap === AdviceCap.square\n ? ADVICE_ALERT_CORNER_RADIUS * u\n : 0;\n const rLo = radius(capLo);\n const rHi = radius(capHi);\n if (hi - lo < rLo + rHi) return null;\n // The pill tips give way before the pill: a range too short for both\n // insets shares what is left beyond the caps between its pill ends, so a\n // pixel-fixed pill in a small drawing still marks a short range.\n const pills =\n Number(capLo === AdviceCap.pill) + Number(capHi === AdviceCap.pill);\n const inset = pills\n ? Math.min(ADVICE_CAP_INSET * u, (hi - lo - rLo - rHi) / pills)\n : 0;\n const edgeLo = capLo === AdviceCap.pill ? lo + inset : lo;\n const edgeHi = capHi === AdviceCap.pill ? hi - inset : hi;\n const p0 = o.perpStart;\n const p1 = o.perpStart + t;\n const v = o.vertical;\n const sw = v ? 0 : 1;\n const P = (main: number, perp: number) => point(v, main, perp);\n const cap = (\n main: number,\n r: number,\n c: AdviceCap,\n from: number,\n to: number,\n dir: 1 | -1\n ) => {\n // `dir` is +1 at the high end, -1 at the low end; the cap bulges that way.\n if (c === AdviceCap.pill) {\n return `A ${r} ${r} 0 0 ${sw} ${P(main - dir * r, to)}`;\n }\n if (c === AdviceCap.square) {\n const inward = from < to ? 1 : -1;\n return `A ${r} ${r} 0 0 ${sw} ${P(main, from + inward * r)} L ${P(main, to - inward * r)} A ${r} ${r} 0 0 ${sw} ${P(main - dir * r, to)}`;\n }\n return `L ${P(main, from)} L ${P(main, to)}`;\n };\n return [\n `M ${P(edgeLo + rLo, p0)}`,\n `L ${P(edgeHi - rHi, p0)}`,\n cap(edgeHi, rHi, capHi, p0, p1, 1),\n `L ${P(edgeLo + rLo, p1)}`,\n cap(edgeLo, rLo, capLo, p1, p0, -1),\n 'Z',\n ].join(' ');\n}\n\n/** One advice band. `nothing` when the range is too short for its caps. */\nexport function renderLinearAdviceBand(\n o: LinearAdviceBandOptions\n): SVGTemplateResult | typeof nothing {\n const advice = asResolvedAdvice(o.advice);\n const style = adviceStyle(advice.category, advice.state);\n const d = bandPath(o, advice);\n if (d === null) return nothing;\n if (style.pattern === 'none') {\n return svg`<path class=\"advice-band\" d=${d} fill=${style.fill} stroke=${style.stroke} stroke-width=\"1\" vector-effect=\"non-scaling-stroke\"/>`;\n }\n const t = o.thickness ?? ADVICE_BAND_THICKNESS;\n const lo = Math.min(o.mainStart, o.mainEnd);\n const hi = Math.max(o.mainStart, o.mainEnd);\n const patternId = `${o.maskId}-pattern`;\n const mirrored = o.mirrorPattern ?? false;\n const unitsPerPx = o.unitsPerPx ?? 1;\n const pattern =\n style.pattern === 'hairline'\n ? hairlinePattern(patternId, style.patternColor, mirrored, unitsPerPx)\n : stripePattern(\n patternId,\n style.patternColor,\n ADVICE_STRIPE.width,\n mirrored,\n unitsPerPx\n );\n const cover = o.vertical\n ? svg`<rect x=${o.perpStart} y=${lo} width=${t} height=${hi - lo} fill=${style.fill}/><rect x=${o.perpStart} y=${lo} width=${t} height=${hi - lo} fill=\"url(#${patternId})\"/>`\n : svg`<rect x=${lo} y=${o.perpStart} width=${hi - lo} height=${t} fill=${style.fill}/><rect x=${lo} y=${o.perpStart} width=${hi - lo} height=${t} fill=\"url(#${patternId})\"/>`;\n return svg`\n <defs>\n ${pattern}\n <mask id=${o.maskId} maskUnits=\"userSpaceOnUse\" x=\"-4096\" y=\"-4096\" width=\"8192\" height=\"8192\">\n <path d=${d} fill=\"white\"/>\n </mask>\n </defs>\n <g mask=\"url(#${o.maskId})\">${cover}</g>\n <path class=\"advice-band\" d=${d} fill=\"none\" stroke=${style.stroke} stroke-width=\"1\" vector-effect=\"non-scaling-stroke\"/>`;\n}\n\n/** Where a point marker sits: on the band centreline at its value. */\nexport interface LinearAdvicePointOptions {\n vertical: boolean;\n /** Main-axis coordinate of the advice's `value`. */\n main: number;\n /** Perpendicular coordinate of the band centreline. */\n perpCenter: number;\n advice: AdviceInput | ResolvedAdvice;\n /** ViewBox units per CSS pixel when the marker is pixel-fixed inside a scaled drawing. */\n unitsPerPx?: number;\n}\n\n/**\n * A point advice: a dot for a go-to category, a thick tick across the band\n * for a no-go one. The caution point takes the tick-mark primary colour while\n * triggered, never the caution yellow.\n */\nexport function renderLinearAdvicePoint(\n o: LinearAdvicePointOptions\n): SVGTemplateResult {\n const advice = asResolvedAdvice(o.advice);\n const style = adviceStyle(advice.category, advice.state);\n const cx = o.vertical ? o.perpCenter : o.main;\n const cy = o.vertical ? o.main : o.perpCenter;\n const u = o.unitsPerPx ?? 1;\n if (isGoToCategory(advice.category)) {\n return svg`<circle cx=${cx} cy=${cy} r=${(ADVICE_POINT_DOT_DIAMETER / 2) * u} fill=${style.fill} stroke=${style.stroke} stroke-width=\"1\" vector-effect=\"non-scaling-stroke\"/>`;\n }\n const grey =\n advice.category === AdviceCategory.caution\n ? advice.state === AdviceState.triggered\n ? 'var(--instrument-tick-mark-primary-color)'\n : style.stroke\n : undefined;\n const {length, thickness, radius} = ADVICE_POINT_TICK;\n const w = (o.vertical ? length : thickness) * u;\n const h = (o.vertical ? thickness : length) * u;\n return svg`<rect x=${cx - w / 2} y=${cy - h / 2} width=${w} height=${h} rx=${radius * u} fill=${grey ?? style.fill} stroke=${grey ?? style.stroke} stroke-width=\"1\" vector-effect=\"non-scaling-stroke\"/>`;\n}\n\n/** Where an area sits: the advice's range along the main axis, the bar across it. */\nexport interface LinearAdviceAreaOptions {\n vertical: boolean;\n mainStart: number;\n mainEnd: number;\n perpStart: number;\n perpEnd: number;\n advice: AdviceInput | ResolvedAdvice;\n /** Unique in the document; the pattern tile's id. */\n patternId: string;\n}\n\n/**\n * The area layer across a bar: the category's tint or pattern between the\n * limits and the limit lines in the category's dash; for a point one line.\n */\nexport function renderLinearAdviceArea(\n o: LinearAdviceAreaOptions\n): SVGTemplateResult {\n const advice = asResolvedAdvice(o.advice);\n const style = adviceStyle(advice.category, advice.state);\n const v = o.vertical;\n const dash =\n style.areaOutline === 'dotted'\n ? ADVICE_AREA_DASH.dotted\n : style.areaOutline === 'dashed'\n ? ADVICE_AREA_DASH.dashed\n : undefined;\n const line = (main: number) => {\n const d = `M ${point(v, main, o.perpStart)} L ${point(v, main, o.perpEnd)}`;\n return svg`\n ${\n dash\n ? svg`<path d=${d} fill=\"none\" stroke=\"var(--instrument-frame-primary-color)\" stroke-width=\"1\" vector-effect=\"non-scaling-stroke\"/>`\n : nothing\n }\n <path d=${d} fill=\"none\" stroke=${style.stroke} stroke-width=\"1\" stroke-dasharray=${dash ?? nothing} vector-effect=\"non-scaling-stroke\"/>`;\n };\n if (advice.point) return line(o.mainStart);\n const lo = Math.min(o.mainStart, o.mainEnd);\n const hi = Math.max(o.mainStart, o.mainEnd);\n const pLo = Math.min(o.perpStart, o.perpEnd);\n const pHi = Math.max(o.perpStart, o.perpEnd);\n const rect = (fill: string) =>\n v\n ? svg`<rect x=${pLo} y=${lo} width=${pHi - pLo} height=${hi - lo} fill=${fill}/>`\n : svg`<rect x=${lo} y=${pLo} width=${hi - lo} height=${pHi - pLo} fill=${fill}/>`;\n const pattern =\n style.areaPattern === 'dots'\n ? dotPattern(o.patternId, style.stroke)\n : style.areaPattern === 'hairline'\n ? hairlinePattern(o.patternId, style.stroke)\n : nothing;\n return svg`\n ${pattern}\n ${style.areaFill === 'none' ? nothing : rect(style.areaFill)}\n ${pattern === nothing ? nothing : rect(`url(#${o.patternId})`)}\n ${line(o.mainStart)} ${line(o.mainEnd)}`;\n}\n\n/** Where an icon sits: the advice's midpoint along the main axis, the label column across it. */\nexport interface LinearAdviceIconOptions {\n vertical: boolean;\n /** Main-axis coordinates of the advice's `min` and `max`; a point gives the same value twice. */\n mainStart: number;\n mainEnd: number;\n /** Perpendicular coordinate of the icon box's centre. */\n perpCenter: number;\n advice: AdviceInput | ResolvedAdvice;\n size?: number;\n /** Unique in the document; the glyph's own ids are prefixed with it. */\n id?: string;\n}\n\n/** The category's icon beside the band, centred on the range, in the responsive size. */\nexport function renderLinearAdviceIcon(\n o: LinearAdviceIconOptions\n): SVGTemplateResult {\n const advice = asResolvedAdvice(o.advice);\n const main = (o.mainStart + o.mainEnd) / 2;\n return renderAdviceIcon({\n category: advice.category,\n state: advice.state,\n x: o.vertical ? o.perpCenter : main,\n y: o.vertical ? main : o.perpCenter,\n size: o.size ?? ADVICE_ICON_SIZE_LINEAR,\n id: o.id,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyDA,IAAM,SAAS,UAAmB,MAAc,SAC9C,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG;;;;;;;;;;;;AAa5C,SAAS,SAAS,GAA4B,QAAwB;CACpE,MAAM,IAAI,EAAE,aAAA;CACZ,MAAM,OAAO,WAAW,MAAM;CAC9B,MAAM,YAAY,EAAE,aAAa,EAAE;CACnC,MAAM,KAAK,KAAK,IAAI,EAAE,WAAW,EAAE,OAAO;CAC1C,MAAM,KAAK,KAAK,IAAI,EAAE,WAAW,EAAE,OAAO;CAC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AAA;EACR,IAAI,EAAE;CACR,CAAC;AACH"}
|
|
@@ -28,4 +28,5 @@ Source: `packages/openbridge-webcomponents/src/svghelpers/advice.ts`
|
|
|
28
28
|
- [State Change Flow](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-advice--advice-state-change-flow): A value moving through the bands with `adviceEmphasis` on: at rest the go-to band is `active` and the no-go band `enabled`; entering the optimal band triggers it and fades the caution band to `hinted`; entering the caution band does the reverse. The linear and the radial rendering share the resolution.
|
|
29
29
|
- [Resolution Stack (Radial)](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-advice--advice-resolution-stack): Chained bands resolved against three readings. Bands that meet are cut flat at the join; a hit on one group fades the other group to `hinted`, while an unhit band of the hit group keeps its resting state.
|
|
30
30
|
- [Range and Point](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-advice--advice-range-and-point): A range and a point on a horizontal bar, with the area layer on two of them: the tint and the dotted limits of the optimal range, the dashed line of the caution point. The point is a dot on the tick base; an alert point is a short tick instead.
|
|
31
|
+
- [Short Range](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-advice--advice-short-range): A go-to range too short for the pill and its two 4 px tip insets. Under 8 px only the limit lines are left; from 8 px the pill's round ends are drawn, and the insets grow back until the range reaches 16 px.
|
|
31
32
|
- [Icons](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-advice--advice-icons): Every category with its icon, at rest and triggered, on the bar and on the radial gauge. The icon sits in the label column, centred on the band; a triggered alert category switches to its IEC icon with that icon's own colours, a go-to category keeps its outline in the band's colour.
|
package/llms/llms-full.txt
CHANGED
|
@@ -374,6 +374,7 @@ Source: `packages/openbridge-webcomponents/src/svghelpers/advice.ts`
|
|
|
374
374
|
- [State Change Flow](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-advice--advice-state-change-flow): A value moving through the bands with `adviceEmphasis` on: at rest the go-to band is `active` and the no-go band `enabled`; entering the optimal band triggers it and fades the caution band to `hinted`; entering the caution band does the reverse. The linear and the radial rendering share the resolution.
|
|
375
375
|
- [Resolution Stack (Radial)](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-advice--advice-resolution-stack): Chained bands resolved against three readings. Bands that meet are cut flat at the join; a hit on one group fades the other group to `hinted`, while an unhit band of the hit group keeps its resting state.
|
|
376
376
|
- [Range and Point](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-advice--advice-range-and-point): A range and a point on a horizontal bar, with the area layer on two of them: the tint and the dotted limits of the optimal range, the dashed line of the caution point. The point is a dot on the tick base; an alert point is a short tick instead.
|
|
377
|
+
- [Short Range](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-advice--advice-short-range): A go-to range too short for the pill and its two 4 px tip insets. Under 8 px only the limit lines are left; from 8 px the pill's round ends are drawn, and the insets grow back until the range reaches 16 px.
|
|
377
378
|
- [Icons](https://openbridge-next-storybook.web.app/?path=/story/building-blocks-advice--advice-icons): Every category with its icon, at rest and triggered, on the bar and on the radial gauge. The icon sits in the label column, centred on the band; a triggered alert category switches to its IEC icon with that icon's own colours, a go-to category keeps its outline in the band's colour.
|
|
378
379
|
|
|
379
380
|
---
|
package/package.json
CHANGED
|
@@ -441,6 +441,40 @@ export const AdviceRangeAndPoint: Story = {
|
|
|
441
441
|
`,
|
|
442
442
|
};
|
|
443
443
|
|
|
444
|
+
/** Painted lengths of the short ranges, in px; a 265 px bar draws 2 px per unit. */
|
|
445
|
+
const SHORT_RANGE_LENGTHS = [6, 9, 12, 16, 24];
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* A go-to range too short for the pill and its two 4 px tip insets. Under
|
|
449
|
+
* 8 px only the limit lines are left; from 8 px the pill's round ends are
|
|
450
|
+
* drawn, and the insets grow back until the range reaches 16 px.
|
|
451
|
+
*/
|
|
452
|
+
export const AdviceShortRange: Story = {
|
|
453
|
+
name: 'Short Range',
|
|
454
|
+
render: () => html`
|
|
455
|
+
<div
|
|
456
|
+
style="display: grid; grid-template-columns: repeat(5, 1fr); gap: 24px;"
|
|
457
|
+
>
|
|
458
|
+
${SHORT_RANGE_LENGTHS.map((length) =>
|
|
459
|
+
cell(
|
|
460
|
+
`${length} px`,
|
|
461
|
+
linearAdvice(
|
|
462
|
+
[
|
|
463
|
+
{
|
|
464
|
+
min: 50 - length / 4,
|
|
465
|
+
max: 50 + length / 4,
|
|
466
|
+
category: AdviceCategory.optimal,
|
|
467
|
+
state: AdviceState.active,
|
|
468
|
+
},
|
|
469
|
+
],
|
|
470
|
+
{height: 265}
|
|
471
|
+
)
|
|
472
|
+
)
|
|
473
|
+
)}
|
|
474
|
+
</div>
|
|
475
|
+
`,
|
|
476
|
+
};
|
|
477
|
+
|
|
444
478
|
/**
|
|
445
479
|
* Every category with its icon, at rest and triggered, on the bar and on the
|
|
446
480
|
* radial gauge. The icon sits in the label column, centred on the band; a
|
|
@@ -443,6 +443,21 @@ describe('advice geometry under fixedAspectRatio', () => {
|
|
|
443
443
|
expect(bandBox(short).height).toBeCloseTo(8 / 3, 3);
|
|
444
444
|
});
|
|
445
445
|
|
|
446
|
+
it('gives up the pill tip inset before the pill on a short range', () => {
|
|
447
|
+
// 20 to 26.5 is 34.84 units, 13.9 px at scale 0.4: room for the 8 px
|
|
448
|
+
// pill, not for its 4 px tips as well. The default tank tile paints a
|
|
449
|
+
// fifth of its range this short.
|
|
450
|
+
const lo = 32 + 20 * 5.36;
|
|
451
|
+
const hi = 32 + 26.5 * 5.36;
|
|
452
|
+
const box = bandBox({
|
|
453
|
+
advices: [{min: 20, max: 26.5, category: 'optimal'}],
|
|
454
|
+
fixedAspectRatioScale: 0.4,
|
|
455
|
+
});
|
|
456
|
+
expect(box.width).toBeGreaterThanOrEqual(8 / 0.4 - 1e-3);
|
|
457
|
+
expect(box.x).toBeGreaterThanOrEqual(lo - 1e-3);
|
|
458
|
+
expect(box.x + box.width).toBeLessThanOrEqual(hi + 1e-3);
|
|
459
|
+
});
|
|
460
|
+
|
|
446
461
|
it('caps the scale by the cross axis with the pixel column held out of the ratio', () => {
|
|
447
462
|
// 48 scaled units plus a 16 px column: the drawing fits a 60 px host at
|
|
448
463
|
// (60 - 16) / 48, not at 60 / 64.
|
|
@@ -63,6 +63,11 @@ const point = (vertical: boolean, main: number, perp: number) =>
|
|
|
63
63
|
* coordinate is the advice's start cap when `mainStart <= mainEnd`, as on a
|
|
64
64
|
* horizontal scale, and its end cap otherwise, as on a vertical scale whose
|
|
65
65
|
* values grow upward.
|
|
66
|
+
*
|
|
67
|
+
* TODO(designer): the sets draw no go-to range shorter than the pill and its
|
|
68
|
+
* two tip insets, 16 px. The code keeps the pill's round ends down to 8 px
|
|
69
|
+
* so a short range on a small tank stays marked, and drops the band below
|
|
70
|
+
* that. The ring drops a range of 16 or less.
|
|
66
71
|
*/
|
|
67
72
|
function bandPath(o: LinearAdviceBandOptions, advice: ResolvedAdvice) {
|
|
68
73
|
const t = o.thickness ?? ADVICE_BAND_THICKNESS;
|
|
@@ -75,9 +80,6 @@ function bandPath(o: LinearAdviceBandOptions, advice: ResolvedAdvice) {
|
|
|
75
80
|
// The caps are pixel geometry like the band: a scaled drawing holds them
|
|
76
81
|
// in the band's own units.
|
|
77
82
|
const u = o.unitsPerPx ?? 1;
|
|
78
|
-
const inset = ADVICE_CAP_INSET * u;
|
|
79
|
-
const edgeLo = capLo === AdviceCap.pill ? lo + inset : lo;
|
|
80
|
-
const edgeHi = capHi === AdviceCap.pill ? hi - inset : hi;
|
|
81
83
|
const radius = (cap: AdviceCap) =>
|
|
82
84
|
cap === AdviceCap.pill
|
|
83
85
|
? t / 2
|
|
@@ -86,7 +88,17 @@ function bandPath(o: LinearAdviceBandOptions, advice: ResolvedAdvice) {
|
|
|
86
88
|
: 0;
|
|
87
89
|
const rLo = radius(capLo);
|
|
88
90
|
const rHi = radius(capHi);
|
|
89
|
-
if (
|
|
91
|
+
if (hi - lo < rLo + rHi) return null;
|
|
92
|
+
// The pill tips give way before the pill: a range too short for both
|
|
93
|
+
// insets shares what is left beyond the caps between its pill ends, so a
|
|
94
|
+
// pixel-fixed pill in a small drawing still marks a short range.
|
|
95
|
+
const pills =
|
|
96
|
+
Number(capLo === AdviceCap.pill) + Number(capHi === AdviceCap.pill);
|
|
97
|
+
const inset = pills
|
|
98
|
+
? Math.min(ADVICE_CAP_INSET * u, (hi - lo - rLo - rHi) / pills)
|
|
99
|
+
: 0;
|
|
100
|
+
const edgeLo = capLo === AdviceCap.pill ? lo + inset : lo;
|
|
101
|
+
const edgeHi = capHi === AdviceCap.pill ? hi - inset : hi;
|
|
90
102
|
const p0 = o.perpStart;
|
|
91
103
|
const p1 = o.perpStart + t;
|
|
92
104
|
const v = o.vertical;
|