vasille-css 7.0.0-rc.2 → 7.0.0-rc.3
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/lib/dev.js +32 -1
- package/lib/lib.js +7 -11
- package/package.json +1 -1
- package/types/dev.d.ts +3 -0
- package/types/lib.d.ts +6 -1
package/lib/dev.js
CHANGED
|
@@ -1,4 +1,35 @@
|
|
|
1
|
-
import { CssStyleInjector } from "./index.js";
|
|
1
|
+
import { CssStyleInjector, setLaptopMaxWidth, setMobileMaxWidth, setTabletMaxWidth } from "./index.js";
|
|
2
|
+
import { desktop, laptopMaxWidth, mobile, mobileMaxWidth, tablet, tabletMaxWidth } from "./lib.js";
|
|
3
|
+
function warn(device) {
|
|
4
|
+
console.warn(`[vasille-css] Setting of ${device} max width in production mode is not supported.`);
|
|
5
|
+
}
|
|
6
|
+
export function devSetMobileMaxWidth(value) {
|
|
7
|
+
setMobileMaxWidth(value);
|
|
8
|
+
if (mobile) {
|
|
9
|
+
mobile.media = `(max-width:${mobileMaxWidth}px)`;
|
|
10
|
+
}
|
|
11
|
+
if (tablet) {
|
|
12
|
+
tablet.media = `(min-width:${mobileMaxWidth}px) and (max-width:${tabletMaxWidth}px)`;
|
|
13
|
+
}
|
|
14
|
+
warn("mobile");
|
|
15
|
+
}
|
|
16
|
+
export function devSetTabletMaxWidth(value) {
|
|
17
|
+
setTabletMaxWidth(value);
|
|
18
|
+
if (tablet) {
|
|
19
|
+
tablet.media = `(min-width:${mobileMaxWidth}px) and (max-width:${tabletMaxWidth}px)`;
|
|
20
|
+
}
|
|
21
|
+
if (desktop) {
|
|
22
|
+
desktop.media = `(min-width:${tabletMaxWidth}px) and (max-width:${laptopMaxWidth}px)`;
|
|
23
|
+
}
|
|
24
|
+
warn("tablet");
|
|
25
|
+
}
|
|
26
|
+
export function devSetLaptopMaxWidth(value) {
|
|
27
|
+
setLaptopMaxWidth(value);
|
|
28
|
+
if (desktop) {
|
|
29
|
+
desktop.media = `(min-width:${tabletMaxWidth}px) and (max-width:${laptopMaxWidth}px)`;
|
|
30
|
+
}
|
|
31
|
+
warn("laptop");
|
|
32
|
+
}
|
|
2
33
|
export class DevCssStyleInjector extends CssStyleInjector {
|
|
3
34
|
constructor(key, styles) {
|
|
4
35
|
super(styles);
|
package/lib/lib.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
let common;
|
|
2
|
-
let mobile;
|
|
3
|
-
let tablet;
|
|
4
|
-
let desktop;
|
|
2
|
+
export let mobile;
|
|
3
|
+
export let tablet;
|
|
4
|
+
export let desktop;
|
|
5
5
|
let dark;
|
|
6
6
|
let light;
|
|
7
|
-
let mobileMaxWidth = 440;
|
|
8
|
-
let tabletMaxWidth = 880;
|
|
9
|
-
let laptopMaxWidth = 1320;
|
|
7
|
+
export let mobileMaxWidth = 440;
|
|
8
|
+
export let tabletMaxWidth = 880;
|
|
9
|
+
export let laptopMaxWidth = 1320;
|
|
10
10
|
export function setMobileMaxWidth(value) {
|
|
11
11
|
mobileMaxWidth = value;
|
|
12
12
|
}
|
|
@@ -22,7 +22,7 @@ function createStyleSheet(media) {
|
|
|
22
22
|
document.head.append(style);
|
|
23
23
|
return style.sheet;
|
|
24
24
|
}
|
|
25
|
-
export function
|
|
25
|
+
export function insertRule(target, rule) {
|
|
26
26
|
let sheet;
|
|
27
27
|
switch (target) {
|
|
28
28
|
case 0:
|
|
@@ -68,10 +68,6 @@ export function getStyleSheet(target) {
|
|
|
68
68
|
sheet = light;
|
|
69
69
|
break;
|
|
70
70
|
}
|
|
71
|
-
return sheet;
|
|
72
|
-
}
|
|
73
|
-
export function insertRule(target, rule) {
|
|
74
|
-
const sheet = getStyleSheet(target);
|
|
75
71
|
/* istanbul ignore else */
|
|
76
72
|
if (sheet) {
|
|
77
73
|
sheet.insertRule(rule, sheet.cssRules.length);
|
package/package.json
CHANGED
package/types/dev.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { CssStyleInjector } from "./index.js";
|
|
2
|
+
export declare function devSetMobileMaxWidth(value: number): void;
|
|
3
|
+
export declare function devSetTabletMaxWidth(value: number): void;
|
|
4
|
+
export declare function devSetLaptopMaxWidth(value: number): void;
|
|
2
5
|
export declare class DevCssStyleInjector extends CssStyleInjector {
|
|
3
6
|
protected key: string;
|
|
4
7
|
constructor(key: string, styles: (string | [number, string])[]);
|
package/types/lib.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
export declare let mobile: CSSStyleSheet | undefined;
|
|
2
|
+
export declare let tablet: CSSStyleSheet | undefined;
|
|
3
|
+
export declare let desktop: CSSStyleSheet | undefined;
|
|
4
|
+
export declare let mobileMaxWidth: number;
|
|
5
|
+
export declare let tabletMaxWidth: number;
|
|
6
|
+
export declare let laptopMaxWidth: number;
|
|
1
7
|
export declare function setMobileMaxWidth(value: number): void;
|
|
2
8
|
export declare function setTabletMaxWidth(value: number): void;
|
|
3
9
|
export declare function setLaptopMaxWidth(value: number): void;
|
|
4
|
-
export declare function getStyleSheet(target: number): CSSStyleSheet | undefined;
|
|
5
10
|
export declare function insertRule(target: number, rule: string): void;
|