@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
@@ -0,0 +1,62 @@
|
|
1
|
+
import {SVGTemplateResult, svg} from 'lit';
|
2
|
+
|
3
|
+
export interface Tickmark {
|
4
|
+
angle: number;
|
5
|
+
type: TickmarkType;
|
6
|
+
text?: string;
|
7
|
+
}
|
8
|
+
|
9
|
+
export enum TickmarkType {
|
10
|
+
main = 'main',
|
11
|
+
primary = 'primary',
|
12
|
+
secondary = 'secondary',
|
13
|
+
tertiary = 'tertiary',
|
14
|
+
}
|
15
|
+
|
16
|
+
export enum TickmarkStyle {
|
17
|
+
hinted = 'hinted',
|
18
|
+
regular = 'regular',
|
19
|
+
enhanced = 'enhanced',
|
20
|
+
}
|
21
|
+
|
22
|
+
export function tickmarkColor(style: TickmarkStyle): string {
|
23
|
+
if (style === TickmarkStyle.hinted) {
|
24
|
+
return 'var(--instrument-frame-tertiary-color)';
|
25
|
+
} else if (style === TickmarkStyle.regular) {
|
26
|
+
return 'var(--instrument-tick-mark-secondary-color)';
|
27
|
+
} else {
|
28
|
+
return 'var(--instrument-tick-mark-primary-color)';
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
export function tickmark(
|
33
|
+
angle: number,
|
34
|
+
tickmarkSize: TickmarkType,
|
35
|
+
style: TickmarkStyle,
|
36
|
+
text?: string
|
37
|
+
): SVGTemplateResult | SVGTemplateResult[] {
|
38
|
+
const textHeight = -32;
|
39
|
+
let lineStartY: number = -35;
|
40
|
+
let lineEndY: number = -34;
|
41
|
+
|
42
|
+
if (tickmarkSize === TickmarkType.secondary) {
|
43
|
+
lineStartY = -24;
|
44
|
+
lineEndY = lineStartY + 8;
|
45
|
+
} else if (tickmarkSize === TickmarkType.main) {
|
46
|
+
lineEndY = lineStartY + 20;
|
47
|
+
} else if (tickmarkSize === TickmarkType.tertiary) {
|
48
|
+
throw new Error('Tertiary tickmarks are not supported');
|
49
|
+
}
|
50
|
+
|
51
|
+
const colorName = tickmarkColor(style);
|
52
|
+
const tick = svg`<line x1=${angle} y1=${lineStartY} x2=${angle} y2=${lineEndY} stroke=${colorName} stroke-width="1" vector-effect="non-scaling-stroke"/>`;
|
53
|
+
if (text) {
|
54
|
+
const textY = lineEndY + textHeight;
|
55
|
+
return [
|
56
|
+
tick,
|
57
|
+
svg`<text x=${angle} y=${textY} class="label" text-anchor="middle">${text}</text>`,
|
58
|
+
];
|
59
|
+
}
|
60
|
+
|
61
|
+
return tick;
|
62
|
+
}
|
@@ -0,0 +1,19 @@
|
|
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
|
+
}
|
12
|
+
|
13
|
+
.label.left {
|
14
|
+
text-anchor: start;
|
15
|
+
}
|
16
|
+
|
17
|
+
.label.right {
|
18
|
+
text-anchor: end;
|
19
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type {Meta, StoryObj} from '@storybook/web-components';
|
2
|
+
import {ObcWatchFlat} from './watch-flat';
|
3
|
+
import './watch-flat';
|
4
|
+
|
5
|
+
const meta: Meta<typeof ObcWatchFlat> = {
|
6
|
+
title: 'Building blocks/Watch flat',
|
7
|
+
tags: ['autodocs'],
|
8
|
+
component: 'obc-watch-flat',
|
9
|
+
args: {},
|
10
|
+
} satisfies Meta<ObcWatchFlat>;
|
11
|
+
|
12
|
+
export default meta;
|
13
|
+
type Story = StoryObj<ObcWatchFlat>;
|
14
|
+
|
15
|
+
export const Primary: Story = {
|
16
|
+
args: {},
|
17
|
+
};
|
@@ -0,0 +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
|
+
}
|