@oicl/openbridge-webcomponents 0.0.15-dev-20240923190011 → 0.0.15-dev-20240923191659

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. package/.storybook/main.ts +58 -58
  2. package/.storybook/preview.ts +55 -55
  3. package/custom-elements.json +3 -3
  4. package/dist/navigation-instruments/compass/arrow.js.map +1 -1
  5. package/dist/navigation-instruments/compass/compass.js.map +1 -1
  6. package/dist/navigation-instruments/compass/radial-tickmark.js.map +1 -1
  7. package/dist/navigation-instruments/compass-flat/compass-flat.js.map +1 -1
  8. package/dist/navigation-instruments/thruster/advice.js.map +1 -1
  9. package/dist/navigation-instruments/watch/advice.js.map +1 -1
  10. package/dist/navigation-instruments/watch/label.js.map +1 -1
  11. package/dist/navigation-instruments/watch/watch.js.map +1 -1
  12. package/dist/navigation-instruments/watch-flat/tickmark-flat.js.map +1 -1
  13. package/dist/navigation-instruments/watch-flat/watch-flat.js.map +1 -1
  14. package/dist/svghelpers/rectangular.js.map +1 -1
  15. package/oicl-openbridge-webcomponents-0.0.15-dev-20240923191659.tgz +0 -0
  16. package/package.json +83 -83
  17. package/src/navigation-instruments/compass/arrow.ts +61 -61
  18. package/src/navigation-instruments/compass/compass.stories.ts +37 -37
  19. package/src/navigation-instruments/compass/compass.ts +132 -132
  20. package/src/navigation-instruments/compass/radial-tickmark.ts +77 -77
  21. package/src/navigation-instruments/compass-flat/compass-flat.css +23 -23
  22. package/src/navigation-instruments/compass-flat/compass-flat.stories.ts +35 -35
  23. package/src/navigation-instruments/compass-flat/compass-flat.ts +221 -221
  24. package/src/navigation-instruments/thruster/advice.ts +109 -109
  25. package/src/navigation-instruments/watch/advice.ts +120 -120
  26. package/src/navigation-instruments/watch/label.ts +69 -69
  27. package/src/navigation-instruments/watch/watch.css +11 -11
  28. package/src/navigation-instruments/watch/watch.ts +199 -199
  29. package/src/navigation-instruments/watch-flat/tickmark-flat.ts +62 -62
  30. package/src/navigation-instruments/watch-flat/watch-flat.css +19 -19
  31. package/src/navigation-instruments/watch-flat/watch-flat.stories.ts +17 -17
  32. package/src/navigation-instruments/watch-flat/watch-flat.ts +148 -148
  33. package/src/svghelpers/rectangular.ts +42 -42
@@ -1,120 +1,120 @@
1
- import {SVGTemplateResult, nothing, svg} from 'lit';
2
- import {TickmarkStyle, TickmarkType, tickmark} from './tickmark';
3
-
4
- export enum AdviceType {
5
- advice = 'advice',
6
- caution = 'caution',
7
- }
8
-
9
- export enum AdviceState {
10
- regular = 'regular',
11
- hinted = 'hinted',
12
- triggered = 'triggered',
13
- }
14
-
15
- export interface AngleAdviceRaw {
16
- minAngle: number;
17
- maxAngle: number;
18
- type: AdviceType;
19
- state: AdviceState;
20
- }
21
-
22
- export interface AngleAdvice {
23
- minAngle: number;
24
- maxAngle: number;
25
- type: AdviceType;
26
- hinted: boolean;
27
- }
28
-
29
- const margin = (344 - 328) / 2 + 8;
30
- const deltaAngle = Math.atan2(margin, (344 + 328) / 2);
31
-
32
- function adviceMask(
33
- minAngle: number,
34
- maxAngle: number,
35
- fill: string,
36
- stroke: string
37
- ): SVGTemplateResult {
38
- const radl = (minAngle * Math.PI) / 180 + deltaAngle;
39
- const radh = (maxAngle * Math.PI) / 180 - deltaAngle;
40
- const r1 = 328 / 2;
41
- const r2 = 344 / 2;
42
- const R = (r2 - r1) / 2;
43
- const x1l = Math.sin(radl) * r1;
44
- const y1l = -Math.cos(radl) * r1;
45
- const x2l = Math.sin(radl) * r2;
46
- const y2l = -Math.cos(radl) * r2;
47
-
48
- const x1h = Math.sin(radh) * r1;
49
- const y1h = -Math.cos(radh) * r1;
50
- const x2h = Math.sin(radh) * r2;
51
- const y2h = -Math.cos(radh) * r2;
52
-
53
- const path = `M ${x1l} ${y1l}
54
- A ${r1} ${r1} 0 0 1 ${x1h} ${y1h}
55
- A ${R} ${R} 0 0 0 ${x2h} ${y2h}
56
- A ${r2} ${r2} 0 0 0 ${x2l} ${y2l}
57
- A ${R} ${R} 0 0 0 ${x1l} ${y1l}
58
- Z`;
59
- return svg`<path d=${path} fill=${fill} stroke=${stroke} stroke-width="1" vector-effect="non-scaling-stroke" />`;
60
- }
61
-
62
- export function renderAdvice(advice: AngleAdviceRaw): SVGTemplateResult {
63
- if (advice.type === AdviceType.caution) {
64
- let mainColor;
65
- let fillColor: string | null = null;
66
- if (advice.state === AdviceState.hinted) {
67
- mainColor = 'var(--instrument-frame-tertiary-color)';
68
- } else if (advice.state === AdviceState.regular) {
69
- mainColor = 'var(--instrument-tick-mark-tertiary-color)';
70
- } else {
71
- mainColor = 'var(--on-caution-active-color)';
72
- fillColor = 'var(--alert-caution-color)';
73
- }
74
- const radialPattern = [];
75
- for (let i = 0; i < 180; i += 4) {
76
- radialPattern.push(svg`<g transform="rotate(${i}) translate(-256 -256) ">
77
- <path d="M369.167 64.7317L144 194.732L142 191.268L367.167 61.2676L369.167 64.7317ZM369.167 320.732L144 450.732L142 447.267L367.167 317.267L369.167 320.732Z" fill=${mainColor}/>
78
- </g>
79
- `);
80
- }
81
- const maskId = `adviceMask-${advice.minAngle}-${advice.maxAngle}`;
82
- let tickmarkStyle = TickmarkStyle.hinted;
83
- if (advice.state === AdviceState.regular) {
84
- tickmarkStyle = TickmarkStyle.regular;
85
- } else if (advice.state === AdviceState.triggered) {
86
- tickmarkStyle = TickmarkStyle.enhanced;
87
- }
88
-
89
- return svg`
90
- <mask id=${maskId}>
91
- ${adviceMask(advice.minAngle, advice.maxAngle, 'white', 'black')}
92
- </mask>
93
- <g mask="url(#${maskId})">
94
- ${fillColor ? svg`<rect x="-256" y="-256" width="512" height="512" fill="${fillColor}"/>` : nothing}
95
- ${radialPattern}
96
- </g>
97
- ${adviceMask(advice.minAngle, advice.maxAngle, 'none', mainColor)}
98
- ${tickmark(advice.minAngle, TickmarkType.primary, tickmarkStyle, 1)}
99
- ${tickmark(advice.maxAngle, TickmarkType.primary, tickmarkStyle, 1)}
100
- `;
101
- } else {
102
- let mainColor;
103
- let tickmarkStyle;
104
- if (advice.state === AdviceState.hinted) {
105
- mainColor = 'var(--instrument-frame-tertiary-color)';
106
- tickmarkStyle = TickmarkStyle.hinted;
107
- } else if (advice.state === AdviceState.regular) {
108
- mainColor = 'var(--instrument-regular-secondary-color)';
109
- tickmarkStyle = TickmarkStyle.regular;
110
- } else {
111
- mainColor = 'var(--instrument-enhanced-secondary-color)';
112
- tickmarkStyle = TickmarkStyle.regular;
113
- }
114
- return svg`
115
- ${adviceMask(advice.minAngle, advice.maxAngle, advice.state === AdviceState.triggered ? mainColor : 'none', mainColor)}
116
- ${tickmark(advice.minAngle, TickmarkType.primary, tickmarkStyle, 1)}
117
- ${tickmark(advice.maxAngle, TickmarkType.primary, tickmarkStyle, 1)}
118
- `;
119
- }
120
- }
1
+ import {SVGTemplateResult, nothing, svg} from 'lit';
2
+ import {TickmarkStyle, TickmarkType, tickmark} from './tickmark';
3
+
4
+ export enum AdviceType {
5
+ advice = 'advice',
6
+ caution = 'caution',
7
+ }
8
+
9
+ export enum AdviceState {
10
+ regular = 'regular',
11
+ hinted = 'hinted',
12
+ triggered = 'triggered',
13
+ }
14
+
15
+ export interface AngleAdviceRaw {
16
+ minAngle: number;
17
+ maxAngle: number;
18
+ type: AdviceType;
19
+ state: AdviceState;
20
+ }
21
+
22
+ export interface AngleAdvice {
23
+ minAngle: number;
24
+ maxAngle: number;
25
+ type: AdviceType;
26
+ hinted: boolean;
27
+ }
28
+
29
+ const margin = (344 - 328) / 2 + 8;
30
+ const deltaAngle = Math.atan2(margin, (344 + 328) / 2);
31
+
32
+ function adviceMask(
33
+ minAngle: number,
34
+ maxAngle: number,
35
+ fill: string,
36
+ stroke: string
37
+ ): SVGTemplateResult {
38
+ const radl = (minAngle * Math.PI) / 180 + deltaAngle;
39
+ const radh = (maxAngle * Math.PI) / 180 - deltaAngle;
40
+ const r1 = 328 / 2;
41
+ const r2 = 344 / 2;
42
+ const R = (r2 - r1) / 2;
43
+ const x1l = Math.sin(radl) * r1;
44
+ const y1l = -Math.cos(radl) * r1;
45
+ const x2l = Math.sin(radl) * r2;
46
+ const y2l = -Math.cos(radl) * r2;
47
+
48
+ const x1h = Math.sin(radh) * r1;
49
+ const y1h = -Math.cos(radh) * r1;
50
+ const x2h = Math.sin(radh) * r2;
51
+ const y2h = -Math.cos(radh) * r2;
52
+
53
+ const path = `M ${x1l} ${y1l}
54
+ A ${r1} ${r1} 0 0 1 ${x1h} ${y1h}
55
+ A ${R} ${R} 0 0 0 ${x2h} ${y2h}
56
+ A ${r2} ${r2} 0 0 0 ${x2l} ${y2l}
57
+ A ${R} ${R} 0 0 0 ${x1l} ${y1l}
58
+ Z`;
59
+ return svg`<path d=${path} fill=${fill} stroke=${stroke} stroke-width="1" vector-effect="non-scaling-stroke" />`;
60
+ }
61
+
62
+ export function renderAdvice(advice: AngleAdviceRaw): SVGTemplateResult {
63
+ if (advice.type === AdviceType.caution) {
64
+ let mainColor;
65
+ let fillColor: string | null = null;
66
+ if (advice.state === AdviceState.hinted) {
67
+ mainColor = 'var(--instrument-frame-tertiary-color)';
68
+ } else if (advice.state === AdviceState.regular) {
69
+ mainColor = 'var(--instrument-tick-mark-tertiary-color)';
70
+ } else {
71
+ mainColor = 'var(--on-caution-active-color)';
72
+ fillColor = 'var(--alert-caution-color)';
73
+ }
74
+ const radialPattern = [];
75
+ for (let i = 0; i < 180; i += 4) {
76
+ radialPattern.push(svg`<g transform="rotate(${i}) translate(-256 -256) ">
77
+ <path d="M369.167 64.7317L144 194.732L142 191.268L367.167 61.2676L369.167 64.7317ZM369.167 320.732L144 450.732L142 447.267L367.167 317.267L369.167 320.732Z" fill=${mainColor}/>
78
+ </g>
79
+ `);
80
+ }
81
+ const maskId = `adviceMask-${advice.minAngle}-${advice.maxAngle}`;
82
+ let tickmarkStyle = TickmarkStyle.hinted;
83
+ if (advice.state === AdviceState.regular) {
84
+ tickmarkStyle = TickmarkStyle.regular;
85
+ } else if (advice.state === AdviceState.triggered) {
86
+ tickmarkStyle = TickmarkStyle.enhanced;
87
+ }
88
+
89
+ return svg`
90
+ <mask id=${maskId}>
91
+ ${adviceMask(advice.minAngle, advice.maxAngle, 'white', 'black')}
92
+ </mask>
93
+ <g mask="url(#${maskId})">
94
+ ${fillColor ? svg`<rect x="-256" y="-256" width="512" height="512" fill="${fillColor}"/>` : nothing}
95
+ ${radialPattern}
96
+ </g>
97
+ ${adviceMask(advice.minAngle, advice.maxAngle, 'none', mainColor)}
98
+ ${tickmark(advice.minAngle, TickmarkType.primary, tickmarkStyle, 1)}
99
+ ${tickmark(advice.maxAngle, TickmarkType.primary, tickmarkStyle, 1)}
100
+ `;
101
+ } else {
102
+ let mainColor;
103
+ let tickmarkStyle;
104
+ if (advice.state === AdviceState.hinted) {
105
+ mainColor = 'var(--instrument-frame-tertiary-color)';
106
+ tickmarkStyle = TickmarkStyle.hinted;
107
+ } else if (advice.state === AdviceState.regular) {
108
+ mainColor = 'var(--instrument-regular-secondary-color)';
109
+ tickmarkStyle = TickmarkStyle.regular;
110
+ } else {
111
+ mainColor = 'var(--instrument-enhanced-secondary-color)';
112
+ tickmarkStyle = TickmarkStyle.regular;
113
+ }
114
+ return svg`
115
+ ${adviceMask(advice.minAngle, advice.maxAngle, advice.state === AdviceState.triggered ? mainColor : 'none', mainColor)}
116
+ ${tickmark(advice.minAngle, TickmarkType.primary, tickmarkStyle, 1)}
117
+ ${tickmark(advice.maxAngle, TickmarkType.primary, tickmarkStyle, 1)}
118
+ `;
119
+ }
120
+ }
@@ -1,69 +1,69 @@
1
- import {svg, SVGTemplateResult} from 'lit-html';
2
-
3
- export function renderLabels(scale: number): SVGTemplateResult {
4
- const labelWidth = 32;
5
- const gap = 8;
6
- const radius: number = 368 / 2;
7
- const labels = [
8
- {
9
- label: 'E',
10
- x: radius + gap / scale + labelWidth / 2,
11
- y: 0,
12
- class: 'label',
13
- },
14
- {
15
- label: 'S',
16
- x: 0,
17
- y: radius + gap / scale + labelWidth / 2,
18
- class: 'label',
19
- },
20
- {
21
- label: 'W',
22
- x: -(radius + gap / scale + labelWidth / 2),
23
- y: 0,
24
- class: 'label',
25
- },
26
- ];
27
-
28
- let arrow = svg`<defs>
29
- <mask id="circleMask">
30
- <rect x="-${radius}" y="-${radius}" width="${radius * 2}" height="${radius * 2}" fill="black"/>
31
- <circle cx="0" cy="0" r="${radius}" fill="white"/>
32
- </mask>
33
- </defs>
34
- <g mask="url(#circleMask)" transform="translate(0, ${-(radius + 45 / scale)}) scale(${1 / scale}, ${1 / scale})">
35
- <path fill-rule="evenodd" clip-rule="evenodd" d="M-32.04 42.7192 0 0 32.039 42.7192C21.627 40.9314 10.922 40 0 40-10.922 40-21.627 40.9314-32.04 42.7192Z"
36
- fill="var(--instrument-tick-mark-secondary-color)"/>
37
- <path d="M5.003 29H2.091L-3.013 20.264H-3.077C-3.066 20.52-3.056 20.7813-3.045 21.048-3.034 21.3147-3.024 21.5867-3.013 21.864-2.992 22.1307-2.976 22.4027-2.965 22.68-2.954 22.9573-2.944 23.2347-2.933 23.512V29H-4.997V17.576H-2.101L2.987 26.232H3.035C3.024 25.9867 3.014 25.736 3.003 25.48 2.992 25.2133 2.982 24.952 2.971 24.696 2.971 24.4293 2.966 24.1627 2.955 23.896 2.944 23.6293 2.934 23.3627 2.923 23.096V17.576H5.003V29Z" fill="var(--element-active-inverted-color)"/>
38
- </g>`;
39
-
40
- if (scale < 0.58) {
41
- arrow = svg`
42
- <g mask="url(#circleMask)" transform="translate(0, ${-radius})">
43
- <path fill-rule="evenodd" clip-rule="evenodd" d="M-17.8457 24.984 0 0 17.8458 24.984C11.9868 24.3338 6.0324 24 0 24-6.0323 24-11.9867 24.3338-17.8457 24.984Z" fill="var(--instrument-frame-tertiary-color)"/>
44
- </g>`;
45
-
46
- labels.push({
47
- label: 'N',
48
- x: 0,
49
- y: -(radius + gap / scale + labelWidth / 2),
50
- class: 'label',
51
- });
52
- }
53
-
54
- return svg`
55
- ${arrow}
56
-
57
- ${labels.map(
58
- (l) => svg`
59
- <text
60
- x="${l.x}"
61
- y="${l.y}"
62
- class="${l.class}"
63
- >
64
- ${l.label}
65
- </text>
66
- `
67
- )}
68
- `;
69
- }
1
+ import {svg, SVGTemplateResult} from 'lit-html';
2
+
3
+ export function renderLabels(scale: number): SVGTemplateResult {
4
+ const labelWidth = 32;
5
+ const gap = 8;
6
+ const radius: number = 368 / 2;
7
+ const labels = [
8
+ {
9
+ label: 'E',
10
+ x: radius + gap / scale + labelWidth / 2,
11
+ y: 0,
12
+ class: 'label',
13
+ },
14
+ {
15
+ label: 'S',
16
+ x: 0,
17
+ y: radius + gap / scale + labelWidth / 2,
18
+ class: 'label',
19
+ },
20
+ {
21
+ label: 'W',
22
+ x: -(radius + gap / scale + labelWidth / 2),
23
+ y: 0,
24
+ class: 'label',
25
+ },
26
+ ];
27
+
28
+ let arrow = svg`<defs>
29
+ <mask id="circleMask">
30
+ <rect x="-${radius}" y="-${radius}" width="${radius * 2}" height="${radius * 2}" fill="black"/>
31
+ <circle cx="0" cy="0" r="${radius}" fill="white"/>
32
+ </mask>
33
+ </defs>
34
+ <g mask="url(#circleMask)" transform="translate(0, ${-(radius + 45 / scale)}) scale(${1 / scale}, ${1 / scale})">
35
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M-32.04 42.7192 0 0 32.039 42.7192C21.627 40.9314 10.922 40 0 40-10.922 40-21.627 40.9314-32.04 42.7192Z"
36
+ fill="var(--instrument-tick-mark-secondary-color)"/>
37
+ <path d="M5.003 29H2.091L-3.013 20.264H-3.077C-3.066 20.52-3.056 20.7813-3.045 21.048-3.034 21.3147-3.024 21.5867-3.013 21.864-2.992 22.1307-2.976 22.4027-2.965 22.68-2.954 22.9573-2.944 23.2347-2.933 23.512V29H-4.997V17.576H-2.101L2.987 26.232H3.035C3.024 25.9867 3.014 25.736 3.003 25.48 2.992 25.2133 2.982 24.952 2.971 24.696 2.971 24.4293 2.966 24.1627 2.955 23.896 2.944 23.6293 2.934 23.3627 2.923 23.096V17.576H5.003V29Z" fill="var(--element-active-inverted-color)"/>
38
+ </g>`;
39
+
40
+ if (scale < 0.58) {
41
+ arrow = svg`
42
+ <g mask="url(#circleMask)" transform="translate(0, ${-radius})">
43
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M-17.8457 24.984 0 0 17.8458 24.984C11.9868 24.3338 6.0324 24 0 24-6.0323 24-11.9867 24.3338-17.8457 24.984Z" fill="var(--instrument-frame-tertiary-color)"/>
44
+ </g>`;
45
+
46
+ labels.push({
47
+ label: 'N',
48
+ x: 0,
49
+ y: -(radius + gap / scale + labelWidth / 2),
50
+ class: 'label',
51
+ });
52
+ }
53
+
54
+ return svg`
55
+ ${arrow}
56
+
57
+ ${labels.map(
58
+ (l) => svg`
59
+ <text
60
+ x="${l.x}"
61
+ y="${l.y}"
62
+ class="${l.class}"
63
+ >
64
+ ${l.label}
65
+ </text>
66
+ `
67
+ )}
68
+ `;
69
+ }
@@ -1,11 +1,11 @@
1
- * {
2
- box-sizing: border-box;
3
- }
4
-
5
- .label {
6
- @mixin font-body;
7
- font-size: calc(16px / var(--scale));
8
- fill: var(--element-neutral-color);
9
- alignment-baseline: middle;
10
- text-anchor: middle;
11
- }
1
+ * {
2
+ box-sizing: border-box;
3
+ }
4
+
5
+ .label {
6
+ @mixin font-body;
7
+ font-size: calc(16px / var(--scale));
8
+ fill: var(--element-neutral-color);
9
+ alignment-baseline: middle;
10
+ text-anchor: middle;
11
+ }