@aiaiai-pt/design-system 0.54.0 → 0.55.1
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/components/EChart.svelte +26 -0
- package/components/EChart.svelte.d.ts +22 -0
- package/components/KpiRegister.svelte +1 -1
- package/components/KpiRegister.svelte.d.ts +1 -1
- package/components/SealChip.svelte +4 -4
- package/components/SealChip.svelte.d.ts +3 -3
- package/components/renderer/aggregate.d.ts +3 -0
- package/components/renderer/aggregate.ts +3 -0
- package/components/renderer/chart-option.d.ts +7 -0
- package/components/renderer/chart-option.ts +44 -16
- package/package.json +2 -1
- package/tokens/themes/ubp.css +5 -5
package/components/EChart.svelte
CHANGED
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
The canvas draws it in `--chart-band-bg`; the table marks the same rows with
|
|
31
31
|
`data-band` and the band's label, so it is never encoded only in pixels.
|
|
32
32
|
|
|
33
|
+
A series with `tone: "muted"` draws in the secondary text colour, behind the
|
|
34
|
+
accent series, and leaves the accent ramp to the others. `yCeiling` and
|
|
35
|
+
`ySecondaryCeiling` make an axis reach at least that value (larger data still
|
|
36
|
+
extends it), so small values look small: 3 mm of rain on a 20 mm scale.
|
|
37
|
+
|
|
33
38
|
@example
|
|
34
39
|
<EChart
|
|
35
40
|
caption="Reports by status"
|
|
@@ -50,6 +55,19 @@
|
|
|
50
55
|
series={[{ name: "High °C", type: "line", data: [24, 25, 23, 22] }]}
|
|
51
56
|
band={{ from: "2 Oct", to: "3 Oct", label: "Stay" }}
|
|
52
57
|
/>
|
|
58
|
+
@example Quiet rain bars under temperature lines
|
|
59
|
+
<EChart
|
|
60
|
+
caption="Usual weather"
|
|
61
|
+
labelHeader="Day"
|
|
62
|
+
category={["1 Oct", "2 Oct", "3 Oct"]}
|
|
63
|
+
series={[
|
|
64
|
+
{ name: "High °C", type: "line", data: [24, 25, 23] },
|
|
65
|
+
{ name: "Rain mm", type: "bar", axis: "secondary", tone: "muted", data: [1, 9, 2] },
|
|
66
|
+
]}
|
|
67
|
+
ySecondary
|
|
68
|
+
ySecondaryCeiling={20}
|
|
69
|
+
legend
|
|
70
|
+
/>
|
|
53
71
|
-->
|
|
54
72
|
<script module>
|
|
55
73
|
/**
|
|
@@ -79,6 +97,10 @@
|
|
|
79
97
|
innerRadius = 0,
|
|
80
98
|
/** @type {ChartBand | undefined} Shade a run of categories, inclusive. */
|
|
81
99
|
band = undefined,
|
|
100
|
+
/** @type {number | undefined} The primary axis reaches at least this value. */
|
|
101
|
+
yCeiling = undefined,
|
|
102
|
+
/** @type {number | undefined} The secondary axis reaches at least this value. */
|
|
103
|
+
ySecondaryCeiling = undefined,
|
|
82
104
|
/** @type {ChartItem[]} BACK-COMPAT: single-series `{label,value}` rows. */
|
|
83
105
|
items = [],
|
|
84
106
|
/** @type {"bar" | "line" | "donut"} BACK-COMPAT: legacy single-series kind. */
|
|
@@ -175,6 +197,8 @@
|
|
|
175
197
|
ySecondary,
|
|
176
198
|
innerRadius: effInnerRadius,
|
|
177
199
|
band,
|
|
200
|
+
yCeiling,
|
|
201
|
+
ySecondaryCeiling,
|
|
178
202
|
});
|
|
179
203
|
}
|
|
180
204
|
|
|
@@ -253,6 +277,8 @@
|
|
|
253
277
|
void ySecondary;
|
|
254
278
|
void effInnerRadius;
|
|
255
279
|
void band;
|
|
280
|
+
void yCeiling;
|
|
281
|
+
void ySecondaryCeiling;
|
|
256
282
|
if (_chart) _chart.setOption(buildOption(), true);
|
|
257
283
|
});
|
|
258
284
|
</script>
|
|
@@ -42,6 +42,11 @@ type EChart = {
|
|
|
42
42
|
* The canvas draws it in `--chart-band-bg`; the table marks the same rows with
|
|
43
43
|
* `data-band` and the band's label, so it is never encoded only in pixels.
|
|
44
44
|
*
|
|
45
|
+
* A series with `tone: "muted"` draws in the secondary text colour, behind the
|
|
46
|
+
* accent series, and leaves the accent ramp to the others. `yCeiling` and
|
|
47
|
+
* `ySecondaryCeiling` make an axis reach at least that value (larger data still
|
|
48
|
+
* extends it), so small values look small: 3 mm of rain on a 20 mm scale.
|
|
49
|
+
*
|
|
45
50
|
* @example
|
|
46
51
|
* <EChart
|
|
47
52
|
* caption="Reports by status"
|
|
@@ -62,6 +67,19 @@ type EChart = {
|
|
|
62
67
|
* series={[{ name: "High °C", type: "line", data: [24, 25, 23, 22] }]}
|
|
63
68
|
* band={{ from: "2 Oct", to: "3 Oct", label: "Stay" }}
|
|
64
69
|
* />
|
|
70
|
+
* @example Quiet rain bars under temperature lines
|
|
71
|
+
* <EChart
|
|
72
|
+
* caption="Usual weather"
|
|
73
|
+
* labelHeader="Day"
|
|
74
|
+
* category={["1 Oct", "2 Oct", "3 Oct"]}
|
|
75
|
+
* series={[
|
|
76
|
+
* { name: "High °C", type: "line", data: [24, 25, 23] },
|
|
77
|
+
* { name: "Rain mm", type: "bar", axis: "secondary", tone: "muted", data: [1, 9, 2] },
|
|
78
|
+
* ]}
|
|
79
|
+
* ySecondary
|
|
80
|
+
* ySecondaryCeiling={20}
|
|
81
|
+
* legend
|
|
82
|
+
* />
|
|
65
83
|
*/
|
|
66
84
|
declare const EChart: import("svelte").Component<{
|
|
67
85
|
category?: any[];
|
|
@@ -71,6 +89,8 @@ declare const EChart: import("svelte").Component<{
|
|
|
71
89
|
ySecondary?: boolean;
|
|
72
90
|
innerRadius?: number;
|
|
73
91
|
band?: any;
|
|
92
|
+
yCeiling?: any;
|
|
93
|
+
ySecondaryCeiling?: any;
|
|
74
94
|
items?: any[];
|
|
75
95
|
kind?: string;
|
|
76
96
|
caption?: string;
|
|
@@ -88,6 +108,8 @@ type $$ComponentProps = {
|
|
|
88
108
|
ySecondary?: boolean;
|
|
89
109
|
innerRadius?: number;
|
|
90
110
|
band?: any;
|
|
111
|
+
yCeiling?: any;
|
|
112
|
+
ySecondaryCeiling?: any;
|
|
91
113
|
items?: any[];
|
|
92
114
|
kind?: string;
|
|
93
115
|
caption?: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@component KpiRegister
|
|
3
3
|
|
|
4
4
|
The two-register composition for one KPI: the more authoritative value above,
|
|
5
|
-
the less authoritative beneath. It is where "
|
|
5
|
+
the less authoritative beneath. It is where "a reading out-ranks a forecast"
|
|
6
6
|
becomes concrete — in type SIZE, in POSITION, and in SCREEN-READER READING
|
|
7
7
|
ORDER, all three.
|
|
8
8
|
|
|
@@ -7,7 +7,7 @@ type KpiRegister = {
|
|
|
7
7
|
* KpiRegister
|
|
8
8
|
*
|
|
9
9
|
* The two-register composition for one KPI: the more authoritative value above,
|
|
10
|
-
* the less authoritative beneath. It is where "
|
|
10
|
+
* the less authoritative beneath. It is where "a reading out-ranks a forecast"
|
|
11
11
|
* becomes concrete — in type SIZE, in POSITION, and in SCREEN-READER READING
|
|
12
12
|
* ORDER, all three.
|
|
13
13
|
*
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
H1 Slice 2 — westeuropeco/atelier-urban-workspace#57.
|
|
29
29
|
|
|
30
30
|
@example A reading, using whatever terms the deployment declares
|
|
31
|
-
<SealChip value="+14 cm/h" evidence={{ value: '
|
|
31
|
+
<SealChip value="+14 cm/h" evidence={{ value: 'term-a', label: 'leitura', tone: 'positive' }} />
|
|
32
32
|
|
|
33
33
|
@example Both axes, horizon passed, why one tap away
|
|
34
34
|
<SealChip
|
|
35
35
|
value="2,1 m"
|
|
36
|
-
evidence={{ value: '
|
|
37
|
-
probability={{ value: '
|
|
36
|
+
evidence={{ value: 'term-b', label: 'modelo', tone: 'info' }}
|
|
37
|
+
probability={{ value: 'rung-c', label: 'grau-c' }}
|
|
38
38
|
stale
|
|
39
39
|
why="the 16:00 window has already passed"
|
|
40
40
|
/>
|
|
@@ -250,7 +250,7 @@
|
|
|
250
250
|
|
|
251
251
|
/*
|
|
252
252
|
* TONES — the presentation scale the design system owns. Which declared term
|
|
253
|
-
* wears which tone is data, declared beside the word and never
|
|
253
|
+
* wears which tone is data, declared beside the word and never guessed from
|
|
254
254
|
* it, so these rules carry no vocabulary.
|
|
255
255
|
*/
|
|
256
256
|
.seal-tone-positive {
|
|
@@ -33,13 +33,13 @@ type SealChip = {
|
|
|
33
33
|
* H1 Slice 2 — westeuropeco/atelier-urban-workspace#57.
|
|
34
34
|
*
|
|
35
35
|
* @example A reading, using whatever terms the deployment declares
|
|
36
|
-
* <SealChip value="+14 cm/h" evidence={{ value: '
|
|
36
|
+
* <SealChip value="+14 cm/h" evidence={{ value: 'term-a', label: 'leitura', tone: 'positive' }} />
|
|
37
37
|
*
|
|
38
38
|
* @example Both axes, horizon passed, why one tap away
|
|
39
39
|
* <SealChip
|
|
40
40
|
* value="2,1 m"
|
|
41
|
-
* evidence={{ value: '
|
|
42
|
-
* probability={{ value: '
|
|
41
|
+
* evidence={{ value: 'term-b', label: 'modelo', tone: 'info' }}
|
|
42
|
+
* probability={{ value: 'rung-c', label: 'grau-c' }}
|
|
43
43
|
* stale
|
|
44
44
|
* why="the 16:00 window has already passed"
|
|
45
45
|
* />
|
|
@@ -81,6 +81,9 @@ export interface SeriesData {
|
|
|
81
81
|
data: number[];
|
|
82
82
|
stack?: string;
|
|
83
83
|
axis?: "primary" | "secondary";
|
|
84
|
+
/** `muted` draws the series in the secondary text colour, behind the accent
|
|
85
|
+
* series (rain bars under temperature lines). Default `accent`. */
|
|
86
|
+
tone?: "accent" | "muted";
|
|
84
87
|
}
|
|
85
88
|
/** The shape `EChart` / `ResultsChart` render: aligned category + series. */
|
|
86
89
|
export interface ChartData {
|
|
@@ -147,6 +147,9 @@ export interface SeriesData {
|
|
|
147
147
|
data: number[];
|
|
148
148
|
stack?: string;
|
|
149
149
|
axis?: "primary" | "secondary";
|
|
150
|
+
/** `muted` draws the series in the secondary text colour, behind the accent
|
|
151
|
+
* series (rain bars under temperature lines). Default `accent`. */
|
|
152
|
+
tone?: "accent" | "muted";
|
|
150
153
|
}
|
|
151
154
|
|
|
152
155
|
/** The shape `EChart` / `ResultsChart` render: aligned category + series. */
|
|
@@ -53,6 +53,11 @@ export interface BuildChartOptionOpts {
|
|
|
53
53
|
innerRadius?: number;
|
|
54
54
|
/** Shade a run of categories (cartesian charts only). */
|
|
55
55
|
band?: ChartBand;
|
|
56
|
+
/** The primary value axis reaches at least this value; larger data extends it.
|
|
57
|
+
* Keeps small values looking small (3 mm of rain on a 20 mm scale). */
|
|
58
|
+
yCeiling?: number;
|
|
59
|
+
/** The same, for the secondary value axis. */
|
|
60
|
+
ySecondaryCeiling?: number;
|
|
56
61
|
}
|
|
57
62
|
/**
|
|
58
63
|
* Per-series / per-slice colour: an alpha ramp off the accent so N series stay
|
|
@@ -60,6 +65,8 @@ export interface BuildChartOptionOpts {
|
|
|
60
65
|
* it in the live colour space, so it re-themes with the tokens.
|
|
61
66
|
*/
|
|
62
67
|
export declare function seriesColor(accent: string, i: number): string;
|
|
68
|
+
/** A muted series: the secondary text colour, light enough to sit behind the accent. */
|
|
69
|
+
export declare function mutedColor(textSecondary: string): string;
|
|
63
70
|
/** Index range of a band's rows in the category order, or null. */
|
|
64
71
|
export declare function bandRows(category: ReadonlyArray<string>, band: ChartBand | undefined): [number, number] | null;
|
|
65
72
|
/**
|
|
@@ -57,6 +57,11 @@ export interface BuildChartOptionOpts {
|
|
|
57
57
|
innerRadius?: number;
|
|
58
58
|
/** Shade a run of categories (cartesian charts only). */
|
|
59
59
|
band?: ChartBand;
|
|
60
|
+
/** The primary value axis reaches at least this value; larger data extends it.
|
|
61
|
+
* Keeps small values looking small (3 mm of rain on a 20 mm scale). */
|
|
62
|
+
yCeiling?: number;
|
|
63
|
+
/** The same, for the secondary value axis. */
|
|
64
|
+
ySecondaryCeiling?: number;
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
/** Token-driven tooltip chrome — ECharts defaults to a white panel that
|
|
@@ -109,7 +114,13 @@ function buildPieOption(
|
|
|
109
114
|
`${p.name}: ${fmt(p.value)} (${p.percent}%)`,
|
|
110
115
|
},
|
|
111
116
|
...(opts.legend
|
|
112
|
-
? {
|
|
117
|
+
? {
|
|
118
|
+
legend: {
|
|
119
|
+
show: true,
|
|
120
|
+
top: 0,
|
|
121
|
+
textStyle: { color: tokens.textPrimary },
|
|
122
|
+
},
|
|
123
|
+
}
|
|
113
124
|
: {}),
|
|
114
125
|
color: palette,
|
|
115
126
|
series: [
|
|
@@ -127,7 +138,12 @@ function buildPieOption(
|
|
|
127
138
|
};
|
|
128
139
|
}
|
|
129
140
|
|
|
130
|
-
/**
|
|
141
|
+
/** A muted series: the secondary text colour, light enough to sit behind the accent. */
|
|
142
|
+
export function mutedColor(textSecondary: string): string {
|
|
143
|
+
return `color-mix(in srgb, ${textSecondary} 35%, transparent)`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Map one shaped series → its ECharts series object. `i` counts accent series only. */
|
|
131
147
|
function toEchartsSeries(
|
|
132
148
|
s: SeriesData,
|
|
133
149
|
i: number,
|
|
@@ -135,7 +151,10 @@ function toEchartsSeries(
|
|
|
135
151
|
): Record<string, unknown> {
|
|
136
152
|
const { tokens, orientation, ySecondary } = opts;
|
|
137
153
|
const horizontal = orientation === "horizontal";
|
|
138
|
-
const color =
|
|
154
|
+
const color =
|
|
155
|
+
s.tone === "muted"
|
|
156
|
+
? mutedColor(tokens.textSecondary)
|
|
157
|
+
: seriesColor(tokens.accent, i);
|
|
139
158
|
// The value dimension is y for vertical charts, x for horizontal.
|
|
140
159
|
const axisKey = horizontal ? "xAxisIndex" : "yAxisIndex";
|
|
141
160
|
const axisIndex = s.axis === "secondary" && ySecondary ? 1 : 0;
|
|
@@ -195,8 +214,7 @@ function bandArea(
|
|
|
195
214
|
silent: true,
|
|
196
215
|
itemStyle: {
|
|
197
216
|
color:
|
|
198
|
-
tokens.band ||
|
|
199
|
-
`color-mix(in srgb, ${tokens.accent} 16%, transparent)`,
|
|
217
|
+
tokens.band || `color-mix(in srgb, ${tokens.accent} 16%, transparent)`,
|
|
200
218
|
},
|
|
201
219
|
label: {
|
|
202
220
|
show: Boolean(band.label),
|
|
@@ -244,22 +262,32 @@ function buildCartesianOption(
|
|
|
244
262
|
axisTick: { show: false },
|
|
245
263
|
};
|
|
246
264
|
|
|
247
|
-
const valueAxis = (secondary: boolean) =>
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
265
|
+
const valueAxis = (secondary: boolean) => {
|
|
266
|
+
const ceiling = secondary ? opts.ySecondaryCeiling : opts.yCeiling;
|
|
267
|
+
return {
|
|
268
|
+
type: "value" as const,
|
|
269
|
+
...(ceiling === undefined
|
|
270
|
+
? {}
|
|
271
|
+
: { max: (extent: { max: number }) => Math.max(extent.max, ceiling) }),
|
|
272
|
+
axisLabel: {
|
|
273
|
+
color: tokens.textSecondary,
|
|
274
|
+
formatter: (v: number) => fmt(v),
|
|
275
|
+
},
|
|
276
|
+
axisLine: { lineStyle: { color: tokens.border } },
|
|
277
|
+
// Hide the 2nd axis' grid lines to avoid a double grid.
|
|
278
|
+
splitLine: { show: !secondary, lineStyle: { color: tokens.border } },
|
|
279
|
+
};
|
|
280
|
+
};
|
|
257
281
|
|
|
258
282
|
const valueAxes = ySecondary
|
|
259
283
|
? [valueAxis(false), valueAxis(true)]
|
|
260
284
|
: [valueAxis(false)];
|
|
261
285
|
|
|
262
|
-
|
|
286
|
+
// The accent ramp counts accent series only, so a muted one does not fade the rest.
|
|
287
|
+
let accentIndex = 0;
|
|
288
|
+
const echSeries = series.map((s) =>
|
|
289
|
+
toEchartsSeries(s, s.tone === "muted" ? 0 : accentIndex++, opts),
|
|
290
|
+
);
|
|
263
291
|
const area = bandArea(category, opts);
|
|
264
292
|
if (area && echSeries[0]) echSeries[0].markArea = area;
|
|
265
293
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiaiai-pt/design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.1",
|
|
4
4
|
"description": "Design system tokens and Svelte components for aiaiai products",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -136,6 +136,7 @@
|
|
|
136
136
|
"@codemirror/view": "^6.40.0",
|
|
137
137
|
"@lezer/highlight": "^1.0.0",
|
|
138
138
|
"@sveltejs/package": "^2.5.7",
|
|
139
|
+
"axe-core": "^4.14.0",
|
|
139
140
|
"date-fns": "^4.1.0",
|
|
140
141
|
"echarts": "^6.1.0",
|
|
141
142
|
"jsdom": "^29.1.1",
|
package/tokens/themes/ubp.css
CHANGED
|
@@ -147,8 +147,8 @@
|
|
|
147
147
|
on their respective subtle backgrounds.
|
|
148
148
|
|
|
149
149
|
Contrast on subtle backgrounds (AA = 4.5:1 for small badge text):
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
positive #256f20 (green-700) on #f0fdf4 (success-subtle): ~5.46:1 [AA]
|
|
151
|
+
caution #9e6308 (amber-700) on #fffbeb (warning-subtle): ~4.79:1 [AA]
|
|
152
152
|
--seal-info-text inherits --color-info (#2e63a3): 5.66:1 on
|
|
153
153
|
info-subtle (#f0f5fa) — no override needed.
|
|
154
154
|
--seal-stale-text inherits --color-text-muted (≥3.0:1 non-essential).
|
|
@@ -249,9 +249,9 @@
|
|
|
249
249
|
coverage-gap note) — visual QA is the complement.
|
|
250
250
|
|
|
251
251
|
Contrast on steel-900 (#0b182a, lum ≈ 0.0082):
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
positive #4ade80 (green-400) lum ≈ 0.403 → ~7.76:1 [AAA]
|
|
253
|
+
info #60a5fa (blue-400) lum ≈ 0.386 → ~7.49:1 [AAA]
|
|
254
|
+
caution #fbbf24 (amber-400) lum ≈ 0.598 → ~11.14:1 [AAA]
|
|
255
255
|
stale inherits --seal-stale-text: var(--color-text-muted) = #60758a (3.74:1)
|
|
256
256
|
═══════════════════════════════════════════════════════════════ */
|
|
257
257
|
--seal-positive-text: #4ade80;
|