@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.23 → 2.2.0-next.25
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 +538 -202
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +271 -0
- package/dist/navigation-instruments/attitude/attitude.css_inline.js +64 -0
- package/dist/navigation-instruments/attitude/attitude.css_inline.js.map +1 -0
- package/dist/navigation-instruments/attitude/attitude.d.ts +121 -0
- package/dist/navigation-instruments/attitude/attitude.d.ts.map +1 -0
- package/dist/navigation-instruments/attitude/attitude.js +255 -0
- package/dist/navigation-instruments/attitude/attitude.js.map +1 -0
- package/dist/navigation-instruments/watch/tickmark.d.ts.map +1 -1
- package/dist/navigation-instruments/watch/tickmark.js +35 -13
- package/dist/navigation-instruments/watch/tickmark.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/dist/svghelpers/math.d.ts +7 -0
- package/dist/svghelpers/math.d.ts.map +1 -1
- package/dist/svghelpers/math.js +10 -1
- package/dist/svghelpers/math.js.map +1 -1
- package/llms/components/obc-attitude.md +69 -0
- package/llms/docs/building-blocks-advice.md +1 -0
- package/llms/llms-full.txt +73 -0
- package/llms/llms.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/navigation-instruments/attitude/attitude.css +54 -0
- package/src/navigation-instruments/attitude/attitude.spec.ts +208 -0
- package/src/navigation-instruments/attitude/attitude.stories.ts +87 -0
- package/src/navigation-instruments/attitude/attitude.ts +351 -0
- package/src/navigation-instruments/watch/tickmark.spec.ts +22 -0
- package/src/navigation-instruments/watch/tickmark.ts +49 -5
- package/src/svghelpers/advice-linear.ts +16 -4
- package/src/svghelpers/math.spec.ts +25 -0
- package/src/svghelpers/math.ts +10 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.js","names":[],"sources":["../../src/svghelpers/math.ts"],"sourcesContent":["/**\n * Numeric helpers shared by the SVG instruments and the components that draw\n * with them: range clamping, angle wrapping and degree/radian conversion.\n *\n * Keep the operand order as written. `(deg * Math.PI) / 180` and\n * `deg * (Math.PI / 180)` differ in the last bit, and the instrument\n * snapshots pin the former.\n */\n\n/**\n * `value` limited to `[min, max]`.\n *\n * @param value - Any number. NaN passes through as NaN, as with `Math.min` / `Math.max`.\n * @param min - Lower bound, inclusive.\n * @param max - Upper bound, inclusive; it wins when `min > max`.\n * @returns The bounded value.\n */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * A percentage limited to `[0, 100]`.\n *\n * @param value - Any number. NaN counts as 0, so a missing reading draws empty; ±Infinity clamp to the bounds.\n * @returns The bounded percentage.\n */\nexport function clampPercent(value: number): number {\n if (Number.isNaN(value)) return 0;\n return clamp(value, 0, 100);\n}\n\n/**\n * Degrees wrapped into `[0, 360)`.\n *\n * @param deg - Any finite angle, negative and over-turned included; a non-finite angle yields NaN.\n * @returns The same direction in `[0, 360)`, never negative zero.\n */\nexport function normalizeAngle(deg: number): number {\n return ((deg % 360) + 360) % 360;\n}\n\n/**\n * @param deg - Angle in degrees.\n * @returns The angle in radians, as `(deg * Math.PI) / 180`.\n */\nexport function degToRad(deg: number): number {\n return (deg * Math.PI) / 180;\n}\n\n/**\n * @param rad - Angle in radians.\n * @returns The angle in degrees, as `(rad * 180) / Math.PI`.\n */\nexport function radToDeg(rad: number): number {\n return (rad * 180) / Math.PI;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAgB,MAAM,OAAe,KAAa,KAAqB;CACrE,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C;;;;;;;AAQA,SAAgB,aAAa,OAAuB;CAClD,IAAI,OAAO,MAAM,KAAK,GAAG,OAAO;CAChC,OAAO,MAAM,OAAO,GAAG,GAAG;AAC5B;;;;;;;AAQA,SAAgB,eAAe,KAAqB;CAClD,QAAS,MAAM,MAAO,OAAO;AAC/B;;;;;AAMA,SAAgB,SAAS,KAAqB;CAC5C,OAAQ,MAAM,KAAK,KAAM;AAC3B;;;;;AAMA,SAAgB,SAAS,KAAqB;CAC5C,OAAQ,MAAM,MAAO,KAAK;AAC5B"}
|
|
1
|
+
{"version":3,"file":"math.js","names":[],"sources":["../../src/svghelpers/math.ts"],"sourcesContent":["/**\n * Numeric helpers shared by the SVG instruments and the components that draw\n * with them: range clamping, angle wrapping and degree/radian conversion.\n *\n * Keep the operand order as written. `(deg * Math.PI) / 180` and\n * `deg * (Math.PI / 180)` differ in the last bit, and the instrument\n * snapshots pin the former.\n */\n\n/**\n * `value` limited to `[min, max]`.\n *\n * @param value - Any number. NaN passes through as NaN, as with `Math.min` / `Math.max`.\n * @param min - Lower bound, inclusive.\n * @param max - Upper bound, inclusive; it wins when `min > max`.\n * @returns The bounded value.\n */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * A percentage limited to `[0, 100]`.\n *\n * @param value - Any number. NaN counts as 0, so a missing reading draws empty; ±Infinity clamp to the bounds.\n * @returns The bounded percentage.\n */\nexport function clampPercent(value: number): number {\n if (Number.isNaN(value)) return 0;\n return clamp(value, 0, 100);\n}\n\n/**\n * Degrees wrapped into `[0, 360)`.\n *\n * @param deg - Any finite angle, negative and over-turned included; a non-finite angle yields NaN.\n * @returns The same direction in `[0, 360)`, never negative zero.\n */\nexport function normalizeAngle(deg: number): number {\n return ((deg % 360) + 360) % 360;\n}\n\n/**\n * Degrees wrapped into `[-180, 180)`, for a deviation either side of zero.\n *\n * @param deg - Any finite angle, negative and over-turned included; a non-finite angle yields NaN.\n * @returns The same direction in `[-180, 180)`; a half turn is `-180`.\n */\nexport function normalizeSignedAngle(deg: number): number {\n return normalizeAngle(deg + 180) - 180;\n}\n\n/**\n * @param deg - Angle in degrees.\n * @returns The angle in radians, as `(deg * Math.PI) / 180`.\n */\nexport function degToRad(deg: number): number {\n return (deg * Math.PI) / 180;\n}\n\n/**\n * @param rad - Angle in radians.\n * @returns The angle in degrees, as `(rad * 180) / Math.PI`.\n */\nexport function radToDeg(rad: number): number {\n return (rad * 180) / Math.PI;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAgB,MAAM,OAAe,KAAa,KAAqB;CACrE,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C;;;;;;;AAQA,SAAgB,aAAa,OAAuB;CAClD,IAAI,OAAO,MAAM,KAAK,GAAG,OAAO;CAChC,OAAO,MAAM,OAAO,GAAG,GAAG;AAC5B;;;;;;;AAQA,SAAgB,eAAe,KAAqB;CAClD,QAAS,MAAM,MAAO,OAAO;AAC/B;;;;;;;AAQA,SAAgB,qBAAqB,KAAqB;CACxD,OAAO,eAAe,MAAM,GAAG,IAAI;AACrC;;;;;AAMA,SAAgB,SAAS,KAAqB;CAC5C,OAAQ,MAAM,KAAK,KAAM;AAC3B;;;;;AAMA,SAAgB,SAAS,KAAqB;CAC5C,OAAQ,MAAM,MAAO,KAAK;AAC5B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# `<obc-attitude>`
|
|
2
|
+
|
|
3
|
+
Attitude instrument that shows pitch and roll as a moving horizon behind a fixed vessel symbol, the way an artificial horizon does.
|
|
4
|
+
|
|
5
|
+
Lifecycle: experimental. [Storybook](https://openbridge-next-storybook.web.app/?path=/docs/instruments-attitude--docs) · [Source](https://raw.githubusercontent.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/develop/packages/openbridge-webcomponents/src/navigation-instruments/attitude/attitude.ts)
|
|
6
|
+
|
|
7
|
+
`<obc-attitude>` – Attitude instrument that shows pitch and roll as a moving
|
|
8
|
+
horizon behind a fixed vessel symbol, the way an artificial horizon does.
|
|
9
|
+
|
|
10
|
+
The symbol in the centre stays level. The ground half of the face slides
|
|
11
|
+
down as the pitch rises and tilts against the roll, so the picture matches
|
|
12
|
+
what is seen looking forward. A ladder of short rungs on the horizon gives
|
|
13
|
+
the pitch. The roll scale turns with the horizon, and the pointer at the
|
|
14
|
+
top, which stays straight up like the symbol, reads the roll on it.
|
|
15
|
+
|
|
16
|
+
## Features / Variants
|
|
17
|
+
|
|
18
|
+
- **Roll scale:** the band over the sky half of the face, labelled
|
|
19
|
+
90/45/0/45/90. It turns with the horizon, so the fixed pointer sits on
|
|
20
|
+
the side the vehicle rolls to. `showLabels` turns the labels off.
|
|
21
|
+
- **Full turns:** `pitch` and `roll` take any angle. Past ±90° of pitch the
|
|
22
|
+
ladder runs on to the inverted horizon, with the ground above the sky,
|
|
23
|
+
and the roll scale follows the sky to the lower half.
|
|
24
|
+
- **Pitch ladder:** one rung per `pitchTickInterval` degrees. A smaller
|
|
25
|
+
interval magnifies the pitch; a larger one shows more of it.
|
|
26
|
+
- **Priority:** `priority` switches the symbol and the pointer between the
|
|
27
|
+
`regular` and `enhanced` palette.
|
|
28
|
+
|
|
29
|
+
## Usage Guidelines
|
|
30
|
+
|
|
31
|
+
Use for a vehicle that is steered in three dimensions and whose operator
|
|
32
|
+
needs pitch and roll together at a glance. For readings against a scale
|
|
33
|
+
with advice zones use `obc-pitch`, `obc-roll` or `obc-pitch-roll`; for
|
|
34
|
+
pitch, roll and yaw deviation as a dot on a polar grid use
|
|
35
|
+
`obc-pitch-roll-yaw`.
|
|
36
|
+
|
|
37
|
+
The scales carry no numbers besides the roll labels. Put the values next to
|
|
38
|
+
the instrument with `obc-readout` when they have to be read exactly.
|
|
39
|
+
|
|
40
|
+
**TODO(designer)**: Figma 20108:142407 shows no pitch values on the ladder.
|
|
41
|
+
|
|
42
|
+
## Properties
|
|
43
|
+
|
|
44
|
+
| Property | Attribute | Type | Default | Description |
|
|
45
|
+
| --- | --- | --- | --- | --- |
|
|
46
|
+
| pitch | pitch | `number` | `0` | Pitch in degrees, positive with the front up. The horizon drops below the symbol as it rises. Any angle is accepted and wraps over a full turn. |
|
|
47
|
+
| roll | roll | `number` | `0` | Roll in degrees, positive with the right side down. The horizon and the roll scale turn the other way, as they appear from on board. Any angle is accepted. |
|
|
48
|
+
| pitchTickInterval | pitchTickInterval | `number` | `10` | Degrees of pitch between two ladder rungs, from 0.1 to 90. Default `10`, which shows about ±29° on the face. |
|
|
49
|
+
| showLabels | | `boolean` | `true` | When `true` (default), labels the roll scale. |
|
|
50
|
+
| priority | priority | `Priority` | | Palette of the symbol and the pointer: `regular` or `enhanced`. |
|
|
51
|
+
| faceDiameter | face-diameter | `number \| undefined` | | Outer-ring diameter in CSS pixels. When set, the instrument renders at a fixed size, so instruments that share the value have rings of the same size. |
|
|
52
|
+
|
|
53
|
+
## Events
|
|
54
|
+
|
|
55
|
+
None.
|
|
56
|
+
|
|
57
|
+
## Slots
|
|
58
|
+
|
|
59
|
+
None.
|
|
60
|
+
|
|
61
|
+
## Stories
|
|
62
|
+
|
|
63
|
+
- [Default](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--default): Level, as the design draws it (Figma 20108:142406).
|
|
64
|
+
- [Enhanced](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--enhanced)
|
|
65
|
+
- [Pitch And Roll](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--pitch-and-roll): Front up and right side down: the horizon drops and tilts to the left, and the roll scale turns with it under the pointer.
|
|
66
|
+
- [Inverted](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--inverted): Past half a turn of pitch the ladder shows the inverted horizon, ground on top. The roll scale follows the sky to the lower half, away from the pointer.
|
|
67
|
+
- [Fine Ladder](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--fine-ladder): One rung is 5°, so the same pitch moves the horizon twice as far.
|
|
68
|
+
- [Without Labels](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--without-labels)
|
|
69
|
+
- [Small](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--small): The roll labels keep their text size, so a small face gives up room to them.
|
|
@@ -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
|
---
|
|
@@ -14686,6 +14687,78 @@ This component does not use slots. The image is provided via the `imageSrc` prop
|
|
|
14686
14687
|
|
|
14687
14688
|
---
|
|
14688
14689
|
|
|
14690
|
+
# `<obc-attitude>`
|
|
14691
|
+
|
|
14692
|
+
Attitude instrument that shows pitch and roll as a moving horizon behind a fixed vessel symbol, the way an artificial horizon does.
|
|
14693
|
+
|
|
14694
|
+
Lifecycle: experimental. [Storybook](https://openbridge-next-storybook.web.app/?path=/docs/instruments-attitude--docs) · [Source](https://raw.githubusercontent.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/develop/packages/openbridge-webcomponents/src/navigation-instruments/attitude/attitude.ts)
|
|
14695
|
+
|
|
14696
|
+
`<obc-attitude>` – Attitude instrument that shows pitch and roll as a moving
|
|
14697
|
+
horizon behind a fixed vessel symbol, the way an artificial horizon does.
|
|
14698
|
+
|
|
14699
|
+
The symbol in the centre stays level. The ground half of the face slides
|
|
14700
|
+
down as the pitch rises and tilts against the roll, so the picture matches
|
|
14701
|
+
what is seen looking forward. A ladder of short rungs on the horizon gives
|
|
14702
|
+
the pitch. The roll scale turns with the horizon, and the pointer at the
|
|
14703
|
+
top, which stays straight up like the symbol, reads the roll on it.
|
|
14704
|
+
|
|
14705
|
+
## Features / Variants
|
|
14706
|
+
|
|
14707
|
+
- **Roll scale:** the band over the sky half of the face, labelled
|
|
14708
|
+
90/45/0/45/90. It turns with the horizon, so the fixed pointer sits on
|
|
14709
|
+
the side the vehicle rolls to. `showLabels` turns the labels off.
|
|
14710
|
+
- **Full turns:** `pitch` and `roll` take any angle. Past ±90° of pitch the
|
|
14711
|
+
ladder runs on to the inverted horizon, with the ground above the sky,
|
|
14712
|
+
and the roll scale follows the sky to the lower half.
|
|
14713
|
+
- **Pitch ladder:** one rung per `pitchTickInterval` degrees. A smaller
|
|
14714
|
+
interval magnifies the pitch; a larger one shows more of it.
|
|
14715
|
+
- **Priority:** `priority` switches the symbol and the pointer between the
|
|
14716
|
+
`regular` and `enhanced` palette.
|
|
14717
|
+
|
|
14718
|
+
## Usage Guidelines
|
|
14719
|
+
|
|
14720
|
+
Use for a vehicle that is steered in three dimensions and whose operator
|
|
14721
|
+
needs pitch and roll together at a glance. For readings against a scale
|
|
14722
|
+
with advice zones use `obc-pitch`, `obc-roll` or `obc-pitch-roll`; for
|
|
14723
|
+
pitch, roll and yaw deviation as a dot on a polar grid use
|
|
14724
|
+
`obc-pitch-roll-yaw`.
|
|
14725
|
+
|
|
14726
|
+
The scales carry no numbers besides the roll labels. Put the values next to
|
|
14727
|
+
the instrument with `obc-readout` when they have to be read exactly.
|
|
14728
|
+
|
|
14729
|
+
**TODO(designer)**: Figma 20108:142407 shows no pitch values on the ladder.
|
|
14730
|
+
|
|
14731
|
+
## Properties
|
|
14732
|
+
|
|
14733
|
+
| Property | Attribute | Type | Default | Description |
|
|
14734
|
+
| --- | --- | --- | --- | --- |
|
|
14735
|
+
| pitch | pitch | `number` | `0` | Pitch in degrees, positive with the front up. The horizon drops below the symbol as it rises. Any angle is accepted and wraps over a full turn. |
|
|
14736
|
+
| roll | roll | `number` | `0` | Roll in degrees, positive with the right side down. The horizon and the roll scale turn the other way, as they appear from on board. Any angle is accepted. |
|
|
14737
|
+
| pitchTickInterval | pitchTickInterval | `number` | `10` | Degrees of pitch between two ladder rungs, from 0.1 to 90. Default `10`, which shows about ±29° on the face. |
|
|
14738
|
+
| showLabels | | `boolean` | `true` | When `true` (default), labels the roll scale. |
|
|
14739
|
+
| priority | priority | `Priority` | | Palette of the symbol and the pointer: `regular` or `enhanced`. |
|
|
14740
|
+
| faceDiameter | face-diameter | `number \| undefined` | | Outer-ring diameter in CSS pixels. When set, the instrument renders at a fixed size, so instruments that share the value have rings of the same size. |
|
|
14741
|
+
|
|
14742
|
+
## Events
|
|
14743
|
+
|
|
14744
|
+
None.
|
|
14745
|
+
|
|
14746
|
+
## Slots
|
|
14747
|
+
|
|
14748
|
+
None.
|
|
14749
|
+
|
|
14750
|
+
## Stories
|
|
14751
|
+
|
|
14752
|
+
- [Default](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--default): Level, as the design draws it (Figma 20108:142406).
|
|
14753
|
+
- [Enhanced](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--enhanced)
|
|
14754
|
+
- [Pitch And Roll](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--pitch-and-roll): Front up and right side down: the horizon drops and tilts to the left, and the roll scale turns with it under the pointer.
|
|
14755
|
+
- [Inverted](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--inverted): Past half a turn of pitch the ladder shows the inverted horizon, ground on top. The roll scale follows the sky to the lower half, away from the pointer.
|
|
14756
|
+
- [Fine Ladder](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--fine-ladder): One rung is 5°, so the same pitch moves the horizon twice as far.
|
|
14757
|
+
- [Without Labels](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--without-labels)
|
|
14758
|
+
- [Small](https://openbridge-next-storybook.web.app/?path=/story/instruments-attitude--small): The roll labels keep their text size, so a small face gives up room to them.
|
|
14759
|
+
|
|
14760
|
+
---
|
|
14761
|
+
|
|
14689
14762
|
# `<obc-azimuth-thruster>`
|
|
14690
14763
|
|
|
14691
14764
|
No summary yet.
|
package/llms/llms.txt
CHANGED
|
@@ -168,6 +168,7 @@ React, Vue, Angular and Svelte wrappers.
|
|
|
168
168
|
|
|
169
169
|
## Navigation instruments and indicators
|
|
170
170
|
|
|
171
|
+
- [obc-attitude](https://openbridge-next-storybook.web.app/components/obc-attitude.md): Attitude instrument that shows pitch and roll as a moving horizon behind a fixed vessel symbol, the way an artificial horizon does. (experimental)
|
|
171
172
|
- [obc-azimuth-thruster](https://openbridge-next-storybook.web.app/components/obc-azimuth-thruster.md): no summary yet (stable)
|
|
172
173
|
- [obc-azimuth-thruster-labeled](https://openbridge-next-storybook.web.app/components/obc-azimuth-thruster-labeled.md): no summary yet (deprecated: The azimuth-thruster-labeled component is deprecated and will be removed in future releases.)
|
|
173
174
|
- [obc-badge-command](https://openbridge-next-storybook.web.app/components/obc-badge-command.md): no summary yet (stable)
|
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.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
* {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.container {
|
|
6
|
+
position: relative; /* containing block for the three stacked layers */
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100%;
|
|
9
|
+
|
|
10
|
+
--attitude-symbol-color: var(--element-neutral-color);
|
|
11
|
+
--attitude-accent-color: var(--instrument-regular-secondary-color);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.container.enhanced {
|
|
15
|
+
--attitude-symbol-color: var(--element-neutral-enhanced-color);
|
|
16
|
+
--attitude-accent-color: var(--instrument-enhanced-secondary-color);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* The horizon sits under the watch so the roll scale band covers it. */
|
|
20
|
+
.container > obc-watch,
|
|
21
|
+
.container > svg {
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 0;
|
|
24
|
+
left: 0;
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ground {
|
|
30
|
+
fill: var(--instrument-frame-secondary-color);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Regular colour in both priorities, as the design draws it. */
|
|
34
|
+
.horizon-line {
|
|
35
|
+
stroke: var(--instrument-regular-secondary-color);
|
|
36
|
+
stroke-width: 2;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.rung {
|
|
40
|
+
stroke: var(--instrument-frame-tertiary-color);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.face-outline {
|
|
44
|
+
fill: none;
|
|
45
|
+
stroke: var(--instrument-frame-tertiary-color);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.vessel-symbol path {
|
|
49
|
+
fill: var(--attitude-symbol-color);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.vessel-symbol circle {
|
|
53
|
+
fill: var(--attitude-accent-color);
|
|
54
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {render} from 'vitest-browser-lit';
|
|
3
|
+
import {html} from 'lit';
|
|
4
|
+
import './attitude.js';
|
|
5
|
+
import type {ObcAttitude} from './attitude.js';
|
|
6
|
+
import type {ObcWatch} from '../watch/watch.js';
|
|
7
|
+
import '../../main.css';
|
|
8
|
+
|
|
9
|
+
/** One ladder rung, in SVG units; a rung is `pitchTickInterval` degrees. */
|
|
10
|
+
const RUNG = 64;
|
|
11
|
+
|
|
12
|
+
async function mount(props: Partial<ObcAttitude> = {}): Promise<ObcAttitude> {
|
|
13
|
+
const screen = render(
|
|
14
|
+
html`<div style="width: 512px; height: 512px">
|
|
15
|
+
<obc-attitude></obc-attitude>
|
|
16
|
+
</div>`
|
|
17
|
+
);
|
|
18
|
+
const el = screen.container.querySelector('obc-attitude') as ObcAttitude;
|
|
19
|
+
Object.assign(el, props);
|
|
20
|
+
await el.updateComplete;
|
|
21
|
+
return el;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The numbers of one `name(a b)` function in a transform attribute. */
|
|
25
|
+
function transformOf(el: Element | null, name: string): number[] {
|
|
26
|
+
const match = new RegExp(`${name}\\(([^)]*)\\)`).exec(
|
|
27
|
+
el?.getAttribute('transform') ?? ''
|
|
28
|
+
);
|
|
29
|
+
return match
|
|
30
|
+
? match[1]
|
|
31
|
+
.trim()
|
|
32
|
+
.split(/[\s,]+/)
|
|
33
|
+
.map(Number)
|
|
34
|
+
: [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function horizonOf(el: ObcAttitude): SVGGElement {
|
|
38
|
+
return el.shadowRoot!.querySelector<SVGGElement>('g.horizon')!;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function numbers(el: ObcAttitude, selector: string, attr: string): number[] {
|
|
42
|
+
return [...el.shadowRoot!.querySelectorAll(selector)]
|
|
43
|
+
.map((node) => Number(node.getAttribute(attr)))
|
|
44
|
+
.sort((a, b) => a - b);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Whether a ground band covers the point `dy` units below the face centre. */
|
|
48
|
+
function groundAt(el: ObcAttitude, dy: number): boolean {
|
|
49
|
+
const [, shift] = transformOf(horizonOf(el), 'translate');
|
|
50
|
+
const y = dy - shift;
|
|
51
|
+
return [...el.shadowRoot!.querySelectorAll('rect.ground')].some((rect) => {
|
|
52
|
+
const top = Number(rect.getAttribute('y'));
|
|
53
|
+
return y >= top && y <= top + Number(rect.getAttribute('height'));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function watchOf(el: ObcAttitude): ObcWatch {
|
|
58
|
+
return el.shadowRoot!.querySelector('obc-watch') as ObcWatch;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
describe('obc-attitude — the horizon follows pitch and roll', () => {
|
|
62
|
+
it('sits level through the centre at zero pitch and roll', async () => {
|
|
63
|
+
const horizon = horizonOf(await mount());
|
|
64
|
+
expect(transformOf(horizon, 'rotate')).toEqual([0]);
|
|
65
|
+
expect(transformOf(horizon, 'translate')).toEqual([0, 0]);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('drops one rung per pitchTickInterval of positive pitch', async () => {
|
|
69
|
+
const el = await mount({pitch: 10});
|
|
70
|
+
expect(transformOf(horizonOf(el), 'translate')).toEqual([0, RUNG]);
|
|
71
|
+
el.pitchTickInterval = 5;
|
|
72
|
+
await el.updateComplete;
|
|
73
|
+
expect(transformOf(horizonOf(el), 'translate')).toEqual([0, 2 * RUNG]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('tilts against the roll', async () => {
|
|
77
|
+
const el = await mount({roll: 30});
|
|
78
|
+
expect(transformOf(horizonOf(el), 'rotate')).toEqual([-30]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('keeps the ground below the centre when level', async () => {
|
|
82
|
+
const el = await mount();
|
|
83
|
+
expect(groundAt(el, 10)).toBe(true);
|
|
84
|
+
expect(groundAt(el, -10)).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('obc-attitude — pitch wraps over a full turn', () => {
|
|
89
|
+
it('draws a full turn the same as no turn', async () => {
|
|
90
|
+
const el = await mount({pitch: 370});
|
|
91
|
+
expect(transformOf(horizonOf(el), 'translate')).toEqual([0, RUNG]);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('shows the ground above the centre when pitched half a turn', async () => {
|
|
95
|
+
const el = await mount({pitch: 180});
|
|
96
|
+
expect(groundAt(el, -10)).toBe(true);
|
|
97
|
+
expect(groundAt(el, 10)).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('shows only sky when pointing straight up', async () => {
|
|
101
|
+
const el = await mount({pitch: 90});
|
|
102
|
+
expect(groundAt(el, -180)).toBe(false);
|
|
103
|
+
expect(groundAt(el, 0)).toBe(false);
|
|
104
|
+
expect(groundAt(el, 180)).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe('obc-attitude — pitch ladder', () => {
|
|
109
|
+
/** Rung positions measured from the face centre, along the ladder. */
|
|
110
|
+
const rungOffsets = (el: ObcAttitude) => {
|
|
111
|
+
const [, shift] = transformOf(horizonOf(el), 'translate');
|
|
112
|
+
return numbers(el, 'line.rung', 'y1').map((y) => y + shift);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
it('treats an interval below a tenth of a degree as a tenth', async () => {
|
|
116
|
+
const el = await mount({pitch: 100, pitchTickInterval: 1e-10});
|
|
117
|
+
expect(transformOf(horizonOf(el), 'translate')).toEqual([0, 1000 * RUNG]);
|
|
118
|
+
expect(numbers(el, 'line.rung', 'y1').length).toBeLessThanOrEqual(7);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('mirrors the rungs around the inverted horizon for any interval', async () => {
|
|
122
|
+
const offsets = rungOffsets(
|
|
123
|
+
await mount({pitch: 180, pitchTickInterval: 7})
|
|
124
|
+
);
|
|
125
|
+
expect(offsets.length).toBeGreaterThan(0);
|
|
126
|
+
offsets.forEach((offset, i) =>
|
|
127
|
+
expect(offset).toBeCloseTo(-offsets[offsets.length - 1 - i], 6)
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('does not shift the rungs as the pitch passes half a turn', async () => {
|
|
132
|
+
const before = rungOffsets(
|
|
133
|
+
await mount({pitch: 179.99, pitchTickInterval: 7})
|
|
134
|
+
);
|
|
135
|
+
const after = rungOffsets(
|
|
136
|
+
await mount({pitch: 180.01, pitchTickInterval: 7})
|
|
137
|
+
);
|
|
138
|
+
expect(after).toHaveLength(before.length);
|
|
139
|
+
after.forEach((offset, i) =>
|
|
140
|
+
expect(Math.abs(offset - before[i])).toBeLessThan(1)
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('draws a rung every 64 units and none on the horizon line', async () => {
|
|
145
|
+
const el = await mount();
|
|
146
|
+
const rungs = numbers(el, 'line.rung', 'y1');
|
|
147
|
+
expect(rungs).toEqual([-2 * RUNG, -RUNG, RUNG, 2 * RUNG]);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('keeps the rungs around the centre as the ladder slides', async () => {
|
|
151
|
+
const el = await mount({pitch: 40});
|
|
152
|
+
const rungs = numbers(el, 'line.rung', 'y1');
|
|
153
|
+
expect(rungs).toEqual([
|
|
154
|
+
-6 * RUNG,
|
|
155
|
+
-5 * RUNG,
|
|
156
|
+
-4 * RUNG,
|
|
157
|
+
-3 * RUNG,
|
|
158
|
+
-2 * RUNG,
|
|
159
|
+
]);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('obc-attitude — roll scale and pointer', () => {
|
|
164
|
+
it('keeps the pointer straight up while the vehicle rolls', async () => {
|
|
165
|
+
const el = await mount({roll: 30});
|
|
166
|
+
const pointer = el.shadowRoot!.querySelector('g.roll-pointer');
|
|
167
|
+
expect(pointer).not.toBeNull();
|
|
168
|
+
expect(pointer!.hasAttribute('transform')).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('turns the roll scale with the horizon', async () => {
|
|
172
|
+
const el = await mount({roll: 30});
|
|
173
|
+
expect(watchOf(el).rotation).toBe(-30);
|
|
174
|
+
expect(transformOf(horizonOf(el), 'rotate')).toEqual([-30]);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('keeps the roll scale on the sky side once the pitch passes vertical', async () => {
|
|
178
|
+
// Pitched over the top the vehicle is upside down: the sky is below.
|
|
179
|
+
expect(watchOf(await mount({pitch: 80, roll: -15})).rotation).toBe(15);
|
|
180
|
+
expect(watchOf(await mount({pitch: 172, roll: -15})).rotation).toBe(195);
|
|
181
|
+
expect(watchOf(await mount({pitch: -172, roll: -15})).rotation).toBe(195);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('turns the rest of the face edge with the roll scale', async () => {
|
|
185
|
+
const el = await mount({roll: 30});
|
|
186
|
+
const outline = el.shadowRoot!.querySelector('path.face-outline');
|
|
187
|
+
expect(transformOf(outline, 'rotate')).toEqual([-30]);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('spans the top half with unsigned roll labels', async () => {
|
|
191
|
+
const watch = watchOf(await mount());
|
|
192
|
+
expect(watch.areas.map((a) => [a.startAngle, a.endAngle])).toEqual([
|
|
193
|
+
[-90, 90],
|
|
194
|
+
]);
|
|
195
|
+
// Left of the top first: the watch counts those angles from 270 up.
|
|
196
|
+
const signed = (angle: number) => (angle > 180 ? angle - 360 : angle);
|
|
197
|
+
const labels = watch.tickmarks
|
|
198
|
+
.filter((t) => t.text !== undefined)
|
|
199
|
+
.sort((a, b) => signed(a.angle) - signed(b.angle))
|
|
200
|
+
.map((t) => t.text);
|
|
201
|
+
expect(labels).toEqual(['90', '45', '0', '45', '90']);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('drops the labels when showLabels is off', async () => {
|
|
205
|
+
const watch = watchOf(await mount({showLabels: false}));
|
|
206
|
+
expect(watch.tickmarks.some((t) => t.text !== undefined)).toBe(false);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type {Meta, StoryObj} from '@storybook/web-components-vite';
|
|
2
|
+
import {ObcAttitude} from './attitude.js';
|
|
3
|
+
import './attitude.js';
|
|
4
|
+
import {widthDecorator} from '../../storybook-util.js';
|
|
5
|
+
import {Priority} from '../types.js';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof ObcAttitude> = {
|
|
8
|
+
title: 'Instruments/Attitude',
|
|
9
|
+
tags: ['autodocs', '6.1', 'experimental'],
|
|
10
|
+
component: 'obc-attitude',
|
|
11
|
+
args: {
|
|
12
|
+
width: 512,
|
|
13
|
+
pitch: 0,
|
|
14
|
+
roll: 0,
|
|
15
|
+
pitchTickInterval: 10,
|
|
16
|
+
showLabels: true,
|
|
17
|
+
priority: Priority.regular,
|
|
18
|
+
},
|
|
19
|
+
argTypes: {
|
|
20
|
+
width: {control: {type: 'range', min: 100, max: 1000, step: 1}},
|
|
21
|
+
pitch: {control: {type: 'range', min: -180, max: 180, step: 0.5}},
|
|
22
|
+
roll: {control: {type: 'range', min: -180, max: 180, step: 0.5}},
|
|
23
|
+
pitchTickInterval: {control: {type: 'range', min: 1, max: 90, step: 1}},
|
|
24
|
+
priority: {control: 'select', options: Object.values(Priority)},
|
|
25
|
+
showLabels: {control: 'boolean'},
|
|
26
|
+
},
|
|
27
|
+
decorators: [widthDecorator],
|
|
28
|
+
} satisfies Meta<ObcAttitude>;
|
|
29
|
+
|
|
30
|
+
export default meta;
|
|
31
|
+
type Story = StoryObj<ObcAttitude>;
|
|
32
|
+
|
|
33
|
+
/** Level, as the design draws it (Figma 20108:142406). */
|
|
34
|
+
export const Default: Story = {
|
|
35
|
+
args: {},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Enhanced: Story = {
|
|
39
|
+
args: {
|
|
40
|
+
priority: Priority.enhanced,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Front up and right side down: the horizon drops and tilts to the left, and
|
|
46
|
+
* the roll scale turns with it under the pointer.
|
|
47
|
+
*/
|
|
48
|
+
export const PitchAndRoll: Story = {
|
|
49
|
+
args: {
|
|
50
|
+
pitch: 12,
|
|
51
|
+
roll: 25,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Past half a turn of pitch the ladder shows the inverted horizon, ground on
|
|
57
|
+
* top. The roll scale follows the sky to the lower half, away from the pointer.
|
|
58
|
+
*/
|
|
59
|
+
export const Inverted: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
pitch: 172,
|
|
62
|
+
roll: -15,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** One rung is 5°, so the same pitch moves the horizon twice as far. */
|
|
67
|
+
export const FineLadder: Story = {
|
|
68
|
+
args: {
|
|
69
|
+
pitch: 12,
|
|
70
|
+
pitchTickInterval: 5,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const WithoutLabels: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
showLabels: false,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** The roll labels keep their text size, so a small face gives up room to them. */
|
|
81
|
+
export const Small: Story = {
|
|
82
|
+
args: {
|
|
83
|
+
width: 160,
|
|
84
|
+
pitch: 6,
|
|
85
|
+
roll: -10,
|
|
86
|
+
},
|
|
87
|
+
};
|