cradova 1.0.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/LICENSE +201 -0
- package/cradova.png +0 -0
- package/docs/README.md +0 -0
- package/index.d.ts +52 -0
- package/index.js +342 -0
- package/index.ts +366 -0
- package/package.json +36 -0
- package/scripts/JsonDB.d.ts +298 -0
- package/scripts/JsonDB.js +698 -0
- package/scripts/JsonDB.ts +794 -0
- package/scripts/Metrics.d.ts +51 -0
- package/scripts/Metrics.js +56 -0
- package/scripts/Metrics.ts +66 -0
- package/scripts/Router.d.ts +12 -0
- package/scripts/Router.js +95 -0
- package/scripts/Router.ts +105 -0
- package/scripts/Screen.d.ts +11 -0
- package/scripts/Screen.js +62 -0
- package/scripts/Screen.ts +62 -0
- package/scripts/animate.d.ts +25 -0
- package/scripts/animate.js +47 -0
- package/scripts/animate.ts +57 -0
- package/scripts/css.d.ts +20 -0
- package/scripts/css.js +41 -0
- package/scripts/css.ts +46 -0
- package/scripts/dispatcher.d.ts +1 -0
- package/scripts/dispatcher.js +57 -0
- package/scripts/dispatcher.ts +58 -0
- package/scripts/file-system.d.ts +2 -0
- package/scripts/file-system.js +175 -0
- package/scripts/file-system.ts +177 -0
- package/scripts/fullscreen.d.ts +4 -0
- package/scripts/fullscreen.js +29 -0
- package/scripts/fullscreen.ts +30 -0
- package/scripts/init.d.ts +2 -0
- package/scripts/init.js +17 -0
- package/scripts/init.ts +18 -0
- package/scripts/localStorage.d.ts +9 -0
- package/scripts/localStorage.js +26 -0
- package/scripts/localStorage.ts +37 -0
- package/scripts/media.d.ts +22 -0
- package/scripts/media.js +48 -0
- package/scripts/media.ts +51 -0
- package/scripts/reuse.ts +74 -0
- package/scripts/speaker.d.ts +2 -0
- package/scripts/speaker.js +16 -0
- package/scripts/speaker.ts +25 -0
- package/scripts/store.d.ts +10 -0
- package/scripts/store.js +56 -0
- package/scripts/store.ts +47 -0
- package/scripts/swipe.d.ts +9 -0
- package/scripts/swipe.js +113 -0
- package/scripts/swipe.ts +129 -0
- package/scripts/widget.d.ts +2 -0
- package/scripts/widget.js +19 -0
- package/scripts/widget.ts +23 -0
- package/service-worker.d.ts +2 -0
- package/service-worker.js +40 -0
- package/service-worker.ts +52 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
declare const metrics: {
|
|
2
|
+
base: string;
|
|
3
|
+
font: string;
|
|
4
|
+
radius: string;
|
|
5
|
+
padding: string;
|
|
6
|
+
large: string;
|
|
7
|
+
big: string;
|
|
8
|
+
small: string;
|
|
9
|
+
s5: string;
|
|
10
|
+
s8: string;
|
|
11
|
+
s10: string;
|
|
12
|
+
s16: string;
|
|
13
|
+
s20: string;
|
|
14
|
+
s30: string;
|
|
15
|
+
s40: string;
|
|
16
|
+
s50: string;
|
|
17
|
+
s60: string;
|
|
18
|
+
h1: string;
|
|
19
|
+
h2: string;
|
|
20
|
+
h3: string;
|
|
21
|
+
h4: string;
|
|
22
|
+
h5: string;
|
|
23
|
+
h6: string;
|
|
24
|
+
body1: string;
|
|
25
|
+
body2: string;
|
|
26
|
+
body3: string;
|
|
27
|
+
body4: string;
|
|
28
|
+
body5: string;
|
|
29
|
+
body6: string;
|
|
30
|
+
borderWidth: string;
|
|
31
|
+
horizontalLineHeight: string;
|
|
32
|
+
screenWidth: string;
|
|
33
|
+
screenHeight: string;
|
|
34
|
+
drawerWidth: string;
|
|
35
|
+
navBarHeight: string;
|
|
36
|
+
buttonRadius: string;
|
|
37
|
+
icons: {
|
|
38
|
+
tiny: string;
|
|
39
|
+
small: string;
|
|
40
|
+
medium: string;
|
|
41
|
+
large: string;
|
|
42
|
+
xl: string;
|
|
43
|
+
};
|
|
44
|
+
images: {
|
|
45
|
+
small: string;
|
|
46
|
+
medium: string;
|
|
47
|
+
large: string;
|
|
48
|
+
logo: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export default metrics;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const { innerWidth, innerHeight } = window;
|
|
2
|
+
const height = innerHeight;
|
|
3
|
+
const width = innerWidth;
|
|
4
|
+
const metrics = {
|
|
5
|
+
// global sizes
|
|
6
|
+
base: "8px",
|
|
7
|
+
font: "14px",
|
|
8
|
+
radius: "20px",
|
|
9
|
+
padding: "24px",
|
|
10
|
+
large: "40px",
|
|
11
|
+
big: "32px",
|
|
12
|
+
small: "24px",
|
|
13
|
+
s5: "5px",
|
|
14
|
+
s8: "8px",
|
|
15
|
+
s10: "10px",
|
|
16
|
+
s16: "16px",
|
|
17
|
+
s20: "20px",
|
|
18
|
+
s30: "30px",
|
|
19
|
+
s40: "40px",
|
|
20
|
+
s50: "50px",
|
|
21
|
+
s60: "60px",
|
|
22
|
+
// font sizes
|
|
23
|
+
h1: "30px",
|
|
24
|
+
h2: "24px",
|
|
25
|
+
h3: "20px",
|
|
26
|
+
h4: "16px",
|
|
27
|
+
h5: "14px",
|
|
28
|
+
h6: "13px",
|
|
29
|
+
body1: "30px",
|
|
30
|
+
body2: "22px",
|
|
31
|
+
body3: "16px",
|
|
32
|
+
body4: "14px",
|
|
33
|
+
body5: "13px",
|
|
34
|
+
body6: "12px",
|
|
35
|
+
borderWidth: "0.4px",
|
|
36
|
+
horizontalLineHeight: "1px",
|
|
37
|
+
screenWidth: width < height ? width + "px" : height + "px",
|
|
38
|
+
screenHeight: width < height ? height + "px" : width + "px",
|
|
39
|
+
drawerWidth: (3 / 4) * width + "px",
|
|
40
|
+
navBarHeight: "60px",
|
|
41
|
+
buttonRadius: "4px",
|
|
42
|
+
icons: {
|
|
43
|
+
tiny: "15px",
|
|
44
|
+
small: "20px",
|
|
45
|
+
medium: "30px",
|
|
46
|
+
large: "45px",
|
|
47
|
+
xl: "50px",
|
|
48
|
+
},
|
|
49
|
+
images: {
|
|
50
|
+
small: "20px",
|
|
51
|
+
medium: "40px",
|
|
52
|
+
large: "60px",
|
|
53
|
+
logo: "200px",
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export default metrics;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const { innerWidth, innerHeight } = window;
|
|
2
|
+
const height = innerHeight;
|
|
3
|
+
const width = innerWidth;
|
|
4
|
+
|
|
5
|
+
const metrics = {
|
|
6
|
+
// global sizes
|
|
7
|
+
base: "8px",
|
|
8
|
+
font: "14px",
|
|
9
|
+
radius: "20px",
|
|
10
|
+
padding: "24px",
|
|
11
|
+
large: "40px",
|
|
12
|
+
big: "32px",
|
|
13
|
+
small: "24px",
|
|
14
|
+
|
|
15
|
+
s5: "5px",
|
|
16
|
+
s8: "8px",
|
|
17
|
+
s10: "10px",
|
|
18
|
+
s16: "16px",
|
|
19
|
+
s20: "20px",
|
|
20
|
+
s30: "30px",
|
|
21
|
+
s40: "40px",
|
|
22
|
+
s50: "50px",
|
|
23
|
+
s60: "60px",
|
|
24
|
+
|
|
25
|
+
// font sizes
|
|
26
|
+
h1: "30px",
|
|
27
|
+
h2: "24px",
|
|
28
|
+
h3: "20px",
|
|
29
|
+
h4: "16px",
|
|
30
|
+
h5: "14px",
|
|
31
|
+
h6: "13px",
|
|
32
|
+
body1: "30px",
|
|
33
|
+
body2: "22px",
|
|
34
|
+
body3: "16px",
|
|
35
|
+
body4: "14px",
|
|
36
|
+
body5: "13px",
|
|
37
|
+
body6: "12px",
|
|
38
|
+
|
|
39
|
+
borderWidth: "0.4px",
|
|
40
|
+
|
|
41
|
+
horizontalLineHeight: "1px",
|
|
42
|
+
|
|
43
|
+
screenWidth: width < height ? width + "px" : height + "px",
|
|
44
|
+
screenHeight: width < height ? height + "px" : width + "px",
|
|
45
|
+
drawerWidth: (3 / 4) * width + "px",
|
|
46
|
+
navBarHeight: "60px",
|
|
47
|
+
|
|
48
|
+
buttonRadius: "4px",
|
|
49
|
+
|
|
50
|
+
icons: {
|
|
51
|
+
tiny: "15px",
|
|
52
|
+
small: "20px",
|
|
53
|
+
medium: "30px",
|
|
54
|
+
large: "45px",
|
|
55
|
+
xl: "50px",
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
images: {
|
|
59
|
+
small: "20px",
|
|
60
|
+
medium: "40px",
|
|
61
|
+
large: "60px",
|
|
62
|
+
logo: "200px",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default metrics;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Facilitates navigation within the application and initializes
|
|
3
|
+
* page views based on the matched routes.
|
|
4
|
+
*/
|
|
5
|
+
declare type r = {
|
|
6
|
+
routes: Record<string, Record<string, string | (() => void)>>;
|
|
7
|
+
route: (path: string, controller: () => void) => void;
|
|
8
|
+
navigate: (href: string) => void;
|
|
9
|
+
router: (e: unknown | undefined) => void;
|
|
10
|
+
};
|
|
11
|
+
declare let Router: r;
|
|
12
|
+
export default Router;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Facilitates navigation within the application and initializes
|
|
3
|
+
* page views based on the matched routes.
|
|
4
|
+
*/
|
|
5
|
+
let Router = {
|
|
6
|
+
routes: {},
|
|
7
|
+
navigate: () => console.log(""),
|
|
8
|
+
route: () => console.log(""),
|
|
9
|
+
router: () => console.log(""),
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {object} context Any initial context to be passed to pages.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Registers a route.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} path Route path.
|
|
19
|
+
* @param {Function} controller Callback method.
|
|
20
|
+
*/
|
|
21
|
+
Router.route = function (path = "/", controller) {
|
|
22
|
+
const link = document.createElement("a");
|
|
23
|
+
link.href = window.location.href.replace(/#(.*)$/, "") + path.split("/")[1];
|
|
24
|
+
Router.routes[path] = {
|
|
25
|
+
templateId: path.split("/")[1] !== "" ? path.split("/")[1] : window.location.hostname,
|
|
26
|
+
controller: controller,
|
|
27
|
+
};
|
|
28
|
+
return link;
|
|
29
|
+
};
|
|
30
|
+
Router.navigate = function (href) {
|
|
31
|
+
let route = null, link = null;
|
|
32
|
+
if (href.includes(".")) {
|
|
33
|
+
if (new URL(href).pathname === window.location.pathname) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
route = Router.routes[new URL(href).pathname];
|
|
37
|
+
link = new URL(href).pathname;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
if (href === window.location.pathname) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
route = Router.routes[href];
|
|
44
|
+
link = href;
|
|
45
|
+
}
|
|
46
|
+
if (route && typeof route.controller === "function") {
|
|
47
|
+
route.controller();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw new Error("cradova err route doesn't exist");
|
|
51
|
+
}
|
|
52
|
+
window.history.pushState(href, "", link);
|
|
53
|
+
window.scrollTo(0, 0);
|
|
54
|
+
return;
|
|
55
|
+
};
|
|
56
|
+
Router.router = function (e) {
|
|
57
|
+
const Alink = e.path.find((el) => el.tagName === "A");
|
|
58
|
+
if (Alink && Alink.href.includes("#")) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
if (Alink) {
|
|
63
|
+
if (Alink.href === "" ||
|
|
64
|
+
new URL(Alink.href).pathname === window.location.pathname) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const route = Router.routes[new URL(Alink.href).pathname];
|
|
68
|
+
if (route && typeof route.controller === "function") {
|
|
69
|
+
route.controller();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
throw new Error("cradova err route doesn't exist " + Alink.href);
|
|
73
|
+
}
|
|
74
|
+
window.history.pushState(Alink.href, "", new URL(Alink.href).pathname);
|
|
75
|
+
window.scrollTo(0, 0);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const url = window.location.pathname;
|
|
79
|
+
const route = Router.routes[url];
|
|
80
|
+
if (route && typeof route.controller === "function") {
|
|
81
|
+
route.controller();
|
|
82
|
+
}
|
|
83
|
+
window.scrollTo(0, 0);
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Responds to click events anywhere in the document and when
|
|
87
|
+
* the click happens on a link that is supposed to be handled
|
|
88
|
+
* by the router, loads and displays the target page.
|
|
89
|
+
*
|
|
90
|
+
* @param {Event} e Click event.
|
|
91
|
+
*/
|
|
92
|
+
document.addEventListener("click", Router.router);
|
|
93
|
+
window.addEventListener("load", Router.router);
|
|
94
|
+
window.addEventListener("popstate", Router.router);
|
|
95
|
+
export default Router;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Facilitates navigation within the application and initializes
|
|
3
|
+
* page views based on the matched routes.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const Router = {};
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {object} context Any initial context to be passed to pages.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
Router.routes = {};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Registers a route.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} path Route path.
|
|
18
|
+
* @param {Function} controller Callback method.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
Router.route = function (path = "/", controller) {
|
|
22
|
+
const link = document.createElement("a");
|
|
23
|
+
link.href = window.location.href.replace(/#(.*)$/, "") + path.split("/")[1];
|
|
24
|
+
Router.routes[path] = {
|
|
25
|
+
templateId:
|
|
26
|
+
path.split("/")[1] !== "" ? path.split("/")[1] : window.location.hostname,
|
|
27
|
+
controller: controller,
|
|
28
|
+
};
|
|
29
|
+
return link;
|
|
30
|
+
};
|
|
31
|
+
Router.navigate = function (href) {
|
|
32
|
+
let route = null,
|
|
33
|
+
link = null;
|
|
34
|
+
if (href.includes(".")) {
|
|
35
|
+
if (new URL(href).pathname === window.location.pathname) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
route = Router.routes[new URL(href).pathname];
|
|
39
|
+
link = new URL(href).pathname;
|
|
40
|
+
} else {
|
|
41
|
+
if (href === window.location.pathname) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
route = Router.routes[href];
|
|
45
|
+
link = href;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (route) {
|
|
49
|
+
route.controller();
|
|
50
|
+
} else {
|
|
51
|
+
throw new Error("cradova err route doesn't exist");
|
|
52
|
+
}
|
|
53
|
+
window.history.pushState(href, null, link);
|
|
54
|
+
window.scrollTo(0, 0);
|
|
55
|
+
return;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Router.router = function (e) {
|
|
59
|
+
const Alink = e.path.find((el) => el.tagName === "A");
|
|
60
|
+
if (Alink && Alink.href.includes("#")) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
if (Alink) {
|
|
65
|
+
if (
|
|
66
|
+
Alink.href === "" ||
|
|
67
|
+
new URL(Alink.href).pathname === window.location.pathname
|
|
68
|
+
) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const route = Router.routes[new URL(Alink.href).pathname];
|
|
72
|
+
if (route) {
|
|
73
|
+
route.controller(e);
|
|
74
|
+
} else {
|
|
75
|
+
throw new Error("cradova err route doesn't exist " + Alink.href);
|
|
76
|
+
}
|
|
77
|
+
window.history.pushState(Alink.href, null, new URL(Alink.href).pathname);
|
|
78
|
+
window.scrollTo(0, 0);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const url = window.location.pathname;
|
|
83
|
+
const route = Router.routes[url];
|
|
84
|
+
if (route) {
|
|
85
|
+
route.controller(e);
|
|
86
|
+
}
|
|
87
|
+
window.scrollTo(0, 0);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Responds to click events anywhere in the document and when
|
|
92
|
+
* the click happens on a link that is supposed to be handled
|
|
93
|
+
* by the router, loads and displays the target page.
|
|
94
|
+
*
|
|
95
|
+
* @param {Event} e Click event.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
document.addEventListener("click", Router.router);
|
|
99
|
+
window.addEventListener("load", Router.router);
|
|
100
|
+
window.addEventListener("popstate", (e) => {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
Router.router(e);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export default Router;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class Screen {
|
|
2
|
+
name: string;
|
|
3
|
+
template: HTMLElement;
|
|
4
|
+
callBacks: ((html: ChildNode | null) => void)[];
|
|
5
|
+
constructor(name: string, template: HTMLElement | (() => HTMLElement));
|
|
6
|
+
onActivate(cb: (html: ChildNode | null) => void): void;
|
|
7
|
+
addChild(...addOns: HTMLElement[] | (() => HTMLElement)[] | string[]): void;
|
|
8
|
+
detach(): void;
|
|
9
|
+
Activate(): void;
|
|
10
|
+
}
|
|
11
|
+
export default Screen;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
class Screen {
|
|
2
|
+
constructor(name, template) {
|
|
3
|
+
this.name = name;
|
|
4
|
+
this.template = document.createElement("div");
|
|
5
|
+
this.template.style.width = "100%";
|
|
6
|
+
this.template.style.display = "flex";
|
|
7
|
+
this.template.style.flexDirection = "column";
|
|
8
|
+
this.template.id = "cradova-screen-set";
|
|
9
|
+
if (typeof template === "function") {
|
|
10
|
+
let fuc = template();
|
|
11
|
+
this.template.append(fuc);
|
|
12
|
+
// if (typeof fuc === "function") {
|
|
13
|
+
// this.template.append(fuc());
|
|
14
|
+
// } else {
|
|
15
|
+
// this.template.append(fuc);
|
|
16
|
+
// }
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
if (!(template instanceof HTMLElement)) {
|
|
20
|
+
throw new Error("Cradova err only should a html element is valid");
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this.template.append(template);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
this.callBacks = [];
|
|
27
|
+
}
|
|
28
|
+
onActivate(cb) {
|
|
29
|
+
this.callBacks.push(cb);
|
|
30
|
+
}
|
|
31
|
+
addChild(...addOns) {
|
|
32
|
+
for (let i = 0; i < addOns.length; i++) {
|
|
33
|
+
if (addOns[i] && addOns[i] instanceof HTMLElement) {
|
|
34
|
+
this.template.append(addOns[i]);
|
|
35
|
+
}
|
|
36
|
+
if (typeof addOns[i] === "function") {
|
|
37
|
+
this.template.append(addOns[i]());
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
detach() {
|
|
42
|
+
var _a;
|
|
43
|
+
const screen = document.querySelector("#cradova-screen-set");
|
|
44
|
+
if (screen) {
|
|
45
|
+
(_a = document.querySelector("#app-wrapper")) === null || _a === void 0 ? void 0 : _a.removeChild(screen);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
Activate() {
|
|
49
|
+
var _a;
|
|
50
|
+
if (document.title === this.name) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const screen = document.querySelector("#cradova-screen-set");
|
|
54
|
+
if (screen) {
|
|
55
|
+
this.detach();
|
|
56
|
+
}
|
|
57
|
+
document.title = this.name;
|
|
58
|
+
(_a = document.querySelector("#app-wrapper")) === null || _a === void 0 ? void 0 : _a.append(this.template);
|
|
59
|
+
this.callBacks.forEach((cb) => cb(this.template.firstChild));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export default Screen;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
class Screen {
|
|
2
|
+
name: string;
|
|
3
|
+
template: HTMLElement;
|
|
4
|
+
callBacks: ((html: ChildNode | null) => void)[];
|
|
5
|
+
constructor(name: string, template: HTMLElement | (() => HTMLElement)) {
|
|
6
|
+
this.name = name;
|
|
7
|
+
this.template = document.createElement("div");
|
|
8
|
+
this.template.style.width = "100%";
|
|
9
|
+
this.template.style.display = "flex";
|
|
10
|
+
this.template.style.flexDirection = "column";
|
|
11
|
+
this.template.id = "cradova-screen-set";
|
|
12
|
+
if (typeof template === "function") {
|
|
13
|
+
let fuc: HTMLElement | (() => HTMLElement) = template();
|
|
14
|
+
this.template.append(fuc);
|
|
15
|
+
// if (typeof fuc === "function") {
|
|
16
|
+
// this.template.append(fuc());
|
|
17
|
+
// } else {
|
|
18
|
+
// this.template.append(fuc);
|
|
19
|
+
// }
|
|
20
|
+
} else {
|
|
21
|
+
if (!(template instanceof HTMLElement)) {
|
|
22
|
+
throw new Error("Cradova err only should a html element is valid");
|
|
23
|
+
} else {
|
|
24
|
+
this.template.append(template);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
this.callBacks = [];
|
|
28
|
+
}
|
|
29
|
+
onActivate(cb: (html: ChildNode | null) => void) {
|
|
30
|
+
this.callBacks.push(cb);
|
|
31
|
+
}
|
|
32
|
+
addChild(...addOns: HTMLElement[] | (() => HTMLElement)[] | string[]) {
|
|
33
|
+
for (let i = 0; i < addOns.length; i++) {
|
|
34
|
+
if (addOns[i] && addOns[i] instanceof HTMLElement) {
|
|
35
|
+
this.template.append(addOns[i]);
|
|
36
|
+
}
|
|
37
|
+
if (typeof addOns[i] === "function") {
|
|
38
|
+
this.template.append(addOns[i]());
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
detach() {
|
|
43
|
+
const screen = document.querySelector("#cradova-screen-set");
|
|
44
|
+
if (screen) {
|
|
45
|
+
document.querySelector("#app-wrapper")?.removeChild(screen);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
Activate() {
|
|
49
|
+
if (document.title === this.name) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const screen = document.querySelector("#cradova-screen-set");
|
|
53
|
+
if (screen) {
|
|
54
|
+
this.detach();
|
|
55
|
+
}
|
|
56
|
+
document.title = this.name;
|
|
57
|
+
document.querySelector("#app-wrapper")?.append(this.template);
|
|
58
|
+
this.callBacks.forEach((cb) => cb(this.template.firstChild));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default Screen;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Write animation value in javascript
|
|
3
|
+
|
|
4
|
+
@example
|
|
5
|
+
|
|
6
|
+
_.animate("popanimation",
|
|
7
|
+
["from",
|
|
8
|
+
{
|
|
9
|
+
transform: "scale3D(2)" ,
|
|
10
|
+
height: "10%",
|
|
11
|
+
"background-color": "#0000"
|
|
12
|
+
}],
|
|
13
|
+
|
|
14
|
+
["to",
|
|
15
|
+
{
|
|
16
|
+
transform: "scale3D(1)" ,
|
|
17
|
+
height: "100%",
|
|
18
|
+
"background-color": "#ff9800"
|
|
19
|
+
}]
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
declare type props = Record<string, string>;
|
|
24
|
+
export default function animate(indentifier: string, ...properties: props[]): void;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Write animation value in javascript
|
|
3
|
+
|
|
4
|
+
@example
|
|
5
|
+
|
|
6
|
+
_.animate("popanimation",
|
|
7
|
+
["from",
|
|
8
|
+
{
|
|
9
|
+
transform: "scale3D(2)" ,
|
|
10
|
+
height: "10%",
|
|
11
|
+
"background-color": "#0000"
|
|
12
|
+
}],
|
|
13
|
+
|
|
14
|
+
["to",
|
|
15
|
+
{
|
|
16
|
+
transform: "scale3D(1)" ,
|
|
17
|
+
height: "100%",
|
|
18
|
+
"background-color": "#ff9800"
|
|
19
|
+
}]
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
export default function animate(indentifier, ...properties) {
|
|
24
|
+
/*This is for creating css
|
|
25
|
+
animations using javascipt*/
|
|
26
|
+
const styS = "@keyframes " + indentifier + " " + "{", styE = "}", proplen = properties.length;
|
|
27
|
+
let style = " ", aniSty = " ", Animation = " ", totalAnimation = null;
|
|
28
|
+
const animationStep = (num) => {
|
|
29
|
+
for (const [k, v] of Object.entries(properties[num][1])) {
|
|
30
|
+
style += "" + k + ": " + v + ";";
|
|
31
|
+
}
|
|
32
|
+
aniSty += "" + properties[num][0] + "{" + style + "}";
|
|
33
|
+
return aniSty;
|
|
34
|
+
};
|
|
35
|
+
for (let i = 0; i < proplen; i++) {
|
|
36
|
+
Animation += animationStep(i);
|
|
37
|
+
}
|
|
38
|
+
let aniStyleTag = document.querySelector("style");
|
|
39
|
+
if (aniStyleTag === null) {
|
|
40
|
+
aniStyleTag = document.createElement("style");
|
|
41
|
+
}
|
|
42
|
+
aniStyleTag.media = "screen";
|
|
43
|
+
totalAnimation = aniStyleTag.innerHTML;
|
|
44
|
+
totalAnimation += styS + Animation + styE;
|
|
45
|
+
aniStyleTag.innerHTML = totalAnimation;
|
|
46
|
+
document.head.append(aniStyleTag);
|
|
47
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Write animation value in javascript
|
|
3
|
+
|
|
4
|
+
@example
|
|
5
|
+
|
|
6
|
+
_.animate("popanimation",
|
|
7
|
+
["from",
|
|
8
|
+
{
|
|
9
|
+
transform: "scale3D(2)" ,
|
|
10
|
+
height: "10%",
|
|
11
|
+
"background-color": "#0000"
|
|
12
|
+
}],
|
|
13
|
+
|
|
14
|
+
["to",
|
|
15
|
+
{
|
|
16
|
+
transform: "scale3D(1)" ,
|
|
17
|
+
height: "100%",
|
|
18
|
+
"background-color": "#ff9800"
|
|
19
|
+
}]
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
type props = Record<string, string>;
|
|
25
|
+
|
|
26
|
+
export default function animate(indentifier: string, ...properties: props[]) {
|
|
27
|
+
/*This is for creating css
|
|
28
|
+
animations using javascipt*/
|
|
29
|
+
const styS = "@keyframes " + indentifier + " " + "{",
|
|
30
|
+
styE = "}",
|
|
31
|
+
proplen = properties.length;
|
|
32
|
+
|
|
33
|
+
let style = " ",
|
|
34
|
+
aniSty = " ",
|
|
35
|
+
Animation = " ",
|
|
36
|
+
totalAnimation = null;
|
|
37
|
+
|
|
38
|
+
const animationStep = (num: number) => {
|
|
39
|
+
for (const [k, v] of Object.entries(properties[num][1])) {
|
|
40
|
+
style += "" + k + ": " + v + ";";
|
|
41
|
+
}
|
|
42
|
+
aniSty += "" + properties[num][0] + "{" + style + "}";
|
|
43
|
+
return aniSty;
|
|
44
|
+
};
|
|
45
|
+
for (let i = 0; i < proplen; i++) {
|
|
46
|
+
Animation += animationStep(i);
|
|
47
|
+
}
|
|
48
|
+
let aniStyleTag = document.querySelector("style");
|
|
49
|
+
if (aniStyleTag === null) {
|
|
50
|
+
aniStyleTag = document.createElement("style");
|
|
51
|
+
}
|
|
52
|
+
aniStyleTag.media = "screen";
|
|
53
|
+
totalAnimation = aniStyleTag.innerHTML;
|
|
54
|
+
totalAnimation += styS + Animation + styE;
|
|
55
|
+
aniStyleTag.innerHTML = totalAnimation;
|
|
56
|
+
document.head.append(aniStyleTag);
|
|
57
|
+
}
|
package/scripts/css.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Write CSS styles in Javascript
|
|
3
|
+
@example
|
|
4
|
+
|
|
5
|
+
css("#container",
|
|
6
|
+
{
|
|
7
|
+
height: "100%",
|
|
8
|
+
height: "100%",
|
|
9
|
+
background-color: "#ff9800"
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
css(".btn:hover",
|
|
13
|
+
{
|
|
14
|
+
height: "100%",
|
|
15
|
+
height: "100%",
|
|
16
|
+
background-color: "#ff9800"
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
*/
|
|
20
|
+
export default function css(indentifier: string, properties: Record<string, string>): void;
|