create-template-bricks 0.0.0-stage → 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/README.md +85 -2
- package/bin/cli.js +403 -0
- package/package.json +49 -4
- package/templates/base/.babelrc +18 -0
- package/templates/base/.editorconfig +22 -0
- package/templates/base/.eslintrc.json +130 -0
- package/templates/base/AGENTS.md +49 -0
- package/templates/base/README.md +121 -0
- package/templates/base/gulpfile.js +46 -0
- package/templates/base/package.json +82 -0
- package/templates/base/postcss.config.mjs +6 -0
- package/templates/base/src/assets/css/vendor/.gitkeep +0 -0
- package/templates/base/src/assets/fonts/.gitkeep +0 -0
- package/templates/base/src/assets/img/Logo.svg +32 -0
- package/templates/base/src/assets/img/favicons/favicon.ico +0 -0
- package/templates/base/src/assets/img/sprite/cup-bronze.png +0 -0
- package/templates/base/src/assets/img/sprite/cup-bronze@2x.png +0 -0
- package/templates/base/src/assets/img/sprite.png +0 -0
- package/templates/base/src/assets/img/sprite@2x.png +0 -0
- package/templates/base/src/assets/img/svg-sprite/close.svg +3 -0
- package/templates/base/src/assets/img/svg-sprite/favorite.svg +3 -0
- package/templates/base/src/assets/img/svg-sprite/keyboard.svg +3 -0
- package/templates/base/src/assets/js/vendor/.gitkeep +0 -0
- package/templates/base/src/styles/core/base.scss +31 -0
- package/templates/base/src/styles/core/extends.scss +11 -0
- package/templates/base/src/styles/core/fonts.scss +0 -0
- package/templates/base/src/styles/core/index.scss +10 -0
- package/templates/base/src/styles/core/keyframes.scss +49 -0
- package/templates/base/src/styles/core/layouts/footer.scss +1 -0
- package/templates/base/src/styles/core/layouts/header/index.scss +1 -0
- package/templates/base/src/styles/core/layouts/index.scss +2 -0
- package/templates/base/src/styles/core/page.scss +16 -0
- package/templates/base/src/styles/core/typography.scss +1 -0
- package/templates/base/src/styles/core/ui/icons.scss +31 -0
- package/templates/base/src/styles/core/ui/index.scss +2 -0
- package/templates/base/src/styles/core/ui/scrollbar.scss +14 -0
- package/templates/base/src/styles/core/variables.scss +41 -0
- package/templates/base/src/styles/index.scss +1 -0
- package/templates/base/src/styles/plugins/functions.scss +0 -0
- package/templates/base/src/styles/plugins/media.scss +63 -0
- package/templates/base/src/styles/plugins/mixins.scss +31 -0
- package/templates/base/src/styles/plugins/sprite-mixin.scss +75 -0
- package/templates/base/src/styles/plugins/sprite.scss +154 -0
- package/templates/base/src/styles.scss +2 -0
- package/templates/base/src/tailwind.css +1 -0
- package/templates/base/src/tmplConfig.js +22 -0
- package/templates/base/tailwind.config.js +23 -0
- package/templates/base/tasks/archive.js +37 -0
- package/templates/base/tasks/clean.js +17 -0
- package/templates/base/tasks/config.js +98 -0
- package/templates/base/tasks/copy.js +53 -0
- package/templates/base/tasks/helper.js +31 -0
- package/templates/base/tasks/images/image-optimize.js +46 -0
- package/templates/base/tasks/images/index.js +27 -0
- package/templates/base/tasks/images/plugins/optimize-raster.js +44 -0
- package/templates/base/tasks/images/png-sprite.js +43 -0
- package/templates/base/tasks/template/data.js +28 -0
- package/templates/base/tasks/template/index.js +48 -0
- package/templates/base/tasks/template/plugins/generate-static-path.js +37 -0
- package/templates/base/tasks/template/plugins/nunjucks-relative-paths-includes.js +39 -0
- package/templates/base/tasks/template/plugins/nunjucks-relative-system-loader.js +28 -0
- package/templates/base/tasks/template/plugins/template-dependencies.js +246 -0
- package/templates/base/tasks/template/template.js +172 -0
- package/templates/base/tasks/watcher.js +233 -0
- package/templates/base/tasks/webpack/env.js +21 -0
- package/templates/base/tasks/webpack/plugins/build-status-plugin.js +74 -0
- package/templates/base/tasks/webpack/plugins/current-color-plugin.js +225 -0
- package/templates/base/tasks/webpack/plugins/removeFilesOnlyJs.js +28 -0
- package/templates/base/tasks/webpack/scripts.config.js +147 -0
- package/templates/base/tasks/webpack/styles.config.js +126 -0
- package/templates/base/tasks/webpack/svg-sprite.config.js +95 -0
- package/templates/base/tasks/webpack/watch.js +50 -0
- package/templates/base/tsconfig.json +20 -0
- package/templates/base/user.config.js +102 -0
- package/templates/base/webpack.config.js +9 -0
- package/templates/template-js/js/api/api.js +0 -0
- package/templates/template-js/js/core/core.js +56 -0
- package/templates/template-js/js/main.js +6 -0
- package/templates/template-js/js/modules/header.js +15 -0
- package/templates/template-js/js/modules/index.js +24 -0
- package/templates/template-js/js/services/index.js +1 -0
- package/templates/template-js/js/services/query-params.js +19 -0
- package/templates/template-js/js/styles.js +2 -0
- package/templates/template-js/js/ui/index.js +18 -0
- package/templates/template-js/js/utils/constants.js +0 -0
- package/templates/template-js/js/utils/create-factory.js +65 -0
- package/templates/template-js/js/utils/debounce.js +8 -0
- package/templates/template-js/js/utils/delay.js +4 -0
- package/templates/template-js/js/utils/is-platform.js +15 -0
- package/templates/template-js/js/utils/throttle.js +16 -0
- package/templates/template-mjml/emails/assets/images/address-btn.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/address.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/banner.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/close.png +0 -0
- package/templates/template-mjml/emails/assets/images/confirm-btn.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/facebook.png +0 -0
- package/templates/template-mjml/emails/assets/images/forgot.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/icon-info.png +0 -0
- package/templates/template-mjml/emails/assets/images/img-send.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/instagram.png +0 -0
- package/templates/template-mjml/emails/assets/images/logo.png +0 -0
- package/templates/template-mjml/emails/assets/images/reset-btn.jpg +0 -0
- package/templates/template-mjml/emails/assets/images/twitter.png +0 -0
- package/templates/template-mjml/emails/pages/address.mjml +55 -0
- package/templates/template-mjml/emails/pages/confirm-resend.mjml +63 -0
- package/templates/template-mjml/emails/pages/confirm.mjml +44 -0
- package/templates/template-mjml/emails/pages/forgot-password.mjml +65 -0
- package/templates/template-mjml/emails/shared/ui/head/fonts.mjml +211 -0
- package/templates/template-mjml/emails/shared/ui/head/index.mjml +146 -0
- package/templates/template-mjml/emails/widgets/footer/ui/index.mjml +12 -0
- package/templates/template-nunjucks/templates/layouts/base.njk +23 -0
- package/templates/template-nunjucks/templates/pages/index.njk +9 -0
- package/templates/template-nunjucks/templates/shared/ui/head/data.json +8 -0
- package/templates/template-nunjucks/templates/shared/ui/head/index.njk +13 -0
- package/templates/template-nunjucks/templates/shared/ui/icon/index.njk +5 -0
- package/templates/template-nunjucks/templates/widgets/footer/index.njk +5 -0
- package/templates/template-nunjucks/templates/widgets/footer/model/data.json +4 -0
- package/templates/template-nunjucks/templates/widgets/footer/ui/index.njk +7 -0
- package/templates/template-nunjucks/templates/widgets/home-hero/index.njk +1 -0
- package/templates/template-nunjucks/templates/widgets/home-hero/ui/index.njk +9 -0
- package/templates/template-pug/templates/layouts/base.pug +19 -0
- package/templates/template-pug/templates/pages/index.pug +12 -0
- package/templates/template-pug/templates/shared/lib/blocks.pug +21 -0
- package/templates/template-pug/templates/shared/ui/head/data.json +8 -0
- package/templates/template-pug/templates/shared/ui/head/index.pug +10 -0
- package/templates/template-pug/templates/shared/ui/icon/index.pug +3 -0
- package/templates/template-pug/templates/widgets/footer/index.pug +1 -0
- package/templates/template-pug/templates/widgets/footer/model/data.json +4 -0
- package/templates/template-pug/templates/widgets/footer/ui/index.pug +4 -0
- package/templates/template-pug/templates/widgets/home-hero/index.pug +1 -0
- package/templates/template-pug/templates/widgets/home-hero/ui/index.pug +6 -0
- package/templates/template-ts/ts/api/api.ts +0 -0
- package/templates/template-ts/ts/core/core.ts +66 -0
- package/templates/template-ts/ts/interfaces/factory.ts +5 -0
- package/templates/template-ts/ts/main.ts +6 -0
- package/templates/template-ts/ts/modules/header.ts +17 -0
- package/templates/template-ts/ts/modules/index.ts +26 -0
- package/templates/template-ts/ts/services/index.ts +2 -0
- package/templates/template-ts/ts/services/query-params.ts +23 -0
- package/templates/template-ts/ts/styles.ts +2 -0
- package/templates/template-ts/ts/ui/index.ts +23 -0
- package/templates/template-ts/ts/utils/constants.ts +0 -0
- package/templates/template-ts/ts/utils/create-factory.ts +91 -0
- package/templates/template-ts/ts/utils/debounce.ts +10 -0
- package/templates/template-ts/ts/utils/delay.ts +5 -0
- package/templates/template-ts/ts/utils/is-platform.ts +21 -0
- package/templates/template-ts/ts/utils/throttle.ts +19 -0
- package/templates/template-twig/templates/layouts/base.html.twig +26 -0
- package/templates/template-twig/templates/pages/index.html.twig +8 -0
- package/templates/template-twig/templates/shared/ui/head/data.json +8 -0
- package/templates/template-twig/templates/shared/ui/head/index.html.twig +11 -0
- package/templates/template-twig/templates/shared/ui/icon/index.html.twig +21 -0
- package/templates/template-twig/templates/widgets/footer/index.html.twig +1 -0
- package/templates/template-twig/templates/widgets/footer/model/data.json +4 -0
- package/templates/template-twig/templates/widgets/footer/ui/index.html.twig +5 -0
- package/templates/template-twig/templates/widgets/home-hero/index.html.twig +1 -0
- package/templates/template-twig/templates/widgets/home-hero/ui/index.html.twig +9 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<mj-head>
|
|
2
|
+
<!--[if gt mso 15]>
|
|
3
|
+
<mj-style type="text/css" media="all">
|
|
4
|
+
/* Outlook 2016 Height Fix */
|
|
5
|
+
table,
|
|
6
|
+
tr,
|
|
7
|
+
td {
|
|
8
|
+
border-collapse: collapse;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
tr {
|
|
12
|
+
font-size: 0px;
|
|
13
|
+
line-height: 0px;
|
|
14
|
+
border-collapse: collapse;
|
|
15
|
+
}
|
|
16
|
+
</mj-style>
|
|
17
|
+
<![endif]-->
|
|
18
|
+
<mj-attributes>
|
|
19
|
+
<mj-all font-family="Roboto, Arial, sans-serif" font-size="20px" padding="0" />
|
|
20
|
+
<mj-text color="#455A64" font-size="16px" line-height="160%" font-weight="500" align="center" />
|
|
21
|
+
<mj-button background-color="transparent" font-size="18px" font-weight="bold" line-height="125%" inner-padding="30px 80px 60px" border-radius="0" text-transform="uppercase" />
|
|
22
|
+
<mj-class name="text-default" font-size="16px" line-height="160%" font-weight="normal" letter-spacing="normal" font-style="normal" />
|
|
23
|
+
<mj-class name="text-sm" font-size="14px" line-height="140%" font-weight="normal" />
|
|
24
|
+
<mj-class name="text-small" font-size="12px" line-height="154%" font-weight="normal" color="#A6B2BF" />
|
|
25
|
+
</mj-attributes>
|
|
26
|
+
<mj-include path="fonts.mjml" />
|
|
27
|
+
<mj-style inline="inline">
|
|
28
|
+
body {
|
|
29
|
+
padding: 48px 15px;
|
|
30
|
+
background-color: #E5E5E5;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.wrapper {
|
|
34
|
+
margin: 48px 15px;
|
|
35
|
+
border-radius: 16px;
|
|
36
|
+
background-color: #ffffff;
|
|
37
|
+
box-shadow: 0px 12px 24px rgba(166, 178, 191, 0.1), 0px 1px 2px rgba(166, 178, 191, 0.1), 0px 8px 64px rgba(166, 178, 191, 0.1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
table {
|
|
41
|
+
width: 100%;
|
|
42
|
+
border-collapse: collapse;
|
|
43
|
+
border-spacing: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
a {
|
|
47
|
+
color: #455A64;
|
|
48
|
+
text-decoration: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
img {
|
|
52
|
+
display: inline-block;
|
|
53
|
+
height: auto;
|
|
54
|
+
max-width: 100%;
|
|
55
|
+
border: 0;
|
|
56
|
+
line-height: 1;
|
|
57
|
+
text-decoration: none;
|
|
58
|
+
outline: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.center {
|
|
62
|
+
display: block;
|
|
63
|
+
margin: auto;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.text-center {
|
|
67
|
+
text-align: center;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.text-default {
|
|
71
|
+
font-style: normal;
|
|
72
|
+
font-weight: normal;
|
|
73
|
+
font-size: 16px;
|
|
74
|
+
line-height: 160%;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.text-primary {
|
|
78
|
+
color: #8DC3C8;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.button {
|
|
82
|
+
display: inline-block;
|
|
83
|
+
background-repeat: no-repeat;
|
|
84
|
+
background-position: top center;
|
|
85
|
+
background-size: contain;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.button a {
|
|
89
|
+
display: inline-block;
|
|
90
|
+
border-radius: 0;
|
|
91
|
+
font-family: Arial, sans-serif;
|
|
92
|
+
font-size: 18px;
|
|
93
|
+
font-weight: 600;
|
|
94
|
+
line-height: 125%;
|
|
95
|
+
mso-padding-alt: 0px;
|
|
96
|
+
text-decoration: none;
|
|
97
|
+
background: transparent;
|
|
98
|
+
color: #ffffff;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.alert-container {
|
|
102
|
+
width: 550px;
|
|
103
|
+
padding-bottom: 24px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.alert {
|
|
107
|
+
font-weight: 500;
|
|
108
|
+
font-size: 16px;
|
|
109
|
+
line-height: 160%;
|
|
110
|
+
border-radius: 16px;
|
|
111
|
+
box-shadow: 0px 12px 24px rgba(64, 123, 255, 0.1), 0px 1px 2px rgba(64, 123, 255, 0.1), 0px 8px 64px rgba(64, 123, 255, 0.1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.alert--primary {
|
|
115
|
+
background-color: #407BFF;
|
|
116
|
+
color: #fff;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.alert__wrapper {
|
|
120
|
+
padding: 12px 0px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.alert__prepend {
|
|
124
|
+
width: 50px;
|
|
125
|
+
border-right: 1px solid rgba(255, 255, 255, 0.21);
|
|
126
|
+
background-repeat: no-repeat;
|
|
127
|
+
background-position: center center;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.alert__text {
|
|
131
|
+
padding-right: 7px;
|
|
132
|
+
padding-left: 16px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.alert__close {
|
|
136
|
+
width: 34px;
|
|
137
|
+
background-repeat: no-repeat;
|
|
138
|
+
background-position: 0px 6px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.alert__close a {
|
|
142
|
+
display: block;
|
|
143
|
+
height: 23px;
|
|
144
|
+
}
|
|
145
|
+
</mj-style>
|
|
146
|
+
</mj-head>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<mj-section padding="0px 30px 52px">
|
|
2
|
+
<mj-column padding-top="20px" border-top="2px solid #EEF2F5">
|
|
3
|
+
<mj-table mj-class="text-small" align="center">
|
|
4
|
+
<tr>
|
|
5
|
+
<td style="padding: 0px 0px 4px" class="text-center">This email was sent to your as a registered member of Company. To unsubscribe <a href="#" class="text-primary" target="_blank">click here.</a> <br /> Use of the service and website is subject to our <a href="#" class="text-primary" target="_blank">Terms of Service</a> and <a href="#" class="text-primary" target="_blank">Privacy Policy.</a></td>
|
|
6
|
+
</tr>
|
|
7
|
+
<tr>
|
|
8
|
+
<td style="padding: 4px 0px" class="text-center">© 2021 Company. All rights reserved.</td>
|
|
9
|
+
</tr>
|
|
10
|
+
</mj-table>
|
|
11
|
+
</mj-column>
|
|
12
|
+
</mj-section>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{% import "../shared/ui/head/index.njk" as Head with context %}
|
|
2
|
+
{% from "../widgets/footer/index.njk" import Footer with context %}
|
|
3
|
+
|
|
4
|
+
<!DOCTYPE html>
|
|
5
|
+
<html lang="{{ lang }}">
|
|
6
|
+
{{ Head.content(head.default, pathPrefix) }}
|
|
7
|
+
<body>
|
|
8
|
+
%symbols%
|
|
9
|
+
<div class="page-wrapper">
|
|
10
|
+
{% block header %}{% endblock %}
|
|
11
|
+
<main class="page-content">
|
|
12
|
+
{% block content %}{% endblock %}
|
|
13
|
+
</main>
|
|
14
|
+
{% block footer %}
|
|
15
|
+
{{ Footer(footer.default) }}
|
|
16
|
+
{% endblock %}
|
|
17
|
+
</div>
|
|
18
|
+
{% block scripts %}
|
|
19
|
+
<script src="{{ staticPath.js }}/vendor.js{{ version }}"></script>
|
|
20
|
+
<script src="{{ staticPath.js }}/main.js{{ version }}"></script>
|
|
21
|
+
{% endblock %}
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{% macro content(data, path) %}
|
|
2
|
+
<head>
|
|
3
|
+
<meta charset="utf-8"/>
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
5
|
+
<title>{{ page.title if page.title else data.title }}</title>
|
|
6
|
+
<meta name="description" content="{{ data.description }}"/>
|
|
7
|
+
{% block styles %}
|
|
8
|
+
<link href="{{ staticPath.css }}/vendor.css{{ version }}" rel="stylesheet">
|
|
9
|
+
<link href="{{ staticPath.css }}/styles.css{{ version }}" rel="stylesheet">
|
|
10
|
+
{% endblock %}
|
|
11
|
+
<link rel="icon" type="image/x-icon" href="{{ staticPath.img }}/favicons/apple-icon-57x57.png"/>
|
|
12
|
+
</head>
|
|
13
|
+
{% endmacro %}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{% macro svg(name, width, height) %}
|
|
2
|
+
<svg class="icon-{{ name }}" width="{{ width }}" height="{{ height }}">
|
|
3
|
+
<use xlink:href="{% if symbolsInject %} #{{ name -}} {% else %} {{- PATH }}assets/img/symbols.svg{{ version }}#{{ name -}} {% endif %}"></use>
|
|
4
|
+
</svg>
|
|
5
|
+
{% endmacro %}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{% include "./ui/index.njk" %}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div class="container">
|
|
2
|
+
<div class="mt-12">
|
|
3
|
+
<img src="{{ images.logo }}" width="200" alt="">
|
|
4
|
+
</div>
|
|
5
|
+
<h1 class="text-4xl md:text-[120px] font-bold">{{ page.title }}</h1>
|
|
6
|
+
<p class="mt-10">
|
|
7
|
+
Create projects from ready-to-use frontend templates.
|
|
8
|
+
</p>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
block components
|
|
2
|
+
include ../shared/ui/head/index
|
|
3
|
+
include ../shared/lib/blocks
|
|
4
|
+
include ../widgets/footer/index
|
|
5
|
+
|
|
6
|
+
doctype html
|
|
7
|
+
html.no-js(lang=lang)
|
|
8
|
+
+Head(head.default)
|
|
9
|
+
body()&attributes(page.attrs)
|
|
10
|
+
| %symbols%
|
|
11
|
+
.page-wrapper
|
|
12
|
+
block header
|
|
13
|
+
main.page-content&attributes(page.content)
|
|
14
|
+
block content
|
|
15
|
+
block footer
|
|
16
|
+
+Footer()
|
|
17
|
+
block bottom
|
|
18
|
+
script(src=`${staticPath.js}/vendor.js${version}`)
|
|
19
|
+
script(src=`${staticPath.js}/main.js${version}`)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//- this object will store the names (keys) of our mixin blocks
|
|
2
|
+
- const blocks = {};
|
|
3
|
+
|
|
4
|
+
//- store block function
|
|
5
|
+
mixin set(key)
|
|
6
|
+
- blocks[key] = this.block
|
|
7
|
+
|
|
8
|
+
//- an example to demonstrate how it works
|
|
9
|
+
mixin layout
|
|
10
|
+
block
|
|
11
|
+
.main
|
|
12
|
+
- blocks.main()
|
|
13
|
+
.side
|
|
14
|
+
- blocks.side()
|
|
15
|
+
|
|
16
|
+
//- mixin calls that blocks
|
|
17
|
+
+layout
|
|
18
|
+
+set('main')
|
|
19
|
+
p Main
|
|
20
|
+
+set('side')
|
|
21
|
+
p Side
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
mixin Head(data)
|
|
2
|
+
head
|
|
3
|
+
meta(charset='utf-8')
|
|
4
|
+
meta(name='viewport' content='width=device-width, initial-scale=1.0')
|
|
5
|
+
title=page.title ? page.title : data.title
|
|
6
|
+
meta(name='description', content=data.description)
|
|
7
|
+
link(rel="icon" type="image/x-icon" href=`${staticPath.img}/favicons/favicon.ico`)
|
|
8
|
+
block styles
|
|
9
|
+
link(rel='stylesheet', href=`${staticPath.css}/vendor.css${version}`)
|
|
10
|
+
link(rel='stylesheet', href=`${staticPath.css}/styles.css${version}`)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include ui/index
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include ui/index
|
|
File without changes
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import uiModules from '../ui/index';
|
|
2
|
+
import { isPlatformClasses } from '../utils/is-platform';
|
|
3
|
+
import { IFactory } from '../interfaces/factory';
|
|
4
|
+
|
|
5
|
+
export class BaseApp {
|
|
6
|
+
private readonly createModules: () => IFactory;
|
|
7
|
+
|
|
8
|
+
private ui: IFactory | null = null;
|
|
9
|
+
|
|
10
|
+
private modules: IFactory | null = null;
|
|
11
|
+
|
|
12
|
+
constructor(createModules: () => IFactory) {
|
|
13
|
+
this.createModules = createModules;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
onStart = (): void => {
|
|
17
|
+
this.init();
|
|
18
|
+
this.afterLoad();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
init(): void {
|
|
22
|
+
isPlatformClasses();
|
|
23
|
+
this.ui = uiModules();
|
|
24
|
+
this.modules = this.createModules();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
destroy(): void {
|
|
28
|
+
if (this.ui && typeof this.ui.destroy === 'function') {
|
|
29
|
+
this.ui.destroy();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (this.modules && typeof this.modules.destroy === 'function') {
|
|
33
|
+
this.modules.destroy();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.ui = null;
|
|
37
|
+
this.modules = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
afterLoad(): void {
|
|
41
|
+
if (document.readyState === 'complete') {
|
|
42
|
+
this.markLoaded();
|
|
43
|
+
} else {
|
|
44
|
+
window.addEventListener('load', this.markLoaded, { once: true });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
markLoaded = (): void => {
|
|
49
|
+
document.body?.classList.add('load');
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function bootstrapApp<T extends BaseApp>(
|
|
54
|
+
AppClass: new (createModules: () => IFactory) => T,
|
|
55
|
+
modulesFactory: () => IFactory
|
|
56
|
+
): T {
|
|
57
|
+
const app = new AppClass(modulesFactory);
|
|
58
|
+
|
|
59
|
+
if (document.readyState === 'loading') {
|
|
60
|
+
document.addEventListener('DOMContentLoaded', app.onStart, { once: true });
|
|
61
|
+
} else {
|
|
62
|
+
app.onStart();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return app;
|
|
66
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import createFactory from '../utils/create-factory';
|
|
2
|
+
import Header from './header';
|
|
3
|
+
import { IFactory } from '../interfaces/factory';
|
|
4
|
+
|
|
5
|
+
const createModules = (): IFactory => {
|
|
6
|
+
const factory = createFactory();
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
onInit: (): void => {
|
|
10
|
+
factory.create(Header);
|
|
11
|
+
},
|
|
12
|
+
destroy: (): void => {
|
|
13
|
+
factory.destroy();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const modulesComponent = (): IFactory => {
|
|
19
|
+
const factory = createModules();
|
|
20
|
+
|
|
21
|
+
factory.onInit();
|
|
22
|
+
|
|
23
|
+
return factory;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default modulesComponent;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type QueryParamsValue = string | number | boolean | null | undefined;
|
|
2
|
+
|
|
3
|
+
export type QueryParams = Record<string, QueryParamsValue | QueryParamsValue[]>;
|
|
4
|
+
|
|
5
|
+
export const createQueryString = (params: QueryParams): string => {
|
|
6
|
+
const searchParams = new URLSearchParams();
|
|
7
|
+
|
|
8
|
+
Object.entries(params).forEach(([ key, value ]) => {
|
|
9
|
+
const values = Array.isArray(value) ? value : [ value ];
|
|
10
|
+
|
|
11
|
+
values.forEach((item) => {
|
|
12
|
+
if (item === null || item === undefined || item === '') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
searchParams.append(key, String(item));
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const queryString = searchParams.toString();
|
|
21
|
+
|
|
22
|
+
return queryString ? `?${queryString}` : '';
|
|
23
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import createFactory from '../utils/create-factory';
|
|
2
|
+
import { IFactory } from '../interfaces/factory';
|
|
3
|
+
|
|
4
|
+
const createUi = (): IFactory => {
|
|
5
|
+
const factory = createFactory();
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
onInit: (): void => {
|
|
9
|
+
},
|
|
10
|
+
destroy: (): void => {
|
|
11
|
+
factory.destroy();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const uiModules = (): IFactory => {
|
|
17
|
+
const factory = createUi();
|
|
18
|
+
factory.onInit();
|
|
19
|
+
return factory;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default uiModules;
|
|
23
|
+
|
|
File without changes
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { IFactory } from '../interfaces/factory';
|
|
2
|
+
type Constructor<T> = new (...args: any[]) => T;
|
|
3
|
+
|
|
4
|
+
const createFactory = () => {
|
|
5
|
+
const instances: IFactory[] = [];
|
|
6
|
+
const listeners: Array<() => void> = [];
|
|
7
|
+
|
|
8
|
+
const runInit = <T extends IFactory>(instance: T): T => {
|
|
9
|
+
if (instance && typeof instance.onInit === 'function') {
|
|
10
|
+
instance.onInit();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return instance;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const create = <T>(Ctor: Constructor<T>, ...args: any[]): T => {
|
|
17
|
+
const instance = new Ctor(...args);
|
|
18
|
+
instances.push(instance as unknown as IFactory);
|
|
19
|
+
|
|
20
|
+
return instance;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const createAndInit = <T extends IFactory>(Ctor: Constructor<T>, ...args: any[]): T => {
|
|
24
|
+
return runInit(create(Ctor, ...args) as T);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const register = <T extends IFactory>(instance: T): T => {
|
|
28
|
+
if (instance) {
|
|
29
|
+
instances.push(instance);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return instance;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const createMany = <T>(selector: string, Ctor: Constructor<T>, ...args: any[]): T[] => {
|
|
36
|
+
return Array.from(document.querySelectorAll(selector)).map((element) => {
|
|
37
|
+
return create(Ctor, element, ...args);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const createManyAndInit = <T extends IFactory>(selector: string, Ctor: Constructor<T>, ...args: any[]): T[] => {
|
|
42
|
+
return Array.from(document.querySelectorAll(selector)).map((element) => {
|
|
43
|
+
return createAndInit(Ctor, element, ...args);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const listen = (
|
|
48
|
+
target: EventTarget | null | undefined,
|
|
49
|
+
eventName: string,
|
|
50
|
+
handler: EventListenerOrEventListenerObject,
|
|
51
|
+
options?: boolean | AddEventListenerOptions
|
|
52
|
+
): (() => void) => {
|
|
53
|
+
if (!target || typeof target.addEventListener !== 'function') {
|
|
54
|
+
return () => {};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
target.addEventListener(eventName, handler, options);
|
|
58
|
+
|
|
59
|
+
const unsubscribe = () => target.removeEventListener(eventName, handler, options);
|
|
60
|
+
listeners.push(unsubscribe);
|
|
61
|
+
|
|
62
|
+
return unsubscribe;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const destroy = (): void => {
|
|
66
|
+
listeners.forEach((unsubscribe) => unsubscribe());
|
|
67
|
+
listeners.length = 0;
|
|
68
|
+
|
|
69
|
+
instances.forEach((instance) => {
|
|
70
|
+
if (instance && typeof instance.destroy === 'function') {
|
|
71
|
+
instance.destroy();
|
|
72
|
+
} else if (instance && typeof instance.dispose === 'function') {
|
|
73
|
+
instance.dispose();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
instances.length = 0;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
create,
|
|
82
|
+
createAndInit,
|
|
83
|
+
register,
|
|
84
|
+
createMany,
|
|
85
|
+
createManyAndInit,
|
|
86
|
+
listen,
|
|
87
|
+
destroy
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default createFactory;
|