@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.15 → 2.2.0-next.17
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 +320 -64
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +1752 -15
- 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-badge/automation-badge.css_inline.js +6 -0
- package/dist/automation/automation-badge/automation-badge.d.ts +61 -1
- package/dist/automation/automation-badge/automation-badge.d.ts.map +1 -1
- package/dist/automation/automation-badge/automation-badge.js +83 -1
- package/dist/automation/automation-badge/automation-badge.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 +16 -4
- package/dist/automation/automation-button/abstract-automation-button.d.ts.map +1 -1
- package/dist/automation/automation-button/abstract-automation-button.js +46 -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/automation-tank/automation-tank.d.ts.map +1 -1
- package/dist/automation/automation-tank/automation-tank.js +7 -2
- package/dist/automation/automation-tank/automation-tank.js.map +1 -1
- 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/automation/specialty-tank/abstract-specialty-tank.d.ts.map +1 -1
- package/dist/automation/specialty-tank/abstract-specialty-tank.js +7 -2
- package/dist/automation/specialty-tank/abstract-specialty-tank.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/package.json +3 -2
- package/script/check-typography-ramp.ts +144 -0
- package/script/typography/ramp.ts +237 -0
- package/script/typography-ramp.test.ts +267 -0
- package/src/automation/analog-threeway-valve/analog-threeway-valve.ts +4 -4
- package/src/automation/analog-valve/analog-valve.stories.ts +8 -0
- package/src/automation/automation-badge/automation-badge.css +6 -0
- package/src/automation/automation-badge/automation-badge.stories.ts +47 -3
- package/src/automation/automation-badge/automation-badge.ts +124 -1
- package/src/automation/automation-button/abstract-automation-button-storybook-helpers.ts +3 -0
- package/src/automation/automation-button/abstract-automation-button.ts +70 -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/automation-tank/automation-tank.ts +11 -6
- 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/automation/specialty-tank/abstract-specialty-tank.ts +11 -6
- package/src/internal/global-setting.spec.ts +119 -0
- package/src/internal/global-setting.ts +105 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {stripComments} from './source-links.js';
|
|
3
|
+
import {
|
|
4
|
+
mixinTokens,
|
|
5
|
+
rampGaps,
|
|
6
|
+
readPalette,
|
|
7
|
+
readTokens,
|
|
8
|
+
resolveLength,
|
|
9
|
+
} from './typography/ramp.js';
|
|
10
|
+
|
|
11
|
+
const VARIABLES = `:root,
|
|
12
|
+
.obc-component-size-regular {
|
|
13
|
+
--global-typography-value-font-size: var(--font-size-100);
|
|
14
|
+
--global-typography-value-line-height: 20px;
|
|
15
|
+
--global-typography-value-font-weight: 570;
|
|
16
|
+
--global-typography-label-font-size: 12px;
|
|
17
|
+
--global-typography-title-font-size: 24px;
|
|
18
|
+
--automation-components-typography-unit-font-size: var(--font-size-100);
|
|
19
|
+
}
|
|
20
|
+
.obc-component-size-medium {
|
|
21
|
+
--global-typography-value-font-size: 22px;
|
|
22
|
+
--global-typography-value-line-height: 24px;
|
|
23
|
+
--global-typography-value-font-weight: 0;
|
|
24
|
+
--global-typography-title-font-size: 32px;
|
|
25
|
+
--automation-components-typography-unit-font-size: 24px;
|
|
26
|
+
}
|
|
27
|
+
.obc-component-size-large {
|
|
28
|
+
--global-typography-value-font-size: 34px;
|
|
29
|
+
--global-typography-value-line-height: 32px;
|
|
30
|
+
--global-typography-label-font-size: 22px;
|
|
31
|
+
--global-typography-title-font-size: 44px;
|
|
32
|
+
--automation-components-typography-unit-font-size: 32px;
|
|
33
|
+
}
|
|
34
|
+
.obc-component-size-xl {
|
|
35
|
+
--global-typography-value-font-size: 40px;
|
|
36
|
+
--global-typography-value-line-height: 48px;
|
|
37
|
+
--global-typography-label-font-size: 32px;
|
|
38
|
+
--global-typography-title-font-size: 0.0px;
|
|
39
|
+
--automation-components-typography-unit-font-size: var(--font-size-100);
|
|
40
|
+
}
|
|
41
|
+
* {
|
|
42
|
+
--font-size-100: 16px;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
const MIXINS = `@define-mixin font-value {
|
|
47
|
+
font-size: var(--global-typography-value-font-size);
|
|
48
|
+
line-height: var(--global-typography-value-line-height);
|
|
49
|
+
font-weight: var(--global-typography-value-font-weight);
|
|
50
|
+
}
|
|
51
|
+
@define-mixin font-label {
|
|
52
|
+
font-size: var(--global-typography-label-font-size);
|
|
53
|
+
}
|
|
54
|
+
@define-mixin value-tag {
|
|
55
|
+
@mixin font-label;
|
|
56
|
+
color: red;
|
|
57
|
+
}
|
|
58
|
+
@define-mixin empty-state {
|
|
59
|
+
.icon {
|
|
60
|
+
height: 96px;
|
|
61
|
+
}
|
|
62
|
+
.title {
|
|
63
|
+
@mixin font-label;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
@define-mixin style $style, $wrapper: .x {
|
|
67
|
+
outline: 1px solid var(--global-typography-title-font-size);
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
const mixins = mixinTokens([MIXINS]);
|
|
72
|
+
const palette = readPalette(VARIABLES);
|
|
73
|
+
|
|
74
|
+
describe('mixinTokens', () => {
|
|
75
|
+
it('collects the tokens of a mixin and of the mixins it applies', () => {
|
|
76
|
+
expect(mixins.get('font-value')).toEqual(
|
|
77
|
+
new Set([
|
|
78
|
+
'--global-typography-value-font-size',
|
|
79
|
+
'--global-typography-value-line-height',
|
|
80
|
+
'--global-typography-value-font-weight',
|
|
81
|
+
])
|
|
82
|
+
);
|
|
83
|
+
expect(mixins.get('value-tag')).toEqual(
|
|
84
|
+
new Set(['--global-typography-label-font-size'])
|
|
85
|
+
);
|
|
86
|
+
expect(mixins.get('style')).toEqual(
|
|
87
|
+
new Set(['--global-typography-title-font-size'])
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('reads the whole body, past a nested rule', () => {
|
|
92
|
+
expect(mixins.get('empty-state')).toEqual(
|
|
93
|
+
new Set(['--global-typography-label-font-size'])
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('readTokens', () => {
|
|
99
|
+
it('reads var() uses, bare names in TypeScript and applied mixins', () => {
|
|
100
|
+
expect(
|
|
101
|
+
readTokens(
|
|
102
|
+
'.a {\n @mixin value-tag;\n height: var(--global-typography-value-line-height);\n}\n',
|
|
103
|
+
mixins
|
|
104
|
+
)
|
|
105
|
+
).toEqual(
|
|
106
|
+
new Set([
|
|
107
|
+
'--global-typography-label-font-size',
|
|
108
|
+
'--global-typography-value-line-height',
|
|
109
|
+
])
|
|
110
|
+
);
|
|
111
|
+
expect(
|
|
112
|
+
readTokens(
|
|
113
|
+
"const VALUE = {fontSizeVar: '--global-typography-value-font-size'};",
|
|
114
|
+
mixins
|
|
115
|
+
)
|
|
116
|
+
).toEqual(new Set(['--global-typography-value-font-size']));
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('does not count a name in a TypeScript comment once comments are stripped', () => {
|
|
120
|
+
const source =
|
|
121
|
+
"// was --global-typography-title-font-size\nconst a = '--global-typography-value-font-size';";
|
|
122
|
+
expect(readTokens(stripComments(source), mixins)).toEqual(
|
|
123
|
+
new Set(['--global-typography-value-font-size'])
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('readPalette', () => {
|
|
129
|
+
it('finds the four blocks, the regular one shared with :root, and the primitives', () => {
|
|
130
|
+
expect(
|
|
131
|
+
palette.classes.regular.get('--global-typography-value-font-size')
|
|
132
|
+
).toBe('var(--font-size-100)');
|
|
133
|
+
expect(palette.classes.xl.get('--global-typography-title-font-size')).toBe(
|
|
134
|
+
'0.0px'
|
|
135
|
+
);
|
|
136
|
+
expect(palette.primitives.get('--font-size-100')).toBe('16px');
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('throws when a size class block is missing', () => {
|
|
140
|
+
expect(() => readPalette(':root { --a: 1px; }')).toThrow(
|
|
141
|
+
'.obc-component-size-regular'
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('resolveLength', () => {
|
|
147
|
+
it('follows var() to the primitive and reads its number and unit', () => {
|
|
148
|
+
expect(
|
|
149
|
+
resolveLength(
|
|
150
|
+
'var(--font-size-100)',
|
|
151
|
+
palette.classes.xl,
|
|
152
|
+
palette.primitives
|
|
153
|
+
)
|
|
154
|
+
).toEqual({n: 16, unit: 'px'});
|
|
155
|
+
expect(
|
|
156
|
+
resolveLength('0.0px', palette.classes.xl, palette.primitives)
|
|
157
|
+
).toEqual({n: 0, unit: 'px'});
|
|
158
|
+
expect(
|
|
159
|
+
resolveLength('normal', palette.classes.xl, palette.primitives)
|
|
160
|
+
).toBeUndefined();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
describe('rampGaps', () => {
|
|
165
|
+
const readers = new Map([
|
|
166
|
+
['--global-typography-value-font-size', new Set(['a.css'])],
|
|
167
|
+
['--global-typography-value-line-height', new Set(['a.css'])],
|
|
168
|
+
['--global-typography-value-font-weight', new Set(['a.css'])],
|
|
169
|
+
['--global-typography-label-font-size', new Set(['b.css', 'c.ts'])],
|
|
170
|
+
['--global-typography-title-font-size', new Set(['d.css'])],
|
|
171
|
+
['--automation-components-typography-unit-font-size', new Set(['e.css'])],
|
|
172
|
+
['--component-local-font-size', new Set(['f.css'])],
|
|
173
|
+
]);
|
|
174
|
+
|
|
175
|
+
it('reports a size token a class leaves undeclared, at 0 or smaller than the class before', () => {
|
|
176
|
+
expect(rampGaps(readers, palette).gaps).toEqual([
|
|
177
|
+
{
|
|
178
|
+
token: '--global-typography-label-font-size',
|
|
179
|
+
sizeClass: 'medium',
|
|
180
|
+
kind: 'missing',
|
|
181
|
+
value: undefined,
|
|
182
|
+
sizes: undefined,
|
|
183
|
+
readers: ['b.css', 'c.ts'],
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
token: '--global-typography-title-font-size',
|
|
187
|
+
sizeClass: 'xl',
|
|
188
|
+
kind: 'zero',
|
|
189
|
+
value: '0.0px',
|
|
190
|
+
sizes: undefined,
|
|
191
|
+
readers: ['d.css'],
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
token: '--automation-components-typography-unit-font-size',
|
|
195
|
+
sizeClass: 'xl',
|
|
196
|
+
kind: 'shrinks',
|
|
197
|
+
value: 'var(--font-size-100)',
|
|
198
|
+
sizes: ['16px', '32px'],
|
|
199
|
+
readers: ['e.css'],
|
|
200
|
+
},
|
|
201
|
+
]);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('ignores tokens that do not size text, and tokens no size class declares', () => {
|
|
205
|
+
const {gaps} = rampGaps(
|
|
206
|
+
new Map([
|
|
207
|
+
['--global-typography-value-font-weight', new Set(['a.css'])],
|
|
208
|
+
['--component-local-font-size', new Set(['f.css'])],
|
|
209
|
+
]),
|
|
210
|
+
palette
|
|
211
|
+
);
|
|
212
|
+
expect(gaps).toEqual([]);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('accepts a known gap only in the classes it names', () => {
|
|
216
|
+
const {gaps, stale} = rampGaps(readers, palette, {
|
|
217
|
+
'--global-typography-title-font-size': {
|
|
218
|
+
classes: ['medium', 'xl'],
|
|
219
|
+
reason: 'no XL value yet (#1422)',
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
expect(gaps.map((g) => `${g.token} ${g.sizeClass}`)).not.toContain(
|
|
223
|
+
'--global-typography-title-font-size xl'
|
|
224
|
+
);
|
|
225
|
+
expect(stale).toEqual([
|
|
226
|
+
{
|
|
227
|
+
token: '--global-typography-title-font-size',
|
|
228
|
+
detail: 'it has a value in medium',
|
|
229
|
+
},
|
|
230
|
+
]);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('reports a reader a known gap does not list', () => {
|
|
234
|
+
const {gaps, stale} = rampGaps(readers, palette, {
|
|
235
|
+
'--global-typography-label-font-size': {
|
|
236
|
+
classes: ['medium'],
|
|
237
|
+
readers: ['b.css', 'gone.css'],
|
|
238
|
+
reason: 'b.css reads it by design',
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
expect(
|
|
242
|
+
gaps.find((g) => g.token === '--global-typography-label-font-size')
|
|
243
|
+
?.readers
|
|
244
|
+
).toEqual(['c.ts']);
|
|
245
|
+
expect(stale).toEqual([
|
|
246
|
+
{
|
|
247
|
+
token: '--global-typography-label-font-size',
|
|
248
|
+
detail: 'gone.css no longer reads it',
|
|
249
|
+
},
|
|
250
|
+
]);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('flags an entry for a token nothing reads', () => {
|
|
254
|
+
const {stale} = rampGaps(readers, palette, {
|
|
255
|
+
'--global-typography-unread-font-size': {
|
|
256
|
+
classes: ['xl'],
|
|
257
|
+
reason: 'left over',
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
expect(stale).toEqual([
|
|
261
|
+
{
|
|
262
|
+
token: '--global-typography-unread-font-size',
|
|
263
|
+
detail: 'nothing reads it',
|
|
264
|
+
},
|
|
265
|
+
]);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
@@ -54,10 +54,10 @@ export enum AnalogThreewayValveVariant {
|
|
|
54
54
|
* @property orientation - Side the stem points to.
|
|
55
55
|
* @property flows - Readout rows, one per flow: an optional arrow direction with either a value and optional unit (default `%`) or `open` for an `Open`/`Closed` state.
|
|
56
56
|
* @property variant - Visual style of the button surround.
|
|
57
|
-
* @slot badge-top-right - Content projected into the top-right badge position; overrides `
|
|
58
|
-
* @slot badge-top-left - Content projected into the top-left badge position; overrides `
|
|
59
|
-
* @slot badge-bottom-left - Content projected into the bottom-left badge position; overrides `
|
|
60
|
-
* @slot badge-bottom-right - Content projected into the bottom-right badge position; overrides `
|
|
57
|
+
* @slot badge-top-right - Content projected into the top-right badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
58
|
+
* @slot badge-top-left - Content projected into the top-left badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
59
|
+
* @slot badge-bottom-left - Content projected into the bottom-left badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
60
|
+
* @slot badge-bottom-right - Content projected into the bottom-right badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
61
61
|
* @fires click - Fired when the valve is clicked.
|
|
62
62
|
* @experimental
|
|
63
63
|
*/
|
|
@@ -82,6 +82,14 @@ export const WithBadges: Story = {
|
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
export const WithSimulationBadge: Story = {
|
|
86
|
+
args: {
|
|
87
|
+
open: true,
|
|
88
|
+
value: 20,
|
|
89
|
+
badgeCommandLocked: AutomationButtonBadgeCommandLocked.Simulation,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
85
93
|
export const ClosedWithHandle: Story = {
|
|
86
94
|
args: {
|
|
87
95
|
open: false,
|
|
@@ -36,6 +36,12 @@
|
|
|
36
36
|
height: 100%;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
.letter {
|
|
40
|
+
font-family: var(--global-typography-font-family);
|
|
41
|
+
/* the design outlines the letters at the bold weight */
|
|
42
|
+
font-weight: var(--font-weight-bold);
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
&.flat .badge {
|
|
40
46
|
width: var(--automation-components-badge-new-icon-size-flat);
|
|
41
47
|
height: var(--automation-components-badge-new-icon-size-flat);
|
|
@@ -47,9 +47,35 @@ export const AllVariants: Story = {
|
|
|
47
47
|
<div
|
|
48
48
|
style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;"
|
|
49
49
|
>
|
|
50
|
-
${Object.values(ObcAutomationBadgeType)
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
${Object.values(ObcAutomationBadgeType)
|
|
51
|
+
.filter((type) => !type.startsWith('letter-'))
|
|
52
|
+
.map((type) =>
|
|
53
|
+
Object.values(ObcAutomationBadgeMode).map(
|
|
54
|
+
(mode) => html`
|
|
55
|
+
<obc-automation-badge
|
|
56
|
+
.mode=${mode}
|
|
57
|
+
.type=${type}
|
|
58
|
+
></obc-automation-badge>
|
|
59
|
+
`
|
|
60
|
+
)
|
|
61
|
+
)}
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const Letters: Story = {
|
|
68
|
+
render() {
|
|
69
|
+
const letters = Object.values(ObcAutomationBadgeType).filter((type) =>
|
|
70
|
+
type.startsWith('letter-')
|
|
71
|
+
);
|
|
72
|
+
return html`
|
|
73
|
+
<div
|
|
74
|
+
style="display: grid; grid-template-columns: repeat(${letters.length}, auto); gap: 10px; justify-content: start;"
|
|
75
|
+
>
|
|
76
|
+
${Object.values(ObcAutomationBadgeMode).map((mode) =>
|
|
77
|
+
letters.map(
|
|
78
|
+
(type) => html`
|
|
53
79
|
<obc-automation-badge
|
|
54
80
|
.mode=${mode}
|
|
55
81
|
.type=${type}
|
|
@@ -98,6 +124,24 @@ export const InterlockInhibit: Story = {
|
|
|
98
124
|
},
|
|
99
125
|
};
|
|
100
126
|
|
|
127
|
+
export const AlertShelved: Story = {
|
|
128
|
+
args: {
|
|
129
|
+
type: ObcAutomationBadgeType.AlertShelved,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const Simulation: Story = {
|
|
134
|
+
args: {
|
|
135
|
+
type: ObcAutomationBadgeType.Simulation,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const Letter: Story = {
|
|
140
|
+
args: {
|
|
141
|
+
type: ObcAutomationBadgeType.LetterS,
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
|
|
101
145
|
export const SlottedIcon: Story = {
|
|
102
146
|
render(args) {
|
|
103
147
|
return html`<obc-automation-badge .mode=${args.mode}>
|
|
@@ -4,6 +4,7 @@ import compentStyle from './automation-badge.css?inline';
|
|
|
4
4
|
import {classMap} from 'lit/directives/class-map.js';
|
|
5
5
|
import {customElement} from '../../decorator.js';
|
|
6
6
|
import '../../icons/icon-alert-off-filled.js';
|
|
7
|
+
import '../../icons/icon-alerts-shelf.js';
|
|
7
8
|
import '../../icons/icon-auto.js';
|
|
8
9
|
import '../../icons/icon-manual.js';
|
|
9
10
|
import '../../icons/icon-manual-only.js';
|
|
@@ -29,6 +30,8 @@ export enum ObcAutomationBadgeType {
|
|
|
29
30
|
Interlock = 'interlock',
|
|
30
31
|
InterlockInhibit = 'interlock-inhibit',
|
|
31
32
|
AlertSilenced = 'alert-silenced',
|
|
33
|
+
AlertShelved = 'alert-shelved',
|
|
34
|
+
Simulation = 'simulation',
|
|
32
35
|
Caution = 'caution',
|
|
33
36
|
Warning = 'warning',
|
|
34
37
|
Alarm = 'alarm',
|
|
@@ -37,6 +40,32 @@ export enum ObcAutomationBadgeType {
|
|
|
37
40
|
LevelMedium = 'level-medium',
|
|
38
41
|
LevelLow = 'level-low',
|
|
39
42
|
LevelDiagnostic = 'level-diagnostic',
|
|
43
|
+
LetterA = 'letter-a',
|
|
44
|
+
LetterB = 'letter-b',
|
|
45
|
+
LetterC = 'letter-c',
|
|
46
|
+
LetterD = 'letter-d',
|
|
47
|
+
LetterE = 'letter-e',
|
|
48
|
+
LetterF = 'letter-f',
|
|
49
|
+
LetterG = 'letter-g',
|
|
50
|
+
LetterH = 'letter-h',
|
|
51
|
+
LetterI = 'letter-i',
|
|
52
|
+
LetterJ = 'letter-j',
|
|
53
|
+
LetterK = 'letter-k',
|
|
54
|
+
LetterL = 'letter-l',
|
|
55
|
+
LetterM = 'letter-m',
|
|
56
|
+
LetterN = 'letter-n',
|
|
57
|
+
LetterO = 'letter-o',
|
|
58
|
+
LetterP = 'letter-p',
|
|
59
|
+
LetterQ = 'letter-q',
|
|
60
|
+
LetterR = 'letter-r',
|
|
61
|
+
LetterS = 'letter-s',
|
|
62
|
+
LetterT = 'letter-t',
|
|
63
|
+
LetterU = 'letter-u',
|
|
64
|
+
LetterV = 'letter-v',
|
|
65
|
+
LetterW = 'letter-w',
|
|
66
|
+
LetterX = 'letter-x',
|
|
67
|
+
LetterY = 'letter-y',
|
|
68
|
+
LetterZ = 'letter-z',
|
|
40
69
|
}
|
|
41
70
|
|
|
42
71
|
const ALERT_BADGE_TYPES: ObcAutomationBadgeType[] = [
|
|
@@ -51,6 +80,47 @@ const ALERT_BADGE_TYPES: ObcAutomationBadgeType[] = [
|
|
|
51
80
|
];
|
|
52
81
|
|
|
53
82
|
/**
|
|
83
|
+
* Letter badge geometry in the 16-unit badge box.
|
|
84
|
+
*
|
|
85
|
+
* The design outlines a 15.33 px capital on a 13.33 baseline, so the glyph
|
|
86
|
+
* fills the box the way the icon badges do (Figma 1188:55068).
|
|
87
|
+
*/
|
|
88
|
+
const LETTER_FONT_SIZE = 15.33;
|
|
89
|
+
const LETTER_BASELINE = 13.33;
|
|
90
|
+
|
|
91
|
+
/** The capital a `letter-<x>` type draws, `undefined` for every other type. */
|
|
92
|
+
function badgeLetter(
|
|
93
|
+
type: ObcAutomationBadgeType | undefined
|
|
94
|
+
): string | undefined {
|
|
95
|
+
return type?.match(/^letter-([a-z])$/)?.[1].toUpperCase();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Automation badge: one state glyph in the corner of a device button, tank
|
|
100
|
+
* or tile.
|
|
101
|
+
*
|
|
102
|
+
* ## Features
|
|
103
|
+
*
|
|
104
|
+
* - `type` picks the glyph: control mode (`auto`, `manual`, `manual-only`,
|
|
105
|
+
* `local`, `local-only`), `command-locked`, `interlock`,
|
|
106
|
+
* `interlock-inhibit`, `simulation`, `alert-silenced`, `alert-shelved`,
|
|
107
|
+
* the alert categories (`caution`, `warning`, `alarm`), the alert levels
|
|
108
|
+
* (`level-critical` to `level-diagnostic`) and one capital letter
|
|
109
|
+
* (`letter-a` to `letter-z`).
|
|
110
|
+
* - `mode` picks the surface: `flat` draws the glyph with a silhouette
|
|
111
|
+
* outline straight on the device, `regular` and `enhanced` put it on a
|
|
112
|
+
* bordered or raised chip. Alert categories and levels carry their own
|
|
113
|
+
* colour and render flat whatever the mode.
|
|
114
|
+
* - Without a built-in type the slots take a custom glyph.
|
|
115
|
+
*
|
|
116
|
+
* ## Usage
|
|
117
|
+
*
|
|
118
|
+
* Device buttons and tanks place it through `badgeControl`, `badgeAlert`,
|
|
119
|
+
* `badgeInterlock` and `badgeCommandLocked`; use the element directly for a
|
|
120
|
+
* badge outside those four corners.
|
|
121
|
+
*
|
|
122
|
+
* @property mode - Surface of the badge: `flat`, `regular` or `enhanced`.
|
|
123
|
+
* @property type - Built-in glyph to draw; unset renders the slots.
|
|
54
124
|
* @slot icon-silhouette - Custom silhouette/outline icon, rendered behind the default slot content when no built-in badge type matches.
|
|
55
125
|
* @slot - Default slot for custom badge content, rendered when no built-in badge type matches.
|
|
56
126
|
* @stable
|
|
@@ -138,9 +208,53 @@ export class ObcAutomationBadge extends LitElement {
|
|
|
138
208
|
</svg>`;
|
|
139
209
|
}
|
|
140
210
|
|
|
211
|
+
/** The cube of the simulated badge, as the design draws it (Figma 1188:54997). */
|
|
212
|
+
private renderSimulationIcon(className: string) {
|
|
213
|
+
return html`<svg
|
|
214
|
+
class=${className}
|
|
215
|
+
viewBox="0 0 16 16"
|
|
216
|
+
fill="currentColor"
|
|
217
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
218
|
+
>
|
|
219
|
+
<path
|
|
220
|
+
d="M7.33333 14.4833V8.38333L2 5.3V10.65C2 10.8944 2.05833 11.1167 2.175 11.3167C2.29167 11.5167 2.45555 11.6778 2.66667 11.8L7.33333 14.4833ZM8.66667 14.4833L13.3333 11.8C13.5444 11.6778 13.7083 11.5167 13.825 11.3167C13.9417 11.1167 14 10.8944 14 10.65V5.3L8.66667 8.38333V14.4833Z"
|
|
221
|
+
/>
|
|
222
|
+
<path
|
|
223
|
+
d="M13.2833 4.16667L8.66667 1.51667C8.45556 1.39444 8.23333 1.33333 8 1.33333C7.76667 1.33333 7.54444 1.39444 7.33333 1.51667L2.7 4.18333L8 7.23333L13.2833 4.16667Z"
|
|
224
|
+
/>
|
|
225
|
+
</svg>`;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** A letter badge: one capital of the body font, hidden from assistive technology because the badge draws it twice. */
|
|
229
|
+
private renderLetterIcon(letter: string, className: string) {
|
|
230
|
+
return html`<svg
|
|
231
|
+
class=${className}
|
|
232
|
+
viewBox="0 0 16 16"
|
|
233
|
+
fill="currentColor"
|
|
234
|
+
aria-hidden="true"
|
|
235
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
236
|
+
>
|
|
237
|
+
<text
|
|
238
|
+
class="letter"
|
|
239
|
+
x="8"
|
|
240
|
+
y=${LETTER_BASELINE}
|
|
241
|
+
font-size=${LETTER_FONT_SIZE}
|
|
242
|
+
text-anchor="middle"
|
|
243
|
+
>
|
|
244
|
+
${letter}
|
|
245
|
+
</text>
|
|
246
|
+
</svg>`;
|
|
247
|
+
}
|
|
248
|
+
|
|
141
249
|
// TODO(designer): rename the 'siluette' typo to 'silhouette', in Figma too
|
|
142
250
|
private getIcon() {
|
|
143
|
-
|
|
251
|
+
const letter = badgeLetter(this.type);
|
|
252
|
+
if (letter) {
|
|
253
|
+
return html`${this.renderLetterIcon(
|
|
254
|
+
letter,
|
|
255
|
+
'icon siluette'
|
|
256
|
+
)}${this.renderLetterIcon(letter, 'icon')}`;
|
|
257
|
+
} else if (this.type === ObcAutomationBadgeType.Auto) {
|
|
144
258
|
return html`<obi-auto class="icon siluette"></obi-auto
|
|
145
259
|
><obi-auto class="icon"></obi-auto>`;
|
|
146
260
|
} else if (this.type === ObcAutomationBadgeType.Manual) {
|
|
@@ -171,6 +285,15 @@ export class ObcAutomationBadge extends LitElement {
|
|
|
171
285
|
class="icon siluette"
|
|
172
286
|
></obi-alert-off-filled
|
|
173
287
|
><obi-alert-off-filled class="icon"></obi-alert-off-filled>`;
|
|
288
|
+
} else if (this.type === ObcAutomationBadgeType.AlertShelved) {
|
|
289
|
+
// TODO(designer): the sketch draws shelved as a diamond with a plus and
|
|
290
|
+
// the alert counter uses a timer; this badge keeps alerts-shelf (#1424)
|
|
291
|
+
return html`<obi-alerts-shelf class="icon siluette"></obi-alerts-shelf
|
|
292
|
+
><obi-alerts-shelf class="icon"></obi-alerts-shelf>`;
|
|
293
|
+
} else if (this.type === ObcAutomationBadgeType.Simulation) {
|
|
294
|
+
return html`${this.renderSimulationIcon(
|
|
295
|
+
'icon siluette'
|
|
296
|
+
)}${this.renderSimulationIcon('icon')}`;
|
|
174
297
|
} else if (this.type === ObcAutomationBadgeType.LevelCritical) {
|
|
175
298
|
return this.renderLevelCriticalIcon(
|
|
176
299
|
this.effectiveMode === ObcAutomationBadgeMode.Flat
|
|
@@ -47,6 +47,9 @@ export const argTypesAbstractAutomationButton = {
|
|
|
47
47
|
options: Object.values(AutomationButtonBadgeAlert),
|
|
48
48
|
control: {type: 'select'},
|
|
49
49
|
},
|
|
50
|
+
badgeLayout: {
|
|
51
|
+
control: {type: 'object'},
|
|
52
|
+
},
|
|
50
53
|
progressMode: {
|
|
51
54
|
options: Object.values(CircularProgressMode),
|
|
52
55
|
control: {type: 'select'},
|