@profitlich/template-toolkit 3.0.1 → 3.1.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.scss +1 -1
- package/package.json +2 -1
- package/scss/core/layout.scss +18 -1
- package/utils/VwBody.js +27 -0
package/dev/toolbar/toolbar.scss
CHANGED
|
@@ -17,7 +17,7 @@ $color--dev-grid-center: rgba(0, 0, 0, 0.2);
|
|
|
17
17
|
// the grid is made through repition
|
|
18
18
|
// 'important' because background settings are more specific than the grid settings
|
|
19
19
|
background-size: calc((100% - ($columns * $gutter)) * calc(1 / $columns) + $gutter) 1px !important;
|
|
20
|
-
margin: 0 ($margin-right - calc($gutter / 2)) 0 ($margin-left - calc($gutter / 2));
|
|
20
|
+
margin: 0 calc($margin-right - calc($gutter / 2)) 0 calc($margin-left - calc($gutter / 2));
|
|
21
21
|
// The grid is calculated starting from the middle
|
|
22
22
|
// Thats why its necessary to add the half of the column gap to the left and right side
|
|
23
23
|
width: calc(100% - $margin-right + calc($gutter / 2) - $margin-left + calc($gutter / 2));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@profitlich/template-toolkit",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.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": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"./utils/MailAdresses": "./utils/MailAdresses.js",
|
|
17
17
|
"./utils/MediaQueries": "./utils/MediaQueries.js",
|
|
18
18
|
"./utils/Vh100": "./utils/Vh100.js",
|
|
19
|
+
"./utils/VwBody": "./utils/VwBody.js",
|
|
19
20
|
"./utils/ImagesLoaded": "./utils/images-loaded/ImagesLoaded.js",
|
|
20
21
|
"./scripts/copy-files": "./scripts/copy-files.js",
|
|
21
22
|
"./scripts/deploy": "./scripts/deploy.js",
|
package/scss/core/layout.scss
CHANGED
|
@@ -4,6 +4,18 @@
|
|
|
4
4
|
@use "sass:meta";
|
|
5
5
|
@use "sass:math";
|
|
6
6
|
|
|
7
|
+
// Liest das optionale Top-Level Feld `vwBasis` aus der Konsumenten-config.
|
|
8
|
+
// Default 'viewport' = bisheriges Verhalten (raw vw).
|
|
9
|
+
// 'body' = calc(var(--vw-body, 1vw) * X) — skaliert mit scrollbar-freier Body-Breite.
|
|
10
|
+
@function _vw-basis() {
|
|
11
|
+
$vars: meta.module-variables('config');
|
|
12
|
+
$value: map.get($vars, 'vwBasis');
|
|
13
|
+
@if $value {
|
|
14
|
+
@return $value;
|
|
15
|
+
}
|
|
16
|
+
@return 'viewport';
|
|
17
|
+
}
|
|
18
|
+
|
|
7
19
|
// Media queries get the breakpoints
|
|
8
20
|
// Breakpints get the layouts
|
|
9
21
|
// Depending on the project, only a part of the layout names are used,
|
|
@@ -187,7 +199,12 @@ $mediaqueries: (
|
|
|
187
199
|
@if ($unit-type == 'px') {
|
|
188
200
|
@return $number * 1px;
|
|
189
201
|
} @else if ($unit-type == 'vw') {
|
|
190
|
-
|
|
202
|
+
$factor: math.div($number, $width) * 100;
|
|
203
|
+
@if (_vw-basis() == 'body') {
|
|
204
|
+
@return calc(var(--vw-body, 1vw) * #{$factor});
|
|
205
|
+
} @else {
|
|
206
|
+
@return _decimal-round($factor, 2) * 1vw;
|
|
207
|
+
}
|
|
191
208
|
} @else {
|
|
192
209
|
@error "Nicht unterstützter Einheitstyp '#{$unit-type}' für Layout '#{$layout}'. Nur 'px' oder 'vw' werden unterstützt.";
|
|
193
210
|
}
|
package/utils/VwBody.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setzt --vw-body als 1% der scrollbar-freien Body-Breite.
|
|
3
|
+
* Wird benötigt, wenn config.json vwBasis: "body" gesetzt hat.
|
|
4
|
+
*/
|
|
5
|
+
export class VwBody {
|
|
6
|
+
static #instance;
|
|
7
|
+
vw = 0;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
this.#calculate();
|
|
11
|
+
window.addEventListener('resize', () => {
|
|
12
|
+
this.#calculate();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#calculate() {
|
|
17
|
+
this.vw = document.documentElement.clientWidth * 0.01;
|
|
18
|
+
document.documentElement.style.setProperty('--vw-body', `${this.vw}px`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static getInstance() {
|
|
22
|
+
if (!VwBody.#instance) {
|
|
23
|
+
VwBody.#instance = new VwBody();
|
|
24
|
+
}
|
|
25
|
+
return VwBody.#instance;
|
|
26
|
+
}
|
|
27
|
+
}
|