@oicl/openbridge-webcomponents 0.0.15-dev-20240923184809 → 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,148 +1,148 @@
1
- import {LitElement, SVGTemplateResult, html, svg, unsafeCSS} from 'lit';
2
- import {customElement, property} from 'lit/decorators.js';
3
- import compentStyle from './watch-flat.css?inline';
4
- import {Tickmark, TickmarkStyle, tickmark} from './tickmark-flat';
5
- import {rect} from '../../svghelpers/rectangular';
6
- import {Label} from '../compass-flat/compass-flat';
7
-
8
- @customElement('obc-watch-flat')
9
- export class ObcWatchFlat extends LitElement {
10
- @property({type: Number}) width = 352;
11
- @property({type: Number}) height = 72;
12
- @property({type: Number}) padding = 0;
13
- @property({type: Number}) rotation = 0;
14
- @property({type: Number}) tickmarkSpacing = 0;
15
- @property({type: Number}) angleSetpoint: number | undefined;
16
- @property({type: Array, attribute: false}) tickmarks: Tickmark[] = [];
17
- @property({type: Array, attribute: false}) labels: Label[] = [];
18
- @property({type: Array, attribute: false}) FOVIndicator: SVGTemplateResult[] =
19
- [];
20
- @property({type: Number}) trackHeight = (2 / 3) * this.height;
21
- @property({type: Number}) ticksHeight = this.height - this.trackHeight;
22
- @property({type: Number}) borderRadius = 8;
23
-
24
- private renderClipPath(offsetY: number = 0): SVGTemplateResult {
25
- return svg`
26
- <clipPath id="frameClipPath${offsetY === 0 ? '' : 'Tickmarks'}">
27
- <rect x="${-this.width / 2}" y="${-this.height / 2 + offsetY}"
28
- width="${this.width}" height="${this.height}"
29
- rx="${this.borderRadius}" />
30
- </clipPath>
31
- `;
32
- }
33
-
34
- private renderLabelMask(): SVGTemplateResult {
35
- return svg`
36
- <mask id="labelMask">
37
- <rect x="${-this.width / 2}" y="${-70}"
38
- width="${this.width}" height="${32}"
39
- />
40
- <linearGradient id="fadeGradient" gradientUnits="userSpaceOnUse"
41
- x1="${-this.width / 2}" y1="0" x2="${this.width / 2}" y2="0">
42
- <stop offset="0%" style="stop-color:black; stop-opacity:1;" />
43
- <stop offset="10%" style="stop-color:white; stop-opacity:1;" />
44
- <stop offset="50%" style="stop-color:white; stop-opacity:1;" />
45
- <stop offset="90%" style="stop-color:white; stop-opacity:1;" />
46
- <stop offset="100%" style="stop-color:black; stop-opacity:1;" />
47
- </linearGradient>
48
- <rect x="${-this.width / 2}" y="${-70}"
49
- width="${this.width}" height="${32}"
50
- fill="url(#fadeGradient)" />
51
- </mask>
52
- `;
53
- }
54
-
55
- private renderLabels(scale: number): SVGTemplateResult[] {
56
- const labels: SVGTemplateResult[] = [];
57
-
58
- for (const l of this.labels) {
59
- labels.push(
60
- svg`<g transform="translate(${-this.rotation * this.tickmarkSpacing}, ${-6 / scale})">
61
- <text x=${l.x} y=${l.y} class="label" fill=${'var(--instrument-tick-mark-secondary-color)'}>
62
- ${l.text}
63
- </text>
64
- </g>`
65
- );
66
- }
67
-
68
- return labels;
69
- }
70
-
71
- private watchFace(): SVGTemplateResult {
72
- const strokeWidth = 1;
73
-
74
- return svg`
75
- ${this.renderClipPath()}
76
- ${this.renderClipPath(-40)}
77
- <g clip-path="url(#frameClipPath)">
78
- ${rect('frame-track', {
79
- width: this.width,
80
- height: this.trackHeight,
81
- y: this.height / 2 - this.trackHeight,
82
- strokeWidth: strokeWidth,
83
- strokeColor: 'var(--instrument-frame-secondary-color)',
84
- strokePosition: 'inside',
85
- fillColor: 'var(--instrument-frame-secondary-color)',
86
- borderRadius: 0,
87
- })}
88
- ${rect('frame-ticks', {
89
- width: this.width,
90
- height: this.ticksHeight,
91
- y: this.height / 2 - this.trackHeight - this.ticksHeight,
92
- strokeWidth: strokeWidth,
93
- strokeColor: 'var(--instrument-frame-primary-color)',
94
- strokePosition: 'inside',
95
- fillColor: 'var(--instrument-frame-primary-color)',
96
- borderRadius: 0,
97
- })}
98
- </g>
99
- ${rect('frame-outline', {
100
- width: this.width,
101
- height: this.height,
102
- strokeWidth: strokeWidth,
103
- strokeColor: 'var(--instrument-frame-tertiary-color)',
104
- strokePosition: 'inside',
105
- fillColor: 'none',
106
- borderRadius: this.borderRadius,
107
- })}
108
- `;
109
- }
110
-
111
- override render() {
112
- const width = (this.width / 2 + this.padding) * 2;
113
- const viewBox = `-${width / 2} -${this.height / 2} ${width} ${this.height}`;
114
- const scale = this.clientWidth / width;
115
-
116
- return html`
117
- <svg
118
- width="100%"
119
- height="100%"
120
- viewBox=${viewBox}
121
- style="--scale: ${scale}"
122
- >
123
- ${this.watchFace()} ${this.renderLabelMask()} ${this.FOVIndicator}
124
-
125
- <g clip-path="url(#frameClipPath)">
126
- ${this.tickmarks.map(
127
- (t) => svg`
128
- <g transform="translate(${-this.rotation * this.tickmarkSpacing}, 0)">
129
- ${tickmark(t.angle, t.type, TickmarkStyle.hinted)}
130
- </g>
131
- `
132
- )}
133
- </g>
134
-
135
- <g mask="url(#labelMask)">
136
- ${this.renderLabels(scale)}
137
- </svg>
138
- `;
139
- }
140
-
141
- static override styles = unsafeCSS(compentStyle);
142
- }
143
-
144
- declare global {
145
- interface HTMLElementTagNameMap {
146
- 'obc-watch-flat': ObcWatchFlat;
147
- }
148
- }
1
+ import {LitElement, SVGTemplateResult, html, svg, unsafeCSS} from 'lit';
2
+ import {customElement, property} from 'lit/decorators.js';
3
+ import compentStyle from './watch-flat.css?inline';
4
+ import {Tickmark, TickmarkStyle, tickmark} from './tickmark-flat';
5
+ import {rect} from '../../svghelpers/rectangular';
6
+ import {Label} from '../compass-flat/compass-flat';
7
+
8
+ @customElement('obc-watch-flat')
9
+ export class ObcWatchFlat extends LitElement {
10
+ @property({type: Number}) width = 352;
11
+ @property({type: Number}) height = 72;
12
+ @property({type: Number}) padding = 0;
13
+ @property({type: Number}) rotation = 0;
14
+ @property({type: Number}) tickmarkSpacing = 0;
15
+ @property({type: Number}) angleSetpoint: number | undefined;
16
+ @property({type: Array, attribute: false}) tickmarks: Tickmark[] = [];
17
+ @property({type: Array, attribute: false}) labels: Label[] = [];
18
+ @property({type: Array, attribute: false}) FOVIndicator: SVGTemplateResult[] =
19
+ [];
20
+ @property({type: Number}) trackHeight = (2 / 3) * this.height;
21
+ @property({type: Number}) ticksHeight = this.height - this.trackHeight;
22
+ @property({type: Number}) borderRadius = 8;
23
+
24
+ private renderClipPath(offsetY: number = 0): SVGTemplateResult {
25
+ return svg`
26
+ <clipPath id="frameClipPath${offsetY === 0 ? '' : 'Tickmarks'}">
27
+ <rect x="${-this.width / 2}" y="${-this.height / 2 + offsetY}"
28
+ width="${this.width}" height="${this.height}"
29
+ rx="${this.borderRadius}" />
30
+ </clipPath>
31
+ `;
32
+ }
33
+
34
+ private renderLabelMask(): SVGTemplateResult {
35
+ return svg`
36
+ <mask id="labelMask">
37
+ <rect x="${-this.width / 2}" y="${-70}"
38
+ width="${this.width}" height="${32}"
39
+ />
40
+ <linearGradient id="fadeGradient" gradientUnits="userSpaceOnUse"
41
+ x1="${-this.width / 2}" y1="0" x2="${this.width / 2}" y2="0">
42
+ <stop offset="0%" style="stop-color:black; stop-opacity:1;" />
43
+ <stop offset="10%" style="stop-color:white; stop-opacity:1;" />
44
+ <stop offset="50%" style="stop-color:white; stop-opacity:1;" />
45
+ <stop offset="90%" style="stop-color:white; stop-opacity:1;" />
46
+ <stop offset="100%" style="stop-color:black; stop-opacity:1;" />
47
+ </linearGradient>
48
+ <rect x="${-this.width / 2}" y="${-70}"
49
+ width="${this.width}" height="${32}"
50
+ fill="url(#fadeGradient)" />
51
+ </mask>
52
+ `;
53
+ }
54
+
55
+ private renderLabels(scale: number): SVGTemplateResult[] {
56
+ const labels: SVGTemplateResult[] = [];
57
+
58
+ for (const l of this.labels) {
59
+ labels.push(
60
+ svg`<g transform="translate(${-this.rotation * this.tickmarkSpacing}, ${-6 / scale})">
61
+ <text x=${l.x} y=${l.y} class="label" fill=${'var(--instrument-tick-mark-secondary-color)'}>
62
+ ${l.text}
63
+ </text>
64
+ </g>`
65
+ );
66
+ }
67
+
68
+ return labels;
69
+ }
70
+
71
+ private watchFace(): SVGTemplateResult {
72
+ const strokeWidth = 1;
73
+
74
+ return svg`
75
+ ${this.renderClipPath()}
76
+ ${this.renderClipPath(-40)}
77
+ <g clip-path="url(#frameClipPath)">
78
+ ${rect('frame-track', {
79
+ width: this.width,
80
+ height: this.trackHeight,
81
+ y: this.height / 2 - this.trackHeight,
82
+ strokeWidth: strokeWidth,
83
+ strokeColor: 'var(--instrument-frame-secondary-color)',
84
+ strokePosition: 'inside',
85
+ fillColor: 'var(--instrument-frame-secondary-color)',
86
+ borderRadius: 0,
87
+ })}
88
+ ${rect('frame-ticks', {
89
+ width: this.width,
90
+ height: this.ticksHeight,
91
+ y: this.height / 2 - this.trackHeight - this.ticksHeight,
92
+ strokeWidth: strokeWidth,
93
+ strokeColor: 'var(--instrument-frame-primary-color)',
94
+ strokePosition: 'inside',
95
+ fillColor: 'var(--instrument-frame-primary-color)',
96
+ borderRadius: 0,
97
+ })}
98
+ </g>
99
+ ${rect('frame-outline', {
100
+ width: this.width,
101
+ height: this.height,
102
+ strokeWidth: strokeWidth,
103
+ strokeColor: 'var(--instrument-frame-tertiary-color)',
104
+ strokePosition: 'inside',
105
+ fillColor: 'none',
106
+ borderRadius: this.borderRadius,
107
+ })}
108
+ `;
109
+ }
110
+
111
+ override render() {
112
+ const width = (this.width / 2 + this.padding) * 2;
113
+ const viewBox = `-${width / 2} -${this.height / 2} ${width} ${this.height}`;
114
+ const scale = this.clientWidth / width;
115
+
116
+ return html`
117
+ <svg
118
+ width="100%"
119
+ height="100%"
120
+ viewBox=${viewBox}
121
+ style="--scale: ${scale}"
122
+ >
123
+ ${this.watchFace()} ${this.renderLabelMask()} ${this.FOVIndicator}
124
+
125
+ <g clip-path="url(#frameClipPath)">
126
+ ${this.tickmarks.map(
127
+ (t) => svg`
128
+ <g transform="translate(${-this.rotation * this.tickmarkSpacing}, 0)">
129
+ ${tickmark(t.angle, t.type, TickmarkStyle.hinted)}
130
+ </g>
131
+ `
132
+ )}
133
+ </g>
134
+
135
+ <g mask="url(#labelMask)">
136
+ ${this.renderLabels(scale)}
137
+ </svg>
138
+ `;
139
+ }
140
+
141
+ static override styles = unsafeCSS(compentStyle);
142
+ }
143
+
144
+ declare global {
145
+ interface HTMLElementTagNameMap {
146
+ 'obc-watch-flat': ObcWatchFlat;
147
+ }
148
+ }
@@ -1,42 +1,42 @@
1
- import {svg} from 'lit';
2
-
3
- export function rect(
4
- id: string,
5
- data: {
6
- width: number;
7
- height: number;
8
- strokeWidth: number;
9
- strokeColor: string;
10
- fillColor: string;
11
- borderRadius: number;
12
- strokePosition: 'inside' | 'outside';
13
- y?: number;
14
- }
15
- ) {
16
- const yPosition = data.y !== undefined ? data.y : -data.height / 2;
17
-
18
- if (data.strokePosition === 'inside') {
19
- return svg`
20
- <defs>
21
- <clipPath id="clip${id}">
22
- <rect id=${id} x=${-data.width / 2} y=${yPosition} width=${
23
- data.width
24
- } height=${data.height} rx=${
25
- data.borderRadius
26
- } vector-effect="non-scaling-stroke" />
27
- </clipPath>
28
- </defs>
29
- <rect id=${id} x=${-data.width / 2} y=${yPosition} width=${
30
- data.width
31
- } height=${data.height} rx=${
32
- data.borderRadius
33
- } vector-effect="non-scaling-stroke" stroke=${
34
- data.strokeColor
35
- } stroke-width=${data.strokeWidth * 2} fill=${
36
- data.fillColor
37
- } clip-path="url(#clip${id})"/>
38
- `;
39
- } else {
40
- return null;
41
- }
42
- }
1
+ import {svg} from 'lit';
2
+
3
+ export function rect(
4
+ id: string,
5
+ data: {
6
+ width: number;
7
+ height: number;
8
+ strokeWidth: number;
9
+ strokeColor: string;
10
+ fillColor: string;
11
+ borderRadius: number;
12
+ strokePosition: 'inside' | 'outside';
13
+ y?: number;
14
+ }
15
+ ) {
16
+ const yPosition = data.y !== undefined ? data.y : -data.height / 2;
17
+
18
+ if (data.strokePosition === 'inside') {
19
+ return svg`
20
+ <defs>
21
+ <clipPath id="clip${id}">
22
+ <rect id=${id} x=${-data.width / 2} y=${yPosition} width=${
23
+ data.width
24
+ } height=${data.height} rx=${
25
+ data.borderRadius
26
+ } vector-effect="non-scaling-stroke" />
27
+ </clipPath>
28
+ </defs>
29
+ <rect id=${id} x=${-data.width / 2} y=${yPosition} width=${
30
+ data.width
31
+ } height=${data.height} rx=${
32
+ data.borderRadius
33
+ } vector-effect="non-scaling-stroke" stroke=${
34
+ data.strokeColor
35
+ } stroke-width=${data.strokeWidth * 2} fill=${
36
+ data.fillColor
37
+ } clip-path="url(#clip${id})"/>
38
+ `;
39
+ } else {
40
+ return null;
41
+ }
42
+ }