@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.16 → 2.2.0-next.18
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 +442 -87
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +1970 -28
- package/dist/automation/analog-threeway-valve/analog-threeway-valve.d.ts +4 -4
- package/dist/automation/analog-threeway-valve/analog-threeway-valve.js.map +1 -1
- package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts +20 -0
- package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts.map +1 -1
- package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js +1 -0
- package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js.map +1 -1
- package/dist/automation/automation-button/abstract-automation-button.d.ts +11 -2
- package/dist/automation/automation-button/abstract-automation-button.d.ts.map +1 -1
- package/dist/automation/automation-button/abstract-automation-button.js +40 -20
- package/dist/automation/automation-button/abstract-automation-button.js.map +1 -1
- package/dist/automation/automation-button/badge-layout.d.ts +34 -0
- package/dist/automation/automation-button/badge-layout.d.ts.map +1 -0
- package/dist/automation/automation-button/badge-layout.js +64 -0
- package/dist/automation/automation-button/badge-layout.js.map +1 -0
- package/dist/automation/digital-threeway-valve/digital-threeway-valve.d.ts +4 -4
- package/dist/automation/digital-threeway-valve/digital-threeway-valve.js.map +1 -1
- package/dist/automation/electricity-battery/electricity-battery.d.ts +4 -4
- package/dist/automation/electricity-battery/electricity-battery.js.map +1 -1
- package/dist/building-blocks/bar-horizontal/bar-horizontal.d.ts +4 -0
- package/dist/building-blocks/bar-horizontal/bar-horizontal.d.ts.map +1 -1
- package/dist/building-blocks/bar-horizontal/bar-horizontal.js +26 -23
- package/dist/building-blocks/bar-horizontal/bar-horizontal.js.map +1 -1
- package/dist/building-blocks/bar-vertical/bar-vertical.d.ts +4 -0
- package/dist/building-blocks/bar-vertical/bar-vertical.d.ts.map +1 -1
- package/dist/building-blocks/bar-vertical/bar-vertical.js +26 -23
- package/dist/building-blocks/bar-vertical/bar-vertical.js.map +1 -1
- package/dist/building-blocks/external-scale/external-scale.d.ts +28 -1
- package/dist/building-blocks/external-scale/external-scale.d.ts.map +1 -1
- package/dist/building-blocks/external-scale/external-scale.js +30 -4
- package/dist/building-blocks/external-scale/external-scale.js.map +1 -1
- package/dist/internal/global-setting.d.ts +55 -0
- package/dist/internal/global-setting.d.ts.map +1 -0
- package/dist/internal/global-setting.js +86 -0
- package/dist/internal/global-setting.js.map +1 -0
- package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.d.ts +28 -17
- package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.d.ts.map +1 -1
- package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.js +91 -11
- package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.js.map +1 -1
- package/dist/navigation-instruments/gauge-vertical/gauge-vertical.d.ts +28 -17
- package/dist/navigation-instruments/gauge-vertical/gauge-vertical.d.ts.map +1 -1
- package/dist/navigation-instruments/gauge-vertical/gauge-vertical.js +91 -11
- package/dist/navigation-instruments/gauge-vertical/gauge-vertical.js.map +1 -1
- package/package.json +1 -1
- package/src/automation/analog-threeway-valve/analog-threeway-valve.ts +4 -4
- package/src/automation/automation-button/abstract-automation-button-storybook-helpers.ts +3 -0
- package/src/automation/automation-button/abstract-automation-button.ts +57 -23
- package/src/automation/automation-button/badge-layout.spec.ts +138 -0
- package/src/automation/automation-button/badge-layout.ts +120 -0
- package/src/automation/digital-threeway-valve/digital-threeway-valve.ts +4 -4
- package/src/automation/electricity-battery/electricity-battery.ts +4 -4
- package/src/automation/pump/pump.stories.ts +59 -0
- package/src/building-blocks/bar-horizontal/bar-horizontal-fixed-aspect.spec.ts +102 -0
- package/src/building-blocks/bar-horizontal/bar-horizontal.ts +28 -23
- package/src/building-blocks/bar-vertical/bar-vertical-fixed-aspect.spec.ts +101 -0
- package/src/building-blocks/bar-vertical/bar-vertical.ts +28 -23
- package/src/building-blocks/external-scale/external-scale.ts +72 -3
- package/src/internal/global-setting.spec.ts +119 -0
- package/src/internal/global-setting.ts +105 -0
- package/src/navigation-instruments/gauge-horizontal/gauge-horizontal.spec.ts +288 -0
- package/src/navigation-instruments/gauge-horizontal/gauge-horizontal.stories.ts +114 -4
- package/src/navigation-instruments/gauge-horizontal/gauge-horizontal.ts +129 -41
- package/src/navigation-instruments/gauge-trend/gauge-trend.stories.ts +8 -0
- package/src/navigation-instruments/gauge-vertical/gauge-vertical.spec.ts +284 -0
- package/src/navigation-instruments/gauge-vertical/gauge-vertical.stories.ts +117 -4
- package/src/navigation-instruments/gauge-vertical/gauge-vertical.ts +129 -41
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {render} from 'vitest-browser-lit';
|
|
3
|
+
import {html} from 'lit';
|
|
4
|
+
import '../../main.css';
|
|
5
|
+
import './gauge-horizontal.js';
|
|
6
|
+
import '../../bars-graphs/line-graph/line-graph.js';
|
|
7
|
+
import {ExternalScaleSide} from './gauge-horizontal.js';
|
|
8
|
+
import type {ObcGaugeHorizontal} from './gauge-horizontal.js';
|
|
9
|
+
import type {ObcLineGraph} from '../../bars-graphs/line-graph/line-graph.js';
|
|
10
|
+
|
|
11
|
+
const frame = () => new Promise((resolve) => requestAnimationFrame(resolve));
|
|
12
|
+
|
|
13
|
+
/** The scale factor settles a few frames after a size change. */
|
|
14
|
+
async function until(check: () => boolean, frames = 40): Promise<void> {
|
|
15
|
+
for (let i = 0; i < frames; i++) {
|
|
16
|
+
if (check()) return;
|
|
17
|
+
await frame();
|
|
18
|
+
}
|
|
19
|
+
throw new Error('the condition never held');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const svgOf = (el: Element) => el.querySelector('svg')!;
|
|
23
|
+
const scaleOf = (el: Element) =>
|
|
24
|
+
parseFloat(svgOf(el).style.getPropertyValue('--scale'));
|
|
25
|
+
|
|
26
|
+
/** Default bands and no setpoint: 48 bar + 24 ticks + 60 labels = 132 thick. */
|
|
27
|
+
async function mount(fixedAspectRatio = false): Promise<ObcGaugeHorizontal> {
|
|
28
|
+
const screen = render(
|
|
29
|
+
html`<div style="display: block; width: 600px; height: 260px">
|
|
30
|
+
<obc-gauge-horizontal
|
|
31
|
+
.minValue=${0}
|
|
32
|
+
.maxValue=${100}
|
|
33
|
+
.value=${40}
|
|
34
|
+
.primaryTickmarkInterval=${20}
|
|
35
|
+
.fixedAspectRatio=${fixedAspectRatio}
|
|
36
|
+
></obc-gauge-horizontal>
|
|
37
|
+
</div>`
|
|
38
|
+
);
|
|
39
|
+
const el = screen.container.querySelector(
|
|
40
|
+
'obc-gauge-horizontal'
|
|
41
|
+
) as ObcGaugeHorizontal;
|
|
42
|
+
await el.updateComplete;
|
|
43
|
+
return el;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('obc-gauge-horizontal sizing', () => {
|
|
47
|
+
it('draws at its 384 px reference length by default', async () => {
|
|
48
|
+
const el = await mount();
|
|
49
|
+
const svg = svgOf(el);
|
|
50
|
+
expect(svg.getAttribute('width')).toBe('384px');
|
|
51
|
+
expect(svg.getAttribute('preserveAspectRatio')).toBe('none');
|
|
52
|
+
expect(Math.round(svg.getBoundingClientRect().width)).toBe(384);
|
|
53
|
+
expect(el.style.display).toBe('');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('fills the box and keeps the label scale when fixedAspectRatio is turned on after connect', async () => {
|
|
57
|
+
const el = await mount();
|
|
58
|
+
el.fixedAspectRatio = true;
|
|
59
|
+
await until(() => scaleOf(el) !== 1);
|
|
60
|
+
const svg = svgOf(el);
|
|
61
|
+
expect(el.style.display).toBe('block');
|
|
62
|
+
expect(el.style.width).toBe('100%');
|
|
63
|
+
expect(svg.getAttribute('width')).toBe('100%');
|
|
64
|
+
expect(svg.getAttribute('height')).toBe('100%');
|
|
65
|
+
expect(svg.getAttribute('preserveAspectRatio')).toBe('xMidYMid meet');
|
|
66
|
+
expect(Math.round(svg.getBoundingClientRect().width)).toBe(600);
|
|
67
|
+
expect(scaleOf(el)).toBeCloseTo(600 / 384, 3);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('follows scaleReferenceSize', async () => {
|
|
71
|
+
const el = await mount(true);
|
|
72
|
+
await until(() => Math.abs(scaleOf(el) - 600 / 384) < 1e-3);
|
|
73
|
+
el.scaleReferenceSize = 192;
|
|
74
|
+
await until(() => Math.abs(scaleOf(el) - 600 / 192) < 1e-3);
|
|
75
|
+
expect(scaleOf(el)).toBeCloseTo(3.125, 3);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('reports the scaled thickness, and re-reports on side and showLabels', async () => {
|
|
79
|
+
const el = await mount();
|
|
80
|
+
const reports: number[] = [];
|
|
81
|
+
el.addEventListener('scale-dimensions-changed', (e) =>
|
|
82
|
+
reports.push((e as CustomEvent<{thickness: number}>).detail.thickness)
|
|
83
|
+
);
|
|
84
|
+
el.fixedAspectRatio = true;
|
|
85
|
+
// 132 × 600 / 384 = 206.25
|
|
86
|
+
await until(() => reports[reports.length - 1] === 206);
|
|
87
|
+
const before = reports.length;
|
|
88
|
+
el.side = ExternalScaleSide.top;
|
|
89
|
+
await el.updateComplete;
|
|
90
|
+
await frame();
|
|
91
|
+
expect(reports.length).toBeGreaterThan(before);
|
|
92
|
+
el.showLabels = false;
|
|
93
|
+
// (48 + 24) × 600 / 384 = 112.5
|
|
94
|
+
await until(() => reports[reports.length - 1] === 113);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('returns to the pixel drawing when fixedAspectRatio is turned off', async () => {
|
|
98
|
+
const el = await mount(true);
|
|
99
|
+
await until(() => scaleOf(el) > 1);
|
|
100
|
+
el.fixedAspectRatio = false;
|
|
101
|
+
await el.updateComplete;
|
|
102
|
+
await frame();
|
|
103
|
+
expect(svgOf(el).getAttribute('width')).toBe('384px');
|
|
104
|
+
expect(el.style.display).toBe('');
|
|
105
|
+
expect(scaleOf(el)).toBe(1);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('gives a fixed-aspect chart its rendered thickness', async () => {
|
|
109
|
+
const screen = render(
|
|
110
|
+
html`<obc-line-graph
|
|
111
|
+
style="display: block; width: 800px"
|
|
112
|
+
.width=${800}
|
|
113
|
+
.height=${400}
|
|
114
|
+
.fixedAspectRatioScaling=${true}
|
|
115
|
+
.data=${[
|
|
116
|
+
{label: 'a', value: 10},
|
|
117
|
+
{label: 'b', value: 40},
|
|
118
|
+
{label: 'c', value: 25},
|
|
119
|
+
]}
|
|
120
|
+
>
|
|
121
|
+
<obc-gauge-horizontal
|
|
122
|
+
slot="bottom-scale"
|
|
123
|
+
.minValue=${0}
|
|
124
|
+
.maxValue=${100}
|
|
125
|
+
.value=${40}
|
|
126
|
+
.primaryTickmarkInterval=${20}
|
|
127
|
+
></obc-gauge-horizontal>
|
|
128
|
+
</obc-line-graph>`
|
|
129
|
+
);
|
|
130
|
+
const chart = screen.container.querySelector(
|
|
131
|
+
'obc-line-graph'
|
|
132
|
+
) as ObcLineGraph;
|
|
133
|
+
const el = screen.container.querySelector(
|
|
134
|
+
'obc-gauge-horizontal'
|
|
135
|
+
) as ObcGaugeHorizontal;
|
|
136
|
+
await chart.updateComplete;
|
|
137
|
+
const reports: number[] = [];
|
|
138
|
+
chart
|
|
139
|
+
.shadowRoot!.querySelector('slot[name="bottom-scale"]')!
|
|
140
|
+
.addEventListener('scale-dimensions-changed', (e) =>
|
|
141
|
+
reports.push((e as CustomEvent<{thickness: number}>).detail.thickness)
|
|
142
|
+
);
|
|
143
|
+
// The slot is 800 px wide: 132 × 800 / 384 = 275
|
|
144
|
+
await until(() => Math.abs(scaleOf(el) - 800 / 384) < 1e-3, 90);
|
|
145
|
+
await until(() => reports[reports.length - 1] === 275, 90);
|
|
146
|
+
// The chart grows the slot once its debounced layout runs.
|
|
147
|
+
await until(
|
|
148
|
+
() => Math.round(svgOf(el).getBoundingClientRect().height) === 275,
|
|
149
|
+
90
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('leaves a consumer inline style alone in pixel mode', async () => {
|
|
154
|
+
const screen = render(
|
|
155
|
+
html`<obc-gauge-horizontal
|
|
156
|
+
style="display: none; width: 300px"
|
|
157
|
+
.minValue=${0}
|
|
158
|
+
.maxValue=${100}
|
|
159
|
+
></obc-gauge-horizontal>`
|
|
160
|
+
);
|
|
161
|
+
const el = screen.container.querySelector(
|
|
162
|
+
'obc-gauge-horizontal'
|
|
163
|
+
) as ObcGaugeHorizontal;
|
|
164
|
+
await el.updateComplete;
|
|
165
|
+
await frame();
|
|
166
|
+
expect(el.style.display).toBe('none');
|
|
167
|
+
expect(el.style.width).toBe('300px');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('gives a consumer inline style back after a toggle cycle', async () => {
|
|
171
|
+
const screen = render(
|
|
172
|
+
html`<div style="display: block; width: 600px; height: 260px">
|
|
173
|
+
<obc-gauge-horizontal
|
|
174
|
+
style="display: inline-block; height: 120px; width: 300px !important"
|
|
175
|
+
.minValue=${0}
|
|
176
|
+
.maxValue=${100}
|
|
177
|
+
></obc-gauge-horizontal>
|
|
178
|
+
</div>`
|
|
179
|
+
);
|
|
180
|
+
const el = screen.container.querySelector(
|
|
181
|
+
'obc-gauge-horizontal'
|
|
182
|
+
) as ObcGaugeHorizontal;
|
|
183
|
+
await el.updateComplete;
|
|
184
|
+
el.fixedAspectRatio = true;
|
|
185
|
+
await until(() => scaleOf(el) !== 1);
|
|
186
|
+
expect(el.style.width).toBe('100%');
|
|
187
|
+
el.fixedAspectRatio = false;
|
|
188
|
+
await el.updateComplete;
|
|
189
|
+
expect(el.style.display).toBe('inline-block');
|
|
190
|
+
expect(el.style.height).toBe('120px');
|
|
191
|
+
expect(el.style.width).toBe('300px');
|
|
192
|
+
expect(el.style.getPropertyPriority('width')).toBe('important');
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('follows the painted scale when the host is shorter than the drawing', async () => {
|
|
196
|
+
const screen = render(
|
|
197
|
+
html`<div style="display: flex; width: 600px; height: 100px">
|
|
198
|
+
<obc-gauge-horizontal
|
|
199
|
+
style="flex: 1"
|
|
200
|
+
.minValue=${0}
|
|
201
|
+
.maxValue=${100}
|
|
202
|
+
.value=${40}
|
|
203
|
+
.primaryTickmarkInterval=${20}
|
|
204
|
+
.fixedAspectRatio=${true}
|
|
205
|
+
></obc-gauge-horizontal>
|
|
206
|
+
</div>`
|
|
207
|
+
);
|
|
208
|
+
const el = screen.container.querySelector(
|
|
209
|
+
'obc-gauge-horizontal'
|
|
210
|
+
) as ObcGaugeHorizontal;
|
|
211
|
+
await el.updateComplete;
|
|
212
|
+
const reports: number[] = [];
|
|
213
|
+
el.addEventListener('scale-dimensions-changed', (e) =>
|
|
214
|
+
reports.push((e as CustomEvent<{thickness: number}>).detail.thickness)
|
|
215
|
+
);
|
|
216
|
+
// meet: the 132-tall drawing fits 100 px before the 384-long one fits 600
|
|
217
|
+
await until(() => Math.abs(scaleOf(el) - 100 / 132) < 1e-3);
|
|
218
|
+
const svg = svgOf(el);
|
|
219
|
+
const text = svg.querySelector('text')!;
|
|
220
|
+
const painted = svg.getScreenCTM()!.a;
|
|
221
|
+
expect(painted).toBeCloseTo(100 / 132, 3);
|
|
222
|
+
expect(parseFloat(getComputedStyle(text).fontSize) * painted).toBeCloseTo(
|
|
223
|
+
12,
|
|
224
|
+
1
|
|
225
|
+
);
|
|
226
|
+
await until(() => reports[reports.length - 1] === 100);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('re-measures the scale when the drawing thickness changes under the same box', async () => {
|
|
230
|
+
const screen = render(
|
|
231
|
+
html`<div style="display: flex; width: 600px; height: 100px">
|
|
232
|
+
<obc-gauge-horizontal
|
|
233
|
+
style="flex: 1"
|
|
234
|
+
.minValue=${0}
|
|
235
|
+
.maxValue=${100}
|
|
236
|
+
.value=${40}
|
|
237
|
+
.primaryTickmarkInterval=${20}
|
|
238
|
+
.fixedAspectRatio=${true}
|
|
239
|
+
></obc-gauge-horizontal>
|
|
240
|
+
</div>`
|
|
241
|
+
);
|
|
242
|
+
const el = screen.container.querySelector(
|
|
243
|
+
'obc-gauge-horizontal'
|
|
244
|
+
) as ObcGaugeHorizontal;
|
|
245
|
+
await el.updateComplete;
|
|
246
|
+
const reports: number[] = [];
|
|
247
|
+
el.addEventListener('scale-dimensions-changed', (e) =>
|
|
248
|
+
reports.push((e as CustomEvent<{thickness: number}>).detail.thickness)
|
|
249
|
+
);
|
|
250
|
+
await until(() => Math.abs(scaleOf(el) - 100 / 132) < 1e-3);
|
|
251
|
+
// 48 + 24 = 72 tall without labels, still more than 100 px at the width's
|
|
252
|
+
// 1.5625, so the height keeps deciding
|
|
253
|
+
reports.length = 0;
|
|
254
|
+
el.showLabels = false;
|
|
255
|
+
await until(() => Math.abs(scaleOf(el) - 100 / 72) < 1e-3);
|
|
256
|
+
await until(() => reports[reports.length - 1] === 100);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('measures the content box of a padded host', async () => {
|
|
260
|
+
const screen = render(
|
|
261
|
+
html`<div style="display: flex; width: 600px; height: 100px">
|
|
262
|
+
<obc-gauge-horizontal
|
|
263
|
+
style="flex: 1; padding: 20px"
|
|
264
|
+
.minValue=${0}
|
|
265
|
+
.maxValue=${100}
|
|
266
|
+
.value=${40}
|
|
267
|
+
.primaryTickmarkInterval=${20}
|
|
268
|
+
.fixedAspectRatio=${true}
|
|
269
|
+
></obc-gauge-horizontal>
|
|
270
|
+
</div>`
|
|
271
|
+
);
|
|
272
|
+
const el = screen.container.querySelector(
|
|
273
|
+
'obc-gauge-horizontal'
|
|
274
|
+
) as ObcGaugeHorizontal;
|
|
275
|
+
await el.updateComplete;
|
|
276
|
+
const reports: number[] = [];
|
|
277
|
+
el.addEventListener('scale-dimensions-changed', (e) =>
|
|
278
|
+
reports.push((e as CustomEvent<{thickness: number}>).detail.thickness)
|
|
279
|
+
);
|
|
280
|
+
// 60 px of content height for the 132-tall drawing
|
|
281
|
+
await until(() => Math.abs(scaleOf(el) - 60 / 132) < 1e-3);
|
|
282
|
+
reports.length = 0;
|
|
283
|
+
// 72 tall without labels: 60 / 72 is still under the width's 560 / 384
|
|
284
|
+
el.showLabels = false;
|
|
285
|
+
await until(() => Math.abs(scaleOf(el) - 60 / 72) < 1e-3);
|
|
286
|
+
await until(() => reports[reports.length - 1] === 60);
|
|
287
|
+
});
|
|
288
|
+
});
|
|
@@ -15,6 +15,23 @@ const meta: Meta = {
|
|
|
15
15
|
tags: ['autodocs', '6.0'],
|
|
16
16
|
component: 'obc-gauge-horizontal',
|
|
17
17
|
argTypes: {
|
|
18
|
+
// Fixed by design and not API; the manifest lists the fields, so the
|
|
19
|
+
// table would otherwise show dead controls.
|
|
20
|
+
width: {table: {disable: true}},
|
|
21
|
+
paddingLeft: {table: {disable: true}},
|
|
22
|
+
paddingRight: {table: {disable: true}},
|
|
23
|
+
barThickness: {table: {disable: true}},
|
|
24
|
+
tickThickness: {table: {disable: true}},
|
|
25
|
+
labelThickness: {table: {disable: true}},
|
|
26
|
+
scaleType: {table: {disable: true}},
|
|
27
|
+
frameStyle: {table: {disable: true}},
|
|
28
|
+
borderRadius: {table: {disable: true}},
|
|
29
|
+
hasBar: {table: {disable: true}},
|
|
30
|
+
hasScale: {table: {disable: true}},
|
|
31
|
+
scaleBackground: {table: {disable: true}},
|
|
32
|
+
advicePosition: {table: {disable: true}},
|
|
33
|
+
fixedAspectRatio: {control: {type: 'boolean'}},
|
|
34
|
+
scaleReferenceSize: {control: {type: 'range', min: 96, max: 768, step: 8}},
|
|
18
35
|
minValue: {control: {type: 'range', min: -100, max: 100}},
|
|
19
36
|
maxValue: {control: {type: 'range', min: 0, max: 1000}},
|
|
20
37
|
reverse: {control: {type: 'boolean'}},
|
|
@@ -50,6 +67,8 @@ const meta: Meta = {
|
|
|
50
67
|
advices: {control: {type: 'object'}},
|
|
51
68
|
},
|
|
52
69
|
args: {
|
|
70
|
+
fixedAspectRatio: false,
|
|
71
|
+
scaleReferenceSize: 384,
|
|
53
72
|
minValue: 0,
|
|
54
73
|
maxValue: 100,
|
|
55
74
|
reverse: false,
|
|
@@ -74,8 +93,12 @@ const meta: Meta = {
|
|
|
74
93
|
side: 'bottom',
|
|
75
94
|
advices: [],
|
|
76
95
|
},
|
|
77
|
-
|
|
78
|
-
|
|
96
|
+
// A fixed-aspect gauge fills its host, so the toggle only shows something
|
|
97
|
+
// inside a sized box; off, the gauge renders bare and the baselines hold.
|
|
98
|
+
render: (args) => {
|
|
99
|
+
const gauge = html`<obc-gauge-horizontal
|
|
100
|
+
.fixedAspectRatio=${args.fixedAspectRatio}
|
|
101
|
+
.scaleReferenceSize=${args.scaleReferenceSize ?? 384}
|
|
79
102
|
.minValue=${args.minValue}
|
|
80
103
|
.maxValue=${args.maxValue}
|
|
81
104
|
.reverse=${args.reverse}
|
|
@@ -100,8 +123,11 @@ const meta: Meta = {
|
|
|
100
123
|
.side=${args.side}
|
|
101
124
|
.advices=${args.advices}
|
|
102
125
|
>
|
|
103
|
-
</obc-gauge-horizontal
|
|
104
|
-
|
|
126
|
+
</obc-gauge-horizontal>`;
|
|
127
|
+
return args.fixedAspectRatio
|
|
128
|
+
? html`<div style="width: 600px">${gauge}</div>`
|
|
129
|
+
: gauge;
|
|
130
|
+
},
|
|
105
131
|
} satisfies Meta;
|
|
106
132
|
|
|
107
133
|
export default meta;
|
|
@@ -544,3 +570,87 @@ export const Reversed: Story = {
|
|
|
544
570
|
secondaryTickmarkInterval: 1,
|
|
545
571
|
},
|
|
546
572
|
};
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* `obc-gauge-horizontal` is a fixed-config gauge: it draws at the design's 384 px
|
|
576
|
+
* reference width with the bar, tick and label bands at their design
|
|
577
|
+
* thickness. That number is where the drawing is 1:1, not a layout limit.
|
|
578
|
+
*
|
|
579
|
+
* - **fixedAspectRatio=false (default)**: a 384 px wide SVG, whatever the box does.
|
|
580
|
+
* - **fixedAspectRatio=true**: the whole gauge scales to the width of its host
|
|
581
|
+
* like a vector image and the labels keep their font size; `scaleReferenceSize`
|
|
582
|
+
* is the host width at which it is 1:1. Size the host, the gauge fills it.
|
|
583
|
+
*
|
|
584
|
+
* For a scale whose length follows the layout while the bands keep their design
|
|
585
|
+
* thickness, use `obc-bar-horizontal` with `width` from a ResizeObserver, as the
|
|
586
|
+
* table's bar cells and the chart slots do.
|
|
587
|
+
*
|
|
588
|
+
* Drag the corner of each box to resize it.
|
|
589
|
+
*/
|
|
590
|
+
export const FixedAspectRatioComparison: StoryObj = {
|
|
591
|
+
tags: ['skip-test'],
|
|
592
|
+
render: () => html`
|
|
593
|
+
<style>
|
|
594
|
+
.far-wrapper {
|
|
595
|
+
display: grid;
|
|
596
|
+
grid-template-rows: 1fr 1fr;
|
|
597
|
+
gap: 32px;
|
|
598
|
+
padding: 16px;
|
|
599
|
+
width: 600px;
|
|
600
|
+
height: 520px;
|
|
601
|
+
}
|
|
602
|
+
.far-box {
|
|
603
|
+
display: flex;
|
|
604
|
+
flex-direction: column;
|
|
605
|
+
padding: 16px;
|
|
606
|
+
border: 2px dashed var(--instrument-frame-tertiary-color);
|
|
607
|
+
resize: both;
|
|
608
|
+
overflow: auto;
|
|
609
|
+
min-width: 200px;
|
|
610
|
+
min-height: 100px;
|
|
611
|
+
}
|
|
612
|
+
.far-box-fixed {
|
|
613
|
+
border-color: var(--instrument-enhanced-primary-color);
|
|
614
|
+
}
|
|
615
|
+
.far-label {
|
|
616
|
+
flex-shrink: 0;
|
|
617
|
+
margin-bottom: 8px;
|
|
618
|
+
font-family: var(--font-family-main);
|
|
619
|
+
font-size: 14px;
|
|
620
|
+
color: var(--instrument-frame-tertiary-color);
|
|
621
|
+
}
|
|
622
|
+
.far-box-fixed .far-label {
|
|
623
|
+
color: var(--instrument-enhanced-primary-color);
|
|
624
|
+
}
|
|
625
|
+
</style>
|
|
626
|
+
<div class="far-wrapper">
|
|
627
|
+
<div class="far-box">
|
|
628
|
+
<div class="far-label">
|
|
629
|
+
fixedAspectRatio=false (default): 384 px wide, whatever the box does
|
|
630
|
+
</div>
|
|
631
|
+
<obc-gauge-horizontal
|
|
632
|
+
.minValue=${-20}
|
|
633
|
+
.maxValue=${120}
|
|
634
|
+
.value=${60}
|
|
635
|
+
.setpoint=${80}
|
|
636
|
+
.primaryTickmarkInterval=${20}
|
|
637
|
+
.priority=${Priority.regular}
|
|
638
|
+
></obc-gauge-horizontal>
|
|
639
|
+
</div>
|
|
640
|
+
<div class="far-box far-box-fixed">
|
|
641
|
+
<div class="far-label">
|
|
642
|
+
fixedAspectRatio=true: fills the box width, labels keep their size
|
|
643
|
+
</div>
|
|
644
|
+
<obc-gauge-horizontal
|
|
645
|
+
.fixedAspectRatio=${true}
|
|
646
|
+
.minValue=${-20}
|
|
647
|
+
.maxValue=${120}
|
|
648
|
+
.value=${60}
|
|
649
|
+
.setpoint=${80}
|
|
650
|
+
.primaryTickmarkInterval=${20}
|
|
651
|
+
.priority=${Priority.enhanced}
|
|
652
|
+
></obc-gauge-horizontal>
|
|
653
|
+
</div>
|
|
654
|
+
</div>
|
|
655
|
+
`,
|
|
656
|
+
};
|