@profitlich/template-toolkit 2.6.1 → 2.7.0
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/dev/toolbar/Toolbar.js +29 -4
- package/dev/toolbar/toolbar.scss +27 -1
- package/package.json +4 -3
- package/vite/jsonToScss.js +16 -0
package/dev/toolbar/Toolbar.js
CHANGED
|
@@ -7,6 +7,7 @@ export class Toolbar {
|
|
|
7
7
|
#gui;
|
|
8
8
|
#state;
|
|
9
9
|
#pictureElements;
|
|
10
|
+
#contentTypeContainer;
|
|
10
11
|
|
|
11
12
|
constructor() {
|
|
12
13
|
// State aus localStorage laden
|
|
@@ -20,6 +21,11 @@ export class Toolbar {
|
|
|
20
21
|
gridOverlay.classList.add('dev-toolbar__grid');
|
|
21
22
|
document.body.prepend(gridOverlay);
|
|
22
23
|
|
|
24
|
+
// Content-Type-Label-Overlay erstellen
|
|
25
|
+
this.#contentTypeContainer = document.createElement('div');
|
|
26
|
+
this.#contentTypeContainer.classList.add('dev-toolbar__content-types');
|
|
27
|
+
document.body.prepend(this.#contentTypeContainer);
|
|
28
|
+
|
|
23
29
|
// Picture-Elemente sammeln
|
|
24
30
|
this.#pictureElements = document.getElementsByTagName('picture');
|
|
25
31
|
|
|
@@ -33,6 +39,10 @@ export class Toolbar {
|
|
|
33
39
|
this.#gui.add(this.#state, 'imageSize')
|
|
34
40
|
.name('Bildgrössen')
|
|
35
41
|
.onChange(() => this.#onStateChange());
|
|
42
|
+
|
|
43
|
+
this.#gui.add(this.#state, 'contentType')
|
|
44
|
+
.name('Inhaltstypen')
|
|
45
|
+
.onChange(() => this.#onStateChange());
|
|
36
46
|
|
|
37
47
|
// State anwenden
|
|
38
48
|
this.#applyState();
|
|
@@ -57,10 +67,24 @@ export class Toolbar {
|
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
#applyState() {
|
|
60
|
-
const gridActive = this.#state.grid !== 'aus';
|
|
61
|
-
document.body.setAttribute('data-dev', String(gridActive));
|
|
62
70
|
document.body.setAttribute('data-dev-grid', this.#state.grid);
|
|
71
|
+
document.body.setAttribute('data-dev-content-type', this.#state.contentType);
|
|
63
72
|
this.#updateImageSize();
|
|
73
|
+
this.#updateContentTypeLabels();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#updateContentTypeLabels() {
|
|
77
|
+
this.#contentTypeContainer.innerHTML = '';
|
|
78
|
+
if (!this.#state.contentType) return;
|
|
79
|
+
document.querySelectorAll('[data-content-type]').forEach(el => {
|
|
80
|
+
const rect = el.getBoundingClientRect();
|
|
81
|
+
const label = document.createElement('div');
|
|
82
|
+
label.className = 'dev-toolbar__content-type-label';
|
|
83
|
+
label.textContent = el.dataset.contentType;
|
|
84
|
+
label.style.left = `${rect.left + window.scrollX}px`;
|
|
85
|
+
label.style.top = `${rect.top + window.scrollY}px`;
|
|
86
|
+
this.#contentTypeContainer.appendChild(label);
|
|
87
|
+
});
|
|
64
88
|
}
|
|
65
89
|
|
|
66
90
|
#saveState() {
|
|
@@ -73,11 +97,11 @@ export class Toolbar {
|
|
|
73
97
|
if (this.#state.imageSize) {
|
|
74
98
|
const windowWidth = window.innerWidth;
|
|
75
99
|
pictures.forEach((picture) => {
|
|
76
|
-
picture.setAttribute('data-size', `${Math.round(picture.offsetWidth / windowWidth * 100)}vw`);
|
|
100
|
+
picture.setAttribute('data-dev-size', `${Math.round(picture.offsetWidth / windowWidth * 100)}vw`);
|
|
77
101
|
});
|
|
78
102
|
} else {
|
|
79
103
|
pictures.forEach((picture) => {
|
|
80
|
-
picture.setAttribute('data-size', '');
|
|
104
|
+
picture.setAttribute('data-dev-size', '');
|
|
81
105
|
});
|
|
82
106
|
}
|
|
83
107
|
}
|
|
@@ -85,6 +109,7 @@ export class Toolbar {
|
|
|
85
109
|
#onResize = () => {
|
|
86
110
|
this.#gui.title(this.#getViewportText());
|
|
87
111
|
this.#updateImageSize();
|
|
112
|
+
this.#updateContentTypeLabels();
|
|
88
113
|
}
|
|
89
114
|
|
|
90
115
|
#handleKeyDown = (event) => {
|
package/dev/toolbar/toolbar.scss
CHANGED
|
@@ -89,7 +89,7 @@ picture {
|
|
|
89
89
|
position: relative;
|
|
90
90
|
|
|
91
91
|
&::before{
|
|
92
|
-
content: attr(data-size);
|
|
92
|
+
content: attr(data-dev-size);
|
|
93
93
|
font-family: sans-serif;
|
|
94
94
|
position: absolute;
|
|
95
95
|
top: 10px;
|
|
@@ -100,3 +100,29 @@ picture {
|
|
|
100
100
|
z-index: 10;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
|
|
104
|
+
.dev-toolbar__content-types {
|
|
105
|
+
display: none;
|
|
106
|
+
position: absolute;
|
|
107
|
+
top: 0;
|
|
108
|
+
left: 0;
|
|
109
|
+
width: 0;
|
|
110
|
+
height: 0;
|
|
111
|
+
pointer-events: none;
|
|
112
|
+
z-index: 9999999;
|
|
113
|
+
|
|
114
|
+
body[data-dev-content-type="true"] & {
|
|
115
|
+
display: block;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.dev-toolbar__content-type-label {
|
|
120
|
+
font: 600 12px / 1.25 sans-serif;
|
|
121
|
+
background-color: black;
|
|
122
|
+
color: white;
|
|
123
|
+
transform: rotate(-90deg) translate(-100%, -100%);
|
|
124
|
+
transform-origin: left top;
|
|
125
|
+
padding: 2px 10px;
|
|
126
|
+
position: absolute;
|
|
127
|
+
white-space: nowrap;
|
|
128
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@profitlich/template-toolkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Shared SCSS layout system, JS utilities, components and build scripts for profitlich template repos",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -21,11 +21,12 @@
|
|
|
21
21
|
"./vite/jsonToScss": "./vite/jsonToScss.js"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
|
+
"components/",
|
|
24
25
|
"dev/",
|
|
25
26
|
"scss/",
|
|
27
|
+
"scripts/",
|
|
26
28
|
"utils/",
|
|
27
|
-
"
|
|
28
|
-
"scripts/"
|
|
29
|
+
"vite/"
|
|
29
30
|
],
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"basic-ftp": "^5.0.0",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function jsonToScss(json) {
|
|
2
|
+
const toValue = (v) => {
|
|
3
|
+
if (typeof v === 'object' && v !== null) {
|
|
4
|
+
return '(' + Object.entries(v).map(([k, val]) => `"${k}": ${toValue(val)}`).join(', ') + ')';
|
|
5
|
+
}
|
|
6
|
+
if (typeof v === 'string') {
|
|
7
|
+
if (/^#[0-9a-fA-F]{3,8}$/.test(v)) return v; // Hex-Farben ohne Quotes
|
|
8
|
+
return `"${v}"`;
|
|
9
|
+
}
|
|
10
|
+
return v;
|
|
11
|
+
};
|
|
12
|
+
return Object.entries(json)
|
|
13
|
+
.filter(([key]) => key !== 'README')
|
|
14
|
+
.map(([key, value]) => `$${key}: ${toValue(value)};`)
|
|
15
|
+
.join('\n');
|
|
16
|
+
}
|