@tekkare/romulus 0.1.11 → 0.1.13

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.
@@ -90,6 +90,16 @@ export function rmBaseOption(theme, decal = false) {
90
90
  }
91
91
  };
92
92
  }
93
+ const valueAxis = (theme, label) => ({
94
+ type: "value",
95
+ name: label,
96
+ nameLocation: "end",
97
+ nameGap: 12,
98
+ nameTextStyle: { fontSize: 10, color: theme.dimmedColor, fontFamily: FONT, align: "left" },
99
+ axisLabel: { fontSize: 11, color: theme.mutedColor, fontFamily: FONT },
100
+ axisLine: { lineStyle: { color: theme.axisLine } },
101
+ splitLine: { lineStyle: { color: theme.splitLine } }
102
+ });
93
103
  const axisCommon = (theme) => ({
94
104
  axisLabel: { fontSize: 11, color: theme.mutedColor, fontFamily: FONT },
95
105
  axisLine: { lineStyle: { color: theme.axisLine } },
@@ -135,17 +145,27 @@ export function rmBarHorizontalOption(labels, values, theme, palette, decal = fa
135
145
  };
136
146
  }
137
147
  export function rmLineOption(categories, series, theme, palette, options = {}) {
138
- const { area = false, step = false, smooth = true, decal = false } = options;
148
+ const { area = false, step = false, smooth = true, decal = false, axisLabels } = options;
149
+ const dual = series.some((s) => s.axis === 1);
139
150
  return {
140
151
  ...rmBaseOption(theme, decal),
141
- legend: series.length > 1 ? { top: 0, textStyle: { color: theme.mutedColor, fontSize: 11, fontFamily: FONT } } : void 0,
152
+ // Legende obligatoire en double axe : sans elle, rien ne dit quelle courbe
153
+ // se lit sur quel axe.
154
+ legend: series.length > 1 || dual ? { top: 0, textStyle: { color: theme.mutedColor, fontSize: 11, fontFamily: FONT } } : void 0,
155
+ grid: { left: 48, right: dual ? 56 : 16, top: dual ? 40 : 24, bottom: 36, containLabel: true },
142
156
  xAxis: { type: "category", data: categories, ...axisCommon(theme), splitLine: { show: false }, boundaryGap: false },
143
- yAxis: { type: "value", ...axisCommon(theme) },
157
+ yAxis: dual ? [
158
+ valueAxis(theme, axisLabels?.[0]),
159
+ // Le second axe ne rejoue pas la grille : deux grilles superposees
160
+ // rendent le fond illisible.
161
+ { ...valueAxis(theme, axisLabels?.[1]), splitLine: { show: false } }
162
+ ] : valueAxis(theme, axisLabels?.[0]),
144
163
  series: series.map((s, i) => {
145
164
  const color = s.color ?? palette[i % palette.length];
146
165
  return {
147
166
  type: "line",
148
167
  name: s.name,
168
+ yAxisIndex: dual ? s.axis ?? 0 : void 0,
149
169
  data: s.data,
150
170
  smooth: step ? false : smooth,
151
171
  step: step ? "end" : void 0,
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Applique un changement d'etat sans transition.
3
+ *
4
+ * Chrome ne reevalue pas une propriete sous `transition` quand sa valeur vient
5
+ * d'un `var()` modifie par un changement de classe sur un ancetre. La
6
+ * propriete garde son ancienne valeur indefiniment, pas seulement le temps de
7
+ * l'animation. Deux cas verifies dans ce paquet :
8
+ *
9
+ * - `border-color: var(--border-default)` sur `.chart-card` : 2,5 s apres le
10
+ * passage en mode nuit, la bordure affichait encore la couleur du jour ;
11
+ * - `width: var(--sidebar-w)` sur `.sidebar` : le token passait bien a 333px
12
+ * et la largeur calculee restait a 220px. Replier la barre laterale ne
13
+ * faisait donc rien du tout.
14
+ *
15
+ * On neutralise les transitions, on applique le changement, on force un
16
+ * recalcul de style synchrone, puis on les reactive. Tout est synchrone
17
+ * volontairement : une version a base de `requestAnimationFrame` ne fonctionne
18
+ * pas dans un onglet en arriere-plan, ou aucune frame n'est produite. Teste
19
+ * dans un panneau masque : la bascule n'avait alors aucun effet.
20
+ *
21
+ * Consequence assumee : la bascule est instantanee, sans animation. Une
22
+ * transition qui n'aboutit pas vaut moins qu'un etat correct.
23
+ */
24
+ export declare function rmWithoutTransitions(mutate: () => void): void;
@@ -0,0 +1,14 @@
1
+ export function rmWithoutTransitions(mutate) {
2
+ if (typeof document === "undefined") {
3
+ mutate();
4
+ return;
5
+ }
6
+ const { body } = document;
7
+ body.classList.add("rm-switching");
8
+ try {
9
+ mutate();
10
+ void body.offsetWidth;
11
+ } finally {
12
+ body.classList.remove("rm-switching");
13
+ }
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",