@massimo-cassandro/minimo 1.41.8 → 1.41.10

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.
@@ -5,14 +5,14 @@ export default {
5
5
  $type: 'dimension'
6
6
  }
7
7
  },
8
- grid: {
9
- cols: {
10
- $value: 3,
11
- $type: 'number'
12
- },
13
- 'min-col-width': {
14
- $value: '6rem',
15
- $type: 'dimension'
16
- }
17
- }
8
+ // grid: {
9
+ // cols: {
10
+ // $value: 3,
11
+ // $type: 'number'
12
+ // },
13
+ // 'min-col-width': {
14
+ // $value: '6rem',
15
+ // $type: 'dimension'
16
+ // }
17
+ // }
18
18
  };
@@ -83,7 +83,7 @@ export const buildSourceModes = async ({
83
83
  // Legge il destFile preesistente (se c'è) PRIMA che venga eseguita qualsiasi istanza
84
84
  // di Style Dictionary, dato che la prima a scrivere lo sovrascriverebbe.
85
85
  if (mergeCustomProps) {
86
- loadExistingCustomPropsScoped(path.join(buildPath, destFile), baseMode, mergeCustomProps, customPropsSelector);
86
+ loadExistingCustomPropsScoped(path.join(buildPath, destFile), baseMode, mergeCustomProps, customPropsSelector, modeNames);
87
87
  }
88
88
 
89
89
  const cssTransforms = pxToRem
@@ -24,7 +24,9 @@
24
24
  `color-scheme` effettivo, indipendentemente dal fatto che la dichiarazione stessa
25
25
  si trovi dentro una regola `@media (prefers-color-scheme: ...)` o meno.
26
26
 
27
- Interazione con `mergeCustomProps`: qui non serve nulla di speciale — il merge
27
+ Interazione con `mergeCustomProps`: le dichiarazioni preesistenti `light-dark(X, Y)` vengono
28
+ scomposte in X (light) e Y (dark) già in fase di lettura (vedi loadExistingCustomPropsScoped()
29
+ in ../merge-css.mjs), così da non essere ricombinate annidate. Per il resto il merge
28
30
  per modalità con le custom properties preesistenti (vedi ../merge-css.mjs)
29
31
  viene già eseguito prima, dentro computeFinalProps() (formats/css.mjs), prima che
30
32
  questo modulo veda le proprietà. Quindi un file preesistente scritto con la
@@ -205,6 +205,41 @@ export const loadExistingCustomProps = (absDestPath, sources = true) => {
205
205
  return existingCustomProps;
206
206
  };
207
207
 
208
+ /*
209
+ Se la coda di una dichiarazione (valore + `;` + eventuale commento finale) è interamente
210
+ una chiamata `light-dark(X, Y)`, restituisce le due metà con il commento finale; altrimenti
211
+ null. La virgola di primo livello è individuata contando la profondità delle parentesi,
212
+ così che argomenti come `var(--a, red)` non vengano spezzati.
213
+ */
214
+ /** @param {string} tail @returns {{light:string, dark:string}|null} */
215
+ const splitLightDarkTail = (tail) => {
216
+ const match = /^light-dark\(/.exec(tail);
217
+ if (!match) return null;
218
+ let depth = 0;
219
+ let commaIdx = -1;
220
+ let closeIdx = -1;
221
+ for (let i = match[0].length - 1; i < tail.length; i++) {
222
+ const ch = tail[i];
223
+ if (ch === '(') depth++;
224
+ else if (ch === ')') {
225
+ depth--;
226
+ if (depth === 0) { closeIdx = i; break; }
227
+ } else if (ch === ',' && depth === 1) {
228
+ if (commaIdx !== -1) return null;
229
+ commaIdx = i;
230
+ }
231
+ }
232
+ if (commaIdx === -1 || closeIdx === -1) return null;
233
+ const rest = tail.slice(closeIdx + 1);
234
+ if (!/^\s*;\s*(\/\*.*\*\/)?\s*$/.test(rest)) return null;
235
+ const suffix = rest.trim();
236
+ const open = match[0].length;
237
+ return {
238
+ light: `${tail.slice(open, commaIdx).trim()}${suffix}`,
239
+ dark: `${tail.slice(commaIdx + 1, closeIdx).trim()}${suffix}`,
240
+ };
241
+ };
242
+
208
243
  /**
209
244
  * Equivalente sourceModes di loadExistingCustomProps(): legge il file CSS di
210
245
  * destinazione (se esiste) e memorizza una mappa nome → valore per modalità,
@@ -217,9 +252,12 @@ export const loadExistingCustomProps = (absDestPath, sources = true) => {
217
252
  * array solo i file sorgente dei token corrispondenti a una delle sue voci (default: true)
218
253
  * @param {string} [selector] il customPropsSelector con cui è stato generato il file
219
254
  * preesistente (default: ':root' — vedi config.mjs)
255
+ * @param {string[]} [modeNames] chiavi di sourceModes: se includono sia `light` sia `dark`, le
256
+ * dichiarazioni preesistenti `light-dark(X, Y)` vengono scomposte in X (light) e Y (dark),
257
+ * per evitare che vengano ricombinate annidate (default: [])
220
258
  * @returns {Record<string, Record<string,string>>|null}
221
259
  */
222
- export const loadExistingCustomPropsScoped = (absDestPath, baseMode, sources = true, selector = ':root') => {
260
+ export const loadExistingCustomPropsScoped = (absDestPath, baseMode, sources = true, selector = ':root', modeNames = []) => {
223
261
  mergeSources = sources;
224
262
  if (!existsSync(absDestPath)) {
225
263
  scopedExistingCustomProps = null;
@@ -234,6 +272,24 @@ export const loadExistingCustomPropsScoped = (absDestPath, baseMode, sources = t
234
272
  if (mode === '__base__') continue;
235
273
  scopedExistingCustomProps[mode] = parseCustomProps(body);
236
274
  }
275
+
276
+ if (modeNames.includes('light') && modeNames.includes('dark')) {
277
+ const baseProps = scopedExistingCustomProps[baseMode] ?? {};
278
+ for (const [name, tail] of Object.entries(baseProps)) {
279
+ const halves = splitLightDarkTail(tail);
280
+ if (!halves) continue;
281
+ scopedExistingCustomProps.light ??= {};
282
+ scopedExistingCustomProps.dark ??= {};
283
+ // una voce esplicita già presente nel blocco della modalità ha la precedenza
284
+ scopedExistingCustomProps.light[name] ??= halves.light;
285
+ scopedExistingCustomProps.dark[name] ??= halves.dark;
286
+ // se la base è light/dark, la voce è stata appena riassegnata sopra: va comunque
287
+ // allineata alla propria metà
288
+ if (baseMode === 'light') scopedExistingCustomProps.light[name] = halves.light;
289
+ else if (baseMode === 'dark') scopedExistingCustomProps.dark[name] = halves.dark;
290
+ else delete baseProps[name];
291
+ }
292
+ }
237
293
  return scopedExistingCustomProps;
238
294
  };
239
295
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "1.41.8",
3
+ "version": "1.41.10",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/src/css/grid.css CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  .grid {
4
4
  --_cols: 1;
5
- /* --_min-col-width: calc((100% - calc(var(--_cols) * var(--flex-grid-gap))) / var(--grid-cols)); */
5
+ /* --_min-col-width: calc((100% - calc(var(--_cols) * var(--flex-grid-gap))) / var(--grid-cols)); NB custom prop rimossa */
6
6
 
7
7
  display: grid;
8
- /* grid-template-columns: repeat(var(--_cols), minmax(var(--grid-min-col-width), 1fr)); */
8
+ /* grid-template-columns: repeat(var(--_cols), minmax(var(--grid-min-col-width), 1fr)); NB custom prop rimossa */
9
9
  grid-template-columns: repeat(var(--_cols), minmax(0, 1fr));
10
10
  grid-auto-flow: row;
11
11
  gap: var(--flex-grid-gap);
@@ -1,6 +1,7 @@
1
1
 
2
2
  h1, h2, h3, .h3, h4, .h4 {
3
- line-height: 1.2;
3
+ font-family: var(--headings-font-family);
4
+ line-height: var(--headings-font-weight);
4
5
  color: var(--headings-color);
5
6
  text-align: var(--headings-text-align);
6
7
  }
@@ -21,7 +21,7 @@ tablet alt:
21
21
  53.75rem : 860px medium (tablet)
22
22
  */
23
23
 
24
- /* @custom-media --media-xxlarge-viewport-up (width >= 90rem); */
24
+ @custom-media --media-xxlarge-viewport-up (width >= 90rem);
25
25
  @custom-media --media-xlarge-viewport-up (width >= 80rem);
26
26
  @custom-media --media-large-viewport-up (width >= 64rem);
27
27
  @custom-media --media-medium-viewport-up (width >= 47.5rem);
@@ -37,4 +37,4 @@ tablet alt:
37
37
  @custom-media --media-xlarge-viewport-down (max-width: 80rem);
38
38
  @custom-media --media-large-viewport-down (max-width: 64rem);
39
39
  @custom-media --media-medium-viewport-down (max-width: 47.5rem);
40
- /* @custom-media --media-small-viewport-down (max-width: 25rem); */
40
+ @custom-media --media-small-viewport-down (max-width: 25rem);
@@ -205,9 +205,6 @@
205
205
  --form-validation-outline-offset: -3px;
206
206
  --form-validation-outline-width: 3px;
207
207
 
208
- --grid-cols: 3;
209
- --grid-min-col-width: 6rem;
210
-
211
208
  --headings-color: var(--text-color);
212
209
  --headings-font-family: var(--font-family);
213
210
  --headings-font-weight: var(--font-weight-semibold);