@profitlich/template-toolkit 7.5.0 → 7.6.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/CLAUDE.project.md +2 -1
- package/dev/toolbar/Toolbar.js +8 -9
- package/dev/toolbar/gridColumns.js +34 -12
- package/package.json +4 -4
package/CLAUDE.project.md
CHANGED
|
@@ -113,7 +113,8 @@ Einen generischen Wert nicht im Projekt umbauen, sondern im Toolkit ändern –
|
|
|
113
113
|
|
|
114
114
|
### SCSS
|
|
115
115
|
|
|
116
|
-
-
|
|
116
|
+
- **Toolkit-Funktionen dort, wo ein Mass mit dem Layout mitgehen soll:** `size()`, `columns()`, `font()`, `marginPadding()`. Sie rechnen ein Mass aus dem Entwurf in die Einheit des Layouts um. **Feste Werte stehen direkt da** – eine Haarlinie von `1px`, ein Radius von `999px`. Nicht alles vorsorglich durch die Funktionen schicken: Die Einheit eines Layouts wird in einem Projekt nachträglich nicht gewechselt, die Flexibilität dafür nutzt niemand.
|
|
117
|
+
- **Kein rohes `vw`.** `size()` rechnet mit `--vw-body`, wenn `vwBasis` auf `body` steht; ein rohes `vw` misst am Fenster samt Scrollbar und läuft bei sichtbarer Scrollbar gegen das übrige Layout.
|
|
117
118
|
- `src/config.json` ist die einzige Quelle für Breakpoints, Layouts, Farben — nie im Code hardcodieren.
|
|
118
119
|
- Jedes Modul/Snippet hat eine eigene `.js`-Datei, die das zugehörige SCSS importiert — auch wenn sie sonst keine Logik enthält.
|
|
119
120
|
- Keine globalen Styles in Modul- oder Snippet-SCSS-Dateien.
|
package/dev/toolbar/Toolbar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import GUI from 'lil-gui';
|
|
2
2
|
import { canvasGridLines } from 'canvas-grid-lines';
|
|
3
3
|
import { MediaQueries } from '../../utils/MediaQueries.js';
|
|
4
|
-
import {
|
|
4
|
+
import { gridColumnsOptions } from './gridColumns.js';
|
|
5
5
|
import './toolbar.scss';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -149,14 +149,14 @@ export class Toolbar {
|
|
|
149
149
|
const mode = GRID_MODES[this.#state.grid];
|
|
150
150
|
if (!mode) return;
|
|
151
151
|
|
|
152
|
-
const columns =
|
|
152
|
+
const columns = gridColumnsOptions(this.#config, this.#mediaQueries.layout);
|
|
153
153
|
if (!columns) return;
|
|
154
154
|
|
|
155
155
|
if (!this.#grid) {
|
|
156
156
|
[this.#grid] = canvasGridLines.initGrid({
|
|
157
157
|
targets: this.#gridElement,
|
|
158
158
|
gridType: mode.gridType,
|
|
159
|
-
columns,
|
|
159
|
+
...columns,
|
|
160
160
|
color: mode.color,
|
|
161
161
|
lineWidth: 1,
|
|
162
162
|
units: 'devicepixel',
|
|
@@ -164,12 +164,11 @@ export class Toolbar {
|
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
this.#grid.gridType
|
|
172
|
-
this.#grid.color = mode.color;
|
|
167
|
+
// In einem Schritt statt über einzelne Setter: Wechselt ein Breakpoint
|
|
168
|
+
// zwischen festem und mitwachsendem Gutter, hat `columns` eine andere
|
|
169
|
+
// Anzahl Werte, und jede Reihenfolge einzelner Zuweisungen liefe über
|
|
170
|
+
// einen ungültigen Zwischenstand.
|
|
171
|
+
this.#grid.configure({ ...columns, gridType: mode.gridType, color: mode.color });
|
|
173
172
|
}
|
|
174
173
|
|
|
175
174
|
#onLayoutChange = () => {
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Spaltenangaben für `canvas-grid-lines`, Rasterarten `columns` und `ribbons`.
|
|
3
|
+
* @typedef {Object} GridColumnsOptions
|
|
4
|
+
* @property {number|number[]} columns - Spaltenzahl bei festem Gutter, sonst das
|
|
5
|
+
* Tripel `[total, band, gap]` in Rastereinheiten.
|
|
6
|
+
* @property {number|null} fixedGap - Gutter in CSS-Pixeln, oder `null`, wenn er
|
|
7
|
+
* mit dem Layout mitwächst.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Rechnet die Spaltenkonfiguration eines Layouts in die Angaben um, die
|
|
12
|
+
* `canvas-grid-lines` für die Rasterarten `columns` und `ribbons` erwartet.
|
|
5
13
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
14
|
+
* Welche Form sie haben, entscheidet `units` — dieselbe Angabe, nach der
|
|
15
|
+
* `size()` im SCSS rechnet:
|
|
16
|
+
*
|
|
17
|
+
* - `px`: Der Gutter ist bei jeder Fensterbreite gleich breit, die Spalten
|
|
18
|
+
* teilen sich den Rest. Das Raster bekommt die Spaltenzahl und den Gutter als
|
|
19
|
+
* festen Abstand.
|
|
20
|
+
* - `vw`: Spalten und Gutter wachsen gemeinsam; ihr Verhältnis ist bei jeder
|
|
21
|
+
* Breite dasselbe und geht als Tripel `[total, band, gap]` ans Raster.
|
|
10
22
|
*
|
|
11
23
|
* @param {Object} config - Inhalt von `src/config.json` des Projekts.
|
|
12
24
|
* @param {string} layout - Layoutname, etwa `desktop`.
|
|
13
|
-
* @returns {
|
|
14
|
-
*
|
|
25
|
+
* @returns {GridColumnsOptions|undefined} `undefined`, wenn die Angaben fehlen
|
|
26
|
+
* oder kein brauchbares Raster ergeben.
|
|
15
27
|
*/
|
|
16
|
-
export function
|
|
28
|
+
export function gridColumnsOptions(config, layout) {
|
|
17
29
|
const width = config?.layouts?.[layout];
|
|
18
30
|
const margins = config?.margins?.[layout];
|
|
19
31
|
const gutter = config?.gutter?.[layout];
|
|
@@ -24,12 +36,22 @@ export function gridColumnsTriple(config, layout) {
|
|
|
24
36
|
return undefined;
|
|
25
37
|
}
|
|
26
38
|
|
|
39
|
+
if (config?.units?.[layout] === 'px') {
|
|
40
|
+
if (!Number.isInteger(count) || count <= 0 || !Number.isFinite(gutter) || gutter < 0) {
|
|
41
|
+
console.warn(`Dev-Toolbar: Layout "${layout}" ergibt keine brauchbare Spaltenaufteilung (Gutter ${gutter}, Spalten ${count}) — das Raster bleibt aus.`);
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return { columns: count, fixedGap: gutter };
|
|
45
|
+
}
|
|
46
|
+
|
|
27
47
|
// Die Spaltenbreite ist `zaehler / count` und oft kein ganzer Designpixel —
|
|
28
48
|
// in `template-kirbycms` etwa 91,428…. Deshalb wird sie nie ausgerechnet:
|
|
29
49
|
// Das Verhältnis Spalte zu Gutter ist `zaehler/count : gutter`, und mit
|
|
30
50
|
// `count` erweitert wird daraus `zaehler : count · gutter`, also ein
|
|
31
51
|
// Verhältnis zweier ganzer Zahlen. Gekürzt ergibt das exakt das gesuchte
|
|
32
|
-
// Muster, ohne jede Rundung
|
|
52
|
+
// Muster, ohne jede Rundung — der grösste gemeinsame Teiler macht aus
|
|
53
|
+
// 80 : 20 die ganzen Zahlen 4 : 1, die das Paket als Wiederholungsmuster
|
|
54
|
+
// braucht.
|
|
33
55
|
const zaehler = width - margins.left - margins.right - (count - 1) * gutter;
|
|
34
56
|
|
|
35
57
|
if (!Number.isInteger(zaehler) || !Number.isInteger(gutter) || !Number.isInteger(count) || zaehler <= 0) {
|
|
@@ -41,7 +63,7 @@ export function gridColumnsTriple(config, layout) {
|
|
|
41
63
|
const band = zaehler / unit;
|
|
42
64
|
const gap = (count * gutter) / unit;
|
|
43
65
|
|
|
44
|
-
return [count * band + (count - 1) * gap, band, gap];
|
|
66
|
+
return { columns: [count * band + (count - 1) * gap, band, gap], fixedGap: null };
|
|
45
67
|
}
|
|
46
68
|
|
|
47
69
|
function greatestCommonDivisor(a, b) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@profitlich/template-toolkit",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.1",
|
|
4
4
|
"description": "Shared SCSS layout system, JS utilities, components and build scripts for profitlich template repos",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sass": "scss/forward.scss",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"vite/"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"basic-ftp": "^6.2.
|
|
48
|
-
"canvas-grid-lines": "^10.
|
|
47
|
+
"basic-ftp": "^6.2.2",
|
|
48
|
+
"canvas-grid-lines": "^10.6.0",
|
|
49
49
|
"chokidar": "^5.0.0",
|
|
50
50
|
"cli-progress": "^3.12.0",
|
|
51
|
-
"dotenv": "^18.0.
|
|
51
|
+
"dotenv": "^18.0.6",
|
|
52
52
|
"fs-extra": "^11.4.1",
|
|
53
53
|
"glob": "^13.0.6",
|
|
54
54
|
"lil-gui": "^0.21.0"
|