@oicl/openbridge-webcomponents 0.0.15-dev-20240916083108 → 0.0.15-dev-20240923184809
Sign up to get free protection for your applications and to get access to all the features.
- package/.storybook/main.ts +8 -0
- package/.storybook/preview.ts +2 -0
- package/__snapshots__/building-blocks-watch--advice.png +0 -0
- package/__snapshots__/building-blocks-watch-flat--primary.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster--in-command-at-setpoint-disable-auto-setpoint.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster--in-command-at-setpoint.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster--in-command.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster--pod.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster--single-direction-with-propeller.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster--single-direction.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster-labeled--large.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster-labeled--medium.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster-labeled--no-command.png +0 -0
- package/__snapshots__/navigation-instruments-compass--primary.png +0 -0
- package/__snapshots__/navigation-instruments-compass-flat--primary.png +0 -0
- package/__snapshots__/navigation-instruments-compass-flat--with-fov-indicator.png +0 -0
- package/__snapshots__/navigation-instruments-main-engine--active.png +0 -0
- package/__snapshots__/navigation-instruments-main-engine--in-command.png +0 -0
- package/__snapshots__/navigation-instruments-main-engine--off.png +0 -0
- package/__snapshots__/navigation-instruments-thruster--tunnel.png +0 -0
- package/custom-elements.json +2184 -660
- package/dist/navigation-instruments/azimuth-thruster/azimuth-thruster.d.ts.map +1 -1
- package/dist/navigation-instruments/azimuth-thruster/azimuth-thruster.js +2 -1
- package/dist/navigation-instruments/azimuth-thruster/azimuth-thruster.js.map +1 -1
- package/dist/navigation-instruments/compass/arrow.d.ts +7 -0
- package/dist/navigation-instruments/compass/arrow.d.ts.map +1 -0
- package/dist/navigation-instruments/compass/arrow.js +59 -0
- package/dist/navigation-instruments/compass/arrow.js.map +1 -0
- package/dist/navigation-instruments/compass/compass.d.ts +23 -0
- package/dist/navigation-instruments/compass/compass.d.ts.map +1 -0
- package/dist/navigation-instruments/compass/compass.js +139 -0
- package/dist/navigation-instruments/compass/compass.js.map +1 -0
- package/dist/navigation-instruments/compass/radial-tickmark.d.ts +4 -0
- package/dist/navigation-instruments/compass/radial-tickmark.d.ts.map +1 -0
- package/dist/navigation-instruments/compass/radial-tickmark.js +69 -0
- package/dist/navigation-instruments/compass/radial-tickmark.js.map +1 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.css.js +29 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.css.js.map +1 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.d.ts +45 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.d.ts.map +1 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.js +223 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.js.map +1 -0
- package/dist/navigation-instruments/main-engine/main-engine.css.js +22 -0
- package/dist/navigation-instruments/main-engine/main-engine.css.js.map +1 -0
- package/dist/navigation-instruments/main-engine/main-engine.d.ts +29 -0
- package/dist/navigation-instruments/main-engine/main-engine.d.ts.map +1 -0
- package/dist/navigation-instruments/main-engine/main-engine.js +196 -0
- package/dist/navigation-instruments/main-engine/main-engine.js.map +1 -0
- package/dist/navigation-instruments/thruster/advice.d.ts.map +1 -1
- package/dist/navigation-instruments/thruster/advice.js +9 -5
- package/dist/navigation-instruments/thruster/advice.js.map +1 -1
- package/dist/navigation-instruments/thruster/thruster.d.ts +54 -1
- package/dist/navigation-instruments/thruster/thruster.d.ts.map +1 -1
- package/dist/navigation-instruments/thruster/thruster.js +163 -99
- package/dist/navigation-instruments/thruster/thruster.js.map +1 -1
- package/dist/navigation-instruments/watch/advice.js +1 -1
- package/dist/navigation-instruments/watch/advice.js.map +1 -1
- package/dist/navigation-instruments/watch/label.d.ts +3 -0
- package/dist/navigation-instruments/watch/label.d.ts.map +1 -0
- package/dist/navigation-instruments/watch/label.js +68 -0
- package/dist/navigation-instruments/watch/label.js.map +1 -0
- package/dist/navigation-instruments/watch/watch.css.js +15 -14
- package/dist/navigation-instruments/watch/watch.css.js.map +1 -1
- package/dist/navigation-instruments/watch/watch.d.ts +3 -0
- package/dist/navigation-instruments/watch/watch.d.ts.map +1 -1
- package/dist/navigation-instruments/watch/watch.js +34 -1
- package/dist/navigation-instruments/watch/watch.js.map +1 -1
- package/dist/navigation-instruments/watch-flat/tickmark-flat.d.ts +20 -0
- package/dist/navigation-instruments/watch-flat/tickmark-flat.d.ts.map +1 -0
- package/dist/navigation-instruments/watch-flat/tickmark-flat.js +53 -0
- package/dist/navigation-instruments/watch-flat/tickmark-flat.js.map +1 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.css.js +32 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.css.js.map +1 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.d.ts +29 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.d.ts.map +1 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.js +184 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.js.map +1 -0
- package/dist/svghelpers/rectangular.d.ts +1 -0
- package/dist/svghelpers/rectangular.d.ts.map +1 -1
- package/dist/svghelpers/rectangular.js +3 -2
- package/dist/svghelpers/rectangular.js.map +1 -1
- package/package.json +16 -11
- package/src/navigation-instruments/azimuth-thruster/azimuth-thruster.ts +1 -0
- package/src/navigation-instruments/compass/arrow.ts +61 -0
- package/src/navigation-instruments/compass/compass.stories.ts +37 -0
- package/src/navigation-instruments/compass/compass.ts +132 -0
- package/src/navigation-instruments/compass/radial-tickmark.ts +77 -0
- package/src/navigation-instruments/compass-flat/compass-flat.css +23 -0
- package/src/navigation-instruments/compass-flat/compass-flat.stories.ts +35 -0
- package/src/navigation-instruments/compass-flat/compass-flat.ts +221 -0
- package/src/navigation-instruments/main-engine/main-engine.css +17 -0
- package/src/navigation-instruments/main-engine/main-engine.stories.ts +54 -0
- package/src/navigation-instruments/main-engine/main-engine.ts +160 -0
- package/src/navigation-instruments/thruster/advice.ts +9 -5
- package/src/navigation-instruments/thruster/thruster.stories.ts +1 -0
- package/src/navigation-instruments/thruster/thruster.ts +205 -113
- package/src/navigation-instruments/watch/advice.ts +1 -1
- package/src/navigation-instruments/watch/label.ts +69 -0
- package/src/navigation-instruments/watch/watch.css +7 -7
- package/src/navigation-instruments/watch/watch.ts +30 -1
- package/src/navigation-instruments/watch-flat/tickmark-flat.ts +62 -0
- package/src/navigation-instruments/watch-flat/watch-flat.css +19 -0
- package/src/navigation-instruments/watch-flat/watch-flat.stories.ts +17 -0
- package/src/navigation-instruments/watch-flat/watch-flat.ts +148 -0
- package/src/palettes/variables.css +1343 -1343
- package/src/svghelpers/rectangular.ts +6 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rectangular.d.ts","sourceRoot":"","sources":["../../src/svghelpers/rectangular.ts"],"names":[],"mappings":"AAEA,wBAAgB,IAAI,CAClB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,QAAQ,GAAG,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"rectangular.d.ts","sourceRoot":"","sources":["../../src/svghelpers/rectangular.ts"],"names":[],"mappings":"AAEA,wBAAgB,IAAI,CAClB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,QAAQ,GAAG,SAAS,CAAC;IACrC,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ,+CA4BF"}
|
@@ -1,13 +1,14 @@
|
|
1
1
|
import { svg } from "lit";
|
2
2
|
function rect(id, data) {
|
3
|
+
const yPosition = data.y !== void 0 ? data.y : -data.height / 2;
|
3
4
|
if (data.strokePosition === "inside") {
|
4
5
|
return svg`
|
5
6
|
<defs>
|
6
7
|
<clipPath id="clip${id}">
|
7
|
-
<rect id=${id} x=${-data.width / 2} y=${
|
8
|
+
<rect id=${id} x=${-data.width / 2} y=${yPosition} width=${data.width} height=${data.height} rx=${data.borderRadius} vector-effect="non-scaling-stroke" />
|
8
9
|
</clipPath>
|
9
10
|
</defs>
|
10
|
-
<rect id=${id} x=${-data.width / 2} y=${
|
11
|
+
<rect id=${id} x=${-data.width / 2} y=${yPosition} width=${data.width} height=${data.height} rx=${data.borderRadius} vector-effect="non-scaling-stroke" stroke=${data.strokeColor} stroke-width=${data.strokeWidth * 2} fill=${data.fillColor} clip-path="url(#clip${id})"/>
|
11
12
|
`;
|
12
13
|
} else {
|
13
14
|
return null;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rectangular.js","sources":["../../src/svghelpers/rectangular.ts"],"sourcesContent":["import {svg} from 'lit';\n\nexport function rect(\n id: string,\n data: {\n width: number;\n height: number;\n strokeWidth: number;\n strokeColor: string;\n fillColor: string;\n borderRadius: number;\n strokePosition: 'inside' | 'outside';\n }\n) {\n if (data.strokePosition === 'inside') {\n return svg`\n\t\t<defs>\n\t\t\t<clipPath id=\"clip${id}\">\n\t\t\t\t<rect id=${id} x=${-data.width / 2} y=${
|
1
|
+
{"version":3,"file":"rectangular.js","sources":["../../src/svghelpers/rectangular.ts"],"sourcesContent":["import {svg} from 'lit';\n\nexport function rect(\n id: string,\n data: {\n width: number;\n height: number;\n strokeWidth: number;\n strokeColor: string;\n fillColor: string;\n borderRadius: number;\n strokePosition: 'inside' | 'outside';\n y?: number;\n }\n) {\n const yPosition = data.y !== undefined ? data.y : -data.height / 2;\n\n if (data.strokePosition === 'inside') {\n return svg`\n\t\t<defs>\n\t\t\t<clipPath id=\"clip${id}\">\n\t\t\t\t<rect id=${id} x=${-data.width / 2} y=${yPosition} width=${\n data.width\n } height=${data.height} rx=${\n data.borderRadius\n } vector-effect=\"non-scaling-stroke\" />\n\t\t\t</clipPath>\n\t\t</defs>\n\t\t<rect id=${id} x=${-data.width / 2} y=${yPosition} width=${\n data.width\n } height=${data.height} rx=${\n data.borderRadius\n } vector-effect=\"non-scaling-stroke\" stroke=${\n data.strokeColor\n } stroke-width=${data.strokeWidth * 2} fill=${\n data.fillColor\n } clip-path=\"url(#clip${id})\"/> \n\t\t `;\n } else {\n return null;\n }\n}\n"],"names":[],"mappings":";AAEgB,SAAA,KACd,IACA,MAUA;AACM,QAAA,YAAY,KAAK,MAAM,SAAY,KAAK,IAAI,CAAC,KAAK,SAAS;AAE7D,MAAA,KAAK,mBAAmB,UAAU;AAC7B,WAAA;AAAA;AAAA,uBAEY,EAAE;AAAA,eACV,EAAE,MAAM,CAAC,KAAK,QAAQ,CAAC,MAAM,SAAS,UAC3C,KAAK,KACP,WAAW,KAAK,MAAM,OACpB,KAAK,YACP;AAAA;AAAA;AAAA,aAGK,EAAE,MAAM,CAAC,KAAK,QAAQ,CAAC,MAAM,SAAS,UAC7C,KAAK,KACP,WAAW,KAAK,MAAM,OACpB,KAAK,YACP,8CACE,KAAK,WACP,kBAAkB,KAAK,cAAc,CAAC,SACpC,KAAK,SACP,wBAAwB,EAAE;AAAA;AAAA,EAAA,OAErB;AACE,WAAA;AAAA,EACT;AACF;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@oicl/openbridge-webcomponents",
|
3
|
-
"version": "0.0.15-dev-
|
3
|
+
"version": "0.0.15-dev-20240923184809",
|
4
4
|
"type": "module",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -35,23 +35,28 @@
|
|
35
35
|
"lit": "^3.1.0"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
|
+
"@chromatic-com/storybook": "^1.7.0",
|
38
39
|
"@custom-elements-manifest/analyzer": "^0.9.0",
|
39
40
|
"@lit-labs/cli": "^0.6.4",
|
40
41
|
"@lit-labs/gen-wrapper-react": "^0.3.2",
|
41
42
|
"@lit-labs/gen-wrapper-vue": "^0.3.3",
|
42
43
|
"@open-wc/lit-helpers": "^0.7.0",
|
43
|
-
"@
|
44
|
-
"@storybook/addon-
|
45
|
-
"@storybook/addon-
|
46
|
-
"@storybook/addon-
|
47
|
-
"@storybook/addon-
|
48
|
-
"@storybook/
|
49
|
-
"@storybook/
|
44
|
+
"@playwright/test": "^1.46.1",
|
45
|
+
"@storybook/addon-essentials": "^8.2.9",
|
46
|
+
"@storybook/addon-interactions": "^8.2.9",
|
47
|
+
"@storybook/addon-links": "^8.2.9",
|
48
|
+
"@storybook/addon-storysource": "^8.2.9",
|
49
|
+
"@storybook/addon-themes": "^8.2.9",
|
50
|
+
"@storybook/blocks": "^8.2.9",
|
51
|
+
"@storybook/manager-api": "^8.2.9",
|
52
|
+
"@storybook/test": "^8.2.9",
|
50
53
|
"@storybook/test-runner": "^0.17.0",
|
51
|
-
"@storybook/
|
52
|
-
"@storybook/web-components
|
54
|
+
"@storybook/theming": "^8.2.9",
|
55
|
+
"@storybook/web-components": "^8.2.9",
|
56
|
+
"@storybook/web-components-vite": "^8.2.9",
|
53
57
|
"@topcli/prompts": "^1.8.0",
|
54
58
|
"@types/jest-image-snapshot": "^6",
|
59
|
+
"@types/node": "^22.4.1",
|
55
60
|
"concurrently": "^8.2.2",
|
56
61
|
"dotenv": "^16.3.1",
|
57
62
|
"eslint": "^8.56.0",
|
@@ -67,7 +72,7 @@
|
|
67
72
|
"prettier": "^3.1.1",
|
68
73
|
"release-it": "^17.1.1",
|
69
74
|
"rollup-plugin-postcss-lit": "^2.1.0",
|
70
|
-
"storybook": "^8.
|
75
|
+
"storybook": "^8.2.9",
|
71
76
|
"tsx": "^4.7.1",
|
72
77
|
"typescript": "^5.3.3",
|
73
78
|
"vite": "^5.2.7",
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import {SVGTemplateResult, svg} from 'lit';
|
2
|
+
|
3
|
+
export enum ArrowStyle {
|
4
|
+
HDG = 'HDG',
|
5
|
+
COG = 'COG',
|
6
|
+
}
|
7
|
+
|
8
|
+
export function arrow(
|
9
|
+
style: ArrowStyle,
|
10
|
+
angle: number
|
11
|
+
): SVGTemplateResult | SVGTemplateResult[] {
|
12
|
+
const colorName = 'var(--instrument-enhanced-secondary-color)';
|
13
|
+
|
14
|
+
if (style === ArrowStyle.HDG) {
|
15
|
+
return svg`
|
16
|
+
<g transform="translate(-32, -${256}) rotate(${angle}, 32, 256)">
|
17
|
+
<rect x="28" y="118" width="8" height="139" rx="4" fill="${colorName}" />
|
18
|
+
<rect x="30.0039" y="256" width="4" height="156" rx="2" fill="${colorName}" />
|
19
|
+
<circle cx="32" cy="256" r="8" fill="${colorName}" />
|
20
|
+
<mask
|
21
|
+
id="mask0_262_65165"
|
22
|
+
style="mask-type:luminance"
|
23
|
+
maskUnits="userSpaceOnUse"
|
24
|
+
x="8"
|
25
|
+
y="94"
|
26
|
+
width="48"
|
27
|
+
height="50"
|
28
|
+
>
|
29
|
+
<path
|
30
|
+
d="M13.2833 140.564L32 96L50.7167 140.564C51.4569 142.326 49.54 144.023 47.8805 143.075L32 136L16.1195 143.075C14.46 144.023 12.5432 142.326 13.2833 140.564Z"
|
31
|
+
fill="white"
|
32
|
+
stroke="black"
|
33
|
+
/>
|
34
|
+
</mask>
|
35
|
+
<g mask="url(#mask0_262_65165)">
|
36
|
+
<path
|
37
|
+
d="M13.2833 140.564L32 96L50.7167 140.564C51.4569 142.326 49.54 144.023 47.8805 143.075L32 136L16.1195 143.075C14.46 144.023 12.5432 142.326 13.2833 140.564Z"
|
38
|
+
fill="${colorName}"
|
39
|
+
/>
|
40
|
+
</g>
|
41
|
+
</g>
|
42
|
+
`;
|
43
|
+
} else if (style === ArrowStyle.COG) {
|
44
|
+
return svg`
|
45
|
+
<g transform="translate(-32, -${256}) rotate(${angle}, 32, 256)">
|
46
|
+
<path
|
47
|
+
fill-rule="evenodd"
|
48
|
+
clip-rule="evenodd"
|
49
|
+
d="M13.2833 140.564C12.5431 142.326 14.46 144.023 16.1195 143.075L32 136L47.8805 143.075C49.54 144.023 51.4568 142.326 50.7167 140.564L32 96L13.2833 140.564ZM32 106.33L19.2545 136.676L32 131.393L44.7455 136.676L32 106.33ZM49.865 139.602L49.8625 139.6L49.865 139.602Z"
|
50
|
+
fill="${colorName}"
|
51
|
+
/>
|
52
|
+
<rect x="30" y="133" width="4" height="124" rx="2" fill="${colorName}" />
|
53
|
+
<circle cx="32" cy="256" r="4" fill="${colorName}" />
|
54
|
+
</g>
|
55
|
+
`;
|
56
|
+
} else {
|
57
|
+
return [];
|
58
|
+
}
|
59
|
+
|
60
|
+
// return [...shaft, circle, arrowTip];
|
61
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import type {Meta, StoryObj} from '@storybook/web-components';
|
2
|
+
import {ObcCompass} from './compass';
|
3
|
+
import './compass';
|
4
|
+
import {beta6Decorator, widthDecorator} from '../../storybook-util';
|
5
|
+
import {AdviceType} from '../watch/advice';
|
6
|
+
|
7
|
+
const meta: Meta<typeof ObcCompass> = {
|
8
|
+
title: 'Navigation Instruments/Compass',
|
9
|
+
tags: ['autodocs'],
|
10
|
+
component: 'obc-compass',
|
11
|
+
args: {
|
12
|
+
width: 512,
|
13
|
+
heading: 311,
|
14
|
+
courseOverGround: 338,
|
15
|
+
headingAdvices: [
|
16
|
+
{
|
17
|
+
minAngle: 20,
|
18
|
+
maxAngle: 50,
|
19
|
+
type: AdviceType.advice,
|
20
|
+
hinted: false,
|
21
|
+
},
|
22
|
+
],
|
23
|
+
},
|
24
|
+
argTypes: {
|
25
|
+
width: {control: {type: 'range', min: 32, max: 1028, step: 1}},
|
26
|
+
heading: {control: {type: 'range', min: 0, max: 360, step: 1}},
|
27
|
+
courseOverGround: {control: {type: 'range', min: 0, max: 360, step: 1}},
|
28
|
+
},
|
29
|
+
decorators: [widthDecorator, beta6Decorator],
|
30
|
+
} satisfies Meta<ObcCompass>;
|
31
|
+
|
32
|
+
export default meta;
|
33
|
+
type Story = StoryObj<ObcCompass>;
|
34
|
+
|
35
|
+
export const Primary: Story = {
|
36
|
+
args: {},
|
37
|
+
};
|
@@ -0,0 +1,132 @@
|
|
1
|
+
import {LitElement, css, html} from 'lit';
|
2
|
+
import {customElement, property} from 'lit/decorators.js';
|
3
|
+
import '../watch/watch';
|
4
|
+
import {Tickmark, TickmarkType} from '../watch/tickmark';
|
5
|
+
import {arrow, ArrowStyle} from './arrow';
|
6
|
+
import {
|
7
|
+
AdviceState,
|
8
|
+
AdviceType,
|
9
|
+
AngleAdvice,
|
10
|
+
AngleAdviceRaw,
|
11
|
+
} from '../watch/advice';
|
12
|
+
import {radialTickmarks} from './radial-tickmark';
|
13
|
+
|
14
|
+
@customElement('obc-compass')
|
15
|
+
export class ObcCompass extends LitElement {
|
16
|
+
@property({type: Number}) heading = 0;
|
17
|
+
@property({type: Number}) courseOverGround = 0;
|
18
|
+
@property({type: Number}) padding = 48;
|
19
|
+
@property({type: Array, attribute: false}) headingAdvices: AngleAdvice[] = [];
|
20
|
+
@property({type: Number}) containerWidth = 0;
|
21
|
+
|
22
|
+
private resizeObserver: ResizeObserver = new ResizeObserver((entries) => {
|
23
|
+
for (const entry of entries) {
|
24
|
+
this.containerWidth = entry.contentRect.width;
|
25
|
+
this.adjustPadding();
|
26
|
+
}
|
27
|
+
});
|
28
|
+
|
29
|
+
override connectedCallback() {
|
30
|
+
super.connectedCallback();
|
31
|
+
this.resizeObserver.observe(this);
|
32
|
+
}
|
33
|
+
|
34
|
+
override disconnectedCallback() {
|
35
|
+
super.disconnectedCallback();
|
36
|
+
this.resizeObserver.unobserve(this);
|
37
|
+
}
|
38
|
+
|
39
|
+
private adjustPadding() {
|
40
|
+
const deltaWidth = 512 - this.containerWidth;
|
41
|
+
const steps = deltaWidth / 128;
|
42
|
+
let deltaPadding = 0;
|
43
|
+
if (deltaWidth > 0) {
|
44
|
+
deltaPadding = steps * 48;
|
45
|
+
} else {
|
46
|
+
deltaPadding = steps * 6;
|
47
|
+
}
|
48
|
+
|
49
|
+
this.padding = 72 + deltaPadding;
|
50
|
+
}
|
51
|
+
|
52
|
+
private get angleAdviceRaw(): AngleAdviceRaw[] {
|
53
|
+
return this.headingAdvices.map(({minAngle, maxAngle, hinted, type}) => {
|
54
|
+
const state =
|
55
|
+
this.heading >= minAngle && this.heading <= maxAngle
|
56
|
+
? AdviceState.triggered
|
57
|
+
: hinted
|
58
|
+
? AdviceState.hinted
|
59
|
+
: AdviceState.regular;
|
60
|
+
return {minAngle, maxAngle, type, state};
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
64
|
+
override render() {
|
65
|
+
const tickmarks: Tickmark[] = [
|
66
|
+
{angle: 0, type: TickmarkType.main},
|
67
|
+
{angle: 90, type: TickmarkType.main},
|
68
|
+
{angle: 180, type: TickmarkType.main},
|
69
|
+
{angle: 270, type: TickmarkType.main},
|
70
|
+
];
|
71
|
+
|
72
|
+
const rt = this.headingAdvices.map(({minAngle, maxAngle, type}) =>
|
73
|
+
radialTickmarks(
|
74
|
+
minAngle,
|
75
|
+
maxAngle,
|
76
|
+
type === AdviceType.caution ? TickmarkType.secondary : undefined
|
77
|
+
)
|
78
|
+
);
|
79
|
+
|
80
|
+
const width = (176 + this.padding) * 2;
|
81
|
+
const viewBox = `-${width / 2} -${width / 2} ${width} ${width}`;
|
82
|
+
|
83
|
+
return html`
|
84
|
+
<div class="container">
|
85
|
+
<obc-watch
|
86
|
+
.padding=${this.padding}
|
87
|
+
.advices=${this.angleAdviceRaw}
|
88
|
+
.tickmarks=${tickmarks}
|
89
|
+
.labelFrameEnabled=${true}
|
90
|
+
.crosshairEnabled=${true}
|
91
|
+
>
|
92
|
+
</obc-watch>
|
93
|
+
<svg viewBox="${viewBox}">
|
94
|
+
${rt} ${arrow(ArrowStyle.HDG, this.heading)}
|
95
|
+
${arrow(ArrowStyle.COG, this.courseOverGround)}
|
96
|
+
</svg>
|
97
|
+
</div>
|
98
|
+
`;
|
99
|
+
}
|
100
|
+
|
101
|
+
static override styles = css`
|
102
|
+
* {
|
103
|
+
box-sizing: border-box;
|
104
|
+
}
|
105
|
+
|
106
|
+
.container {
|
107
|
+
position: relative;
|
108
|
+
width: 100%;
|
109
|
+
height: 100%;
|
110
|
+
}
|
111
|
+
|
112
|
+
.container > * {
|
113
|
+
position: absolute;
|
114
|
+
top: 0;
|
115
|
+
left: 0;
|
116
|
+
width: 100%;
|
117
|
+
height: 100%;
|
118
|
+
}
|
119
|
+
|
120
|
+
:host {
|
121
|
+
display: block;
|
122
|
+
width: 100%;
|
123
|
+
height: 100%;
|
124
|
+
}
|
125
|
+
`;
|
126
|
+
}
|
127
|
+
|
128
|
+
declare global {
|
129
|
+
interface HTMLElementTagNameMap {
|
130
|
+
'obc-compass': ObcCompass;
|
131
|
+
}
|
132
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import {SVGTemplateResult, svg} from 'lit';
|
2
|
+
import {TickmarkType, TickmarkStyle, tickmarkColor} from '../watch/tickmark';
|
3
|
+
|
4
|
+
export function radialTickmarks(
|
5
|
+
minAngle: number,
|
6
|
+
maxAngle: number,
|
7
|
+
type: TickmarkType | undefined
|
8
|
+
): SVGTemplateResult[] {
|
9
|
+
if (type === TickmarkType.main || type === TickmarkType.tertiary) {
|
10
|
+
throw new Error(
|
11
|
+
'Only secondary tickmarks or undefined tickmarks (dots) are supported'
|
12
|
+
);
|
13
|
+
}
|
14
|
+
|
15
|
+
const origin = {x: 0, y: 0};
|
16
|
+
const radius = 320 / 2;
|
17
|
+
const strokeWidth = '1.2';
|
18
|
+
const margin = 1.5;
|
19
|
+
const colorName = tickmarkColor(TickmarkStyle.hinted);
|
20
|
+
const tickWidth = type === TickmarkType.secondary ? 4 : 1;
|
21
|
+
const tickmarks: SVGTemplateResult[] = [];
|
22
|
+
|
23
|
+
const sinMin = Math.sin((minAngle * Math.PI) / 180);
|
24
|
+
const cosMin = Math.cos((minAngle * Math.PI) / 180);
|
25
|
+
const sinMax = Math.sin((maxAngle * Math.PI) / 180);
|
26
|
+
const cosMax = Math.cos((maxAngle * Math.PI) / 180);
|
27
|
+
|
28
|
+
const deltaIncrement = tickWidth * margin;
|
29
|
+
|
30
|
+
for (let deltaR = 0; deltaR <= radius; deltaR += deltaIncrement) {
|
31
|
+
const xMin = origin.x + sinMin * deltaR;
|
32
|
+
const yMin = origin.y - cosMin * deltaR;
|
33
|
+
const xMax = origin.x + sinMax * deltaR;
|
34
|
+
const yMax = origin.y - cosMax * deltaR;
|
35
|
+
|
36
|
+
if (type === undefined) {
|
37
|
+
const size = 1;
|
38
|
+
tickmarks.push(
|
39
|
+
svg`<rect
|
40
|
+
x=${xMin - size / 2}
|
41
|
+
y=${yMin - size / 2}
|
42
|
+
width=${size}
|
43
|
+
height=${size}
|
44
|
+
fill=${colorName}
|
45
|
+
transform="rotate(${minAngle} ${xMin} ${yMin})"
|
46
|
+
vector-effect="non-scaling-stroke"/>`
|
47
|
+
);
|
48
|
+
tickmarks.push(
|
49
|
+
svg`<rect
|
50
|
+
x=${xMax - size / 2}
|
51
|
+
y=${yMax - size / 2}
|
52
|
+
width=${size}
|
53
|
+
height=${size}
|
54
|
+
fill=${colorName}
|
55
|
+
transform="rotate(${maxAngle} ${xMax} ${yMax})"
|
56
|
+
vector-effect="non-scaling-stroke"/>`
|
57
|
+
);
|
58
|
+
} else {
|
59
|
+
const currentRadius = Math.min(deltaR + tickWidth, radius);
|
60
|
+
const x2Min = origin.x + sinMin * currentRadius;
|
61
|
+
const y2Min = origin.y - cosMin * currentRadius;
|
62
|
+
const x2Max = origin.x + sinMax * currentRadius;
|
63
|
+
const y2Max = origin.y - cosMax * currentRadius;
|
64
|
+
|
65
|
+
tickmarks.push(
|
66
|
+
svg`<line x1=${xMin} y1=${yMin} x2=${x2Min} y2=${y2Min} stroke=${colorName} stroke-width=${strokeWidth} vector-effect="non-scaling-stroke"/>`
|
67
|
+
);
|
68
|
+
tickmarks.push(
|
69
|
+
svg`<line x1=${xMax} y1=${yMax} x2=${x2Max} y2=${y2Max} stroke=${colorName} stroke-width=${strokeWidth} vector-effect="non-scaling-stroke"/>`
|
70
|
+
);
|
71
|
+
|
72
|
+
if (currentRadius >= radius) break;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
return tickmarks;
|
77
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
* {
|
2
|
+
box-sizing: border-box;
|
3
|
+
}
|
4
|
+
|
5
|
+
.container {
|
6
|
+
position: relative;
|
7
|
+
width: 100%;
|
8
|
+
height: 100%;
|
9
|
+
}
|
10
|
+
|
11
|
+
.container > * {
|
12
|
+
position: absolute;
|
13
|
+
top: 0;
|
14
|
+
left: 0;
|
15
|
+
width: 100%;
|
16
|
+
height: 100%;
|
17
|
+
}
|
18
|
+
|
19
|
+
:host {
|
20
|
+
display: block;
|
21
|
+
width: 100%;
|
22
|
+
height: 100%;
|
23
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import type {Meta, StoryObj} from '@storybook/web-components';
|
2
|
+
import {ObcCompassFlat} from './compass-flat';
|
3
|
+
import './compass-flat';
|
4
|
+
import {beta6Decorator, widthDecorator} from '../../storybook-util';
|
5
|
+
import {LabelPosition} from './compass-flat';
|
6
|
+
|
7
|
+
const meta: Meta<typeof ObcCompassFlat> = {
|
8
|
+
title: 'Navigation Instruments/Compass flat',
|
9
|
+
tags: ['autodocs'],
|
10
|
+
component: 'obc-compass-flat',
|
11
|
+
args: {
|
12
|
+
width: 512,
|
13
|
+
heading: 45,
|
14
|
+
courseOverGround: 50,
|
15
|
+
FOVIndicator: false,
|
16
|
+
minFOV: 90,
|
17
|
+
},
|
18
|
+
argTypes: {
|
19
|
+
width: {control: {type: 'range', min: 32, max: 1028, step: 1}},
|
20
|
+
heading: {control: {type: 'range', min: 0, max: 360, step: 1}},
|
21
|
+
courseOverGround: {control: {type: 'range', min: 0, max: 360, step: 1}},
|
22
|
+
},
|
23
|
+
decorators: [widthDecorator, beta6Decorator],
|
24
|
+
} satisfies Meta<ObcCompassFlat>;
|
25
|
+
|
26
|
+
export default meta;
|
27
|
+
type Story = StoryObj<ObcCompassFlat>;
|
28
|
+
|
29
|
+
export const Primary: Story = {};
|
30
|
+
|
31
|
+
export const WithFOVIndicator: Story = {
|
32
|
+
args: {
|
33
|
+
FOVIndicator: true,
|
34
|
+
},
|
35
|
+
};
|