@tsparticles/template-login 4.1.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/LICENSE +21 -0
- package/package.json +14 -0
- package/scripts/prebuild.js +65 -0
- package/template/vanilla/README.md +10 -0
- package/template/vanilla/gitignore +14 -0
- package/template/vanilla/index.html +43 -0
- package/template/vanilla/package.json +11 -0
- package/template/vanilla/src/main.ts +142 -0
- package/template/vanilla/src/style.css +151 -0
- package/template/vanilla/tsconfig.json +19 -0
- package/template/vanilla/vite.config.ts +5 -0
- package/template.json +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Matteo Bruni
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsparticles/template-login",
|
|
3
|
+
"version": "4.1.3",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prebuild": "node scripts/prebuild.js",
|
|
10
|
+
"build": "pnpm run prebuild",
|
|
11
|
+
"build:ci": "pnpm run prebuild"
|
|
12
|
+
},
|
|
13
|
+
"gitHead": "0551736c55ae8eec3855a693af8a99b1b4420350"
|
|
14
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const fs = require("fs-extra");
|
|
2
|
+
|
|
3
|
+
const libPackage = "./template.json";
|
|
4
|
+
|
|
5
|
+
const workspaceVersions = {
|
|
6
|
+
"@tsparticles/engine": require("../../../engine/package.json").version,
|
|
7
|
+
"@tsparticles/slim": require("../../../bundles/slim/package.json").version,
|
|
8
|
+
"@tsparticles/configs": require("../../../utils/configs/package.json").version,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function resolveWorkspaceDependency(name) {
|
|
12
|
+
const libObj = JSON.parse(fs.readFileSync(libPackage, "utf-8"));
|
|
13
|
+
|
|
14
|
+
const allDeps = {
|
|
15
|
+
...libObj.package.dependencies,
|
|
16
|
+
...libObj.package.devDependencies,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const spec = allDeps[name];
|
|
20
|
+
|
|
21
|
+
if (!spec?.startsWith("workspace:")) {
|
|
22
|
+
return spec;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const workspaceRange = spec.replace("workspace:", "");
|
|
26
|
+
|
|
27
|
+
if (workspaceRange.length > 0 && workspaceRange !== "*" && workspaceRange !== "^" && workspaceRange !== "~") {
|
|
28
|
+
return workspaceRange;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const version = workspaceVersions[name];
|
|
32
|
+
|
|
33
|
+
if (!version) {
|
|
34
|
+
throw new Error(`Cannot resolve workspace dependency version for ${name}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return workspaceRange === "^" || workspaceRange === "~" ? `${workspaceRange}${version}` : `^${version}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fs.readFile(libPackage, function (error, data) {
|
|
41
|
+
if (error) {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const text = data.toString();
|
|
46
|
+
const libObj = JSON.parse(text);
|
|
47
|
+
|
|
48
|
+
for (const dep of Object.keys(libObj.package.dependencies)) {
|
|
49
|
+
const resolved = resolveWorkspaceDependency(dep);
|
|
50
|
+
if (resolved) {
|
|
51
|
+
libObj.package.dependencies[dep] = resolved;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
for (const dep of Object.keys(libObj.package.devDependencies)) {
|
|
56
|
+
const resolved = resolveWorkspaceDependency(dep);
|
|
57
|
+
if (resolved) {
|
|
58
|
+
libObj.package.devDependencies[dep] = resolved;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fs.writeFile(libPackage, JSON.stringify(libObj, undefined, 2), "utf-8", function () {
|
|
63
|
+
console.log("template.json dependencies updated successfully");
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>{{projectName}}</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app">
|
|
10
|
+
<div class="auth-container">
|
|
11
|
+
<div class="auth-card">
|
|
12
|
+
<div class="auth-header">
|
|
13
|
+
<h1 id="authTitle">Login</h1>
|
|
14
|
+
<button id="themeToggle" class="theme-btn" aria-label="Toggle theme">🌙</button>
|
|
15
|
+
</div>
|
|
16
|
+
<form id="authForm" novalidate>
|
|
17
|
+
<div class="form-group">
|
|
18
|
+
<label for="email">Email</label>
|
|
19
|
+
<input type="email" id="email" placeholder="you@example.com" required />
|
|
20
|
+
<span class="error" id="emailError"></span>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="form-group">
|
|
23
|
+
<label for="password">Password</label>
|
|
24
|
+
<input type="password" id="password" placeholder="Enter password" required />
|
|
25
|
+
<span class="error" id="passwordError"></span>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="form-group" id="confirmGroup" style="display: none">
|
|
28
|
+
<label for="confirmPassword">Confirm Password</label>
|
|
29
|
+
<input type="password" id="confirmPassword" placeholder="Confirm password" />
|
|
30
|
+
<span class="error" id="confirmError"></span>
|
|
31
|
+
</div>
|
|
32
|
+
<button type="submit" id="submitBtn">Sign In</button>
|
|
33
|
+
</form>
|
|
34
|
+
<p class="toggle-text">
|
|
35
|
+
<span id="toggleLabel">Don't have an account?</span>
|
|
36
|
+
<a href="#" id="toggleAuth">Register</a>
|
|
37
|
+
</p>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<script type="module" src="/src/main.ts"></script>
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import "./style.css";
|
|
2
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
3
|
+
import { loadSlim } from "@tsparticles/slim";
|
|
4
|
+
|
|
5
|
+
let isLogin = true;
|
|
6
|
+
|
|
7
|
+
const authTitle = document.getElementById("authTitle") as HTMLHeadingElement;
|
|
8
|
+
const authForm = document.getElementById("authForm") as HTMLFormElement;
|
|
9
|
+
const submitBtn = document.getElementById("submitBtn") as HTMLButtonElement;
|
|
10
|
+
const toggleAuth = document.getElementById("toggleAuth") as HTMLAnchorElement;
|
|
11
|
+
const toggleLabel = document.getElementById("toggleLabel") as HTMLSpanElement;
|
|
12
|
+
const confirmGroup = document.getElementById("confirmGroup") as HTMLDivElement;
|
|
13
|
+
const themeToggle = document.getElementById("themeToggle") as HTMLButtonElement;
|
|
14
|
+
|
|
15
|
+
const emailInput = document.getElementById("email") as HTMLInputElement;
|
|
16
|
+
const passwordInput = document.getElementById("password") as HTMLInputElement;
|
|
17
|
+
const confirmInput = document.getElementById("confirmPassword") as HTMLInputElement;
|
|
18
|
+
|
|
19
|
+
const emailError = document.getElementById("emailError") as HTMLSpanElement;
|
|
20
|
+
const passwordError = document.getElementById("passwordError") as HTMLSpanElement;
|
|
21
|
+
const confirmError = document.getElementById("confirmError") as HTMLSpanElement;
|
|
22
|
+
|
|
23
|
+
function setTheme(theme: string): void {
|
|
24
|
+
document.documentElement.setAttribute("data-theme", theme);
|
|
25
|
+
themeToggle.textContent = theme === "dark" ? "🌙" : "☀️";
|
|
26
|
+
localStorage.setItem("theme", theme);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function toggleTheme(): void {
|
|
30
|
+
const current = document.documentElement.getAttribute("data-theme") || "dark";
|
|
31
|
+
setTheme(current === "dark" ? "light" : "dark");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const savedTheme = localStorage.getItem("theme") || "dark";
|
|
35
|
+
setTheme(savedTheme);
|
|
36
|
+
|
|
37
|
+
themeToggle.addEventListener("click", toggleTheme);
|
|
38
|
+
|
|
39
|
+
function validateEmail(email: string): boolean {
|
|
40
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function validate(): boolean {
|
|
44
|
+
let valid = true;
|
|
45
|
+
|
|
46
|
+
if (!emailInput.value || !validateEmail(emailInput.value)) {
|
|
47
|
+
emailError.textContent = "Please enter a valid email address";
|
|
48
|
+
valid = false;
|
|
49
|
+
} else {
|
|
50
|
+
emailError.textContent = "";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!passwordInput.value || passwordInput.value.length < 6) {
|
|
54
|
+
passwordError.textContent = "Password must be at least 6 characters";
|
|
55
|
+
valid = false;
|
|
56
|
+
} else {
|
|
57
|
+
passwordError.textContent = "";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!isLogin) {
|
|
61
|
+
if (passwordInput.value !== confirmInput.value) {
|
|
62
|
+
confirmError.textContent = "Passwords do not match";
|
|
63
|
+
valid = false;
|
|
64
|
+
} else {
|
|
65
|
+
confirmError.textContent = "";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return valid;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function toggleMode(): void {
|
|
73
|
+
isLogin = !isLogin;
|
|
74
|
+
|
|
75
|
+
authTitle.textContent = isLogin ? "Login" : "Register";
|
|
76
|
+
submitBtn.textContent = isLogin ? "Sign In" : "Create Account";
|
|
77
|
+
toggleLabel.textContent = isLogin ? "Don't have an account?" : "Already have an account?";
|
|
78
|
+
toggleAuth.textContent = isLogin ? "Register" : "Login";
|
|
79
|
+
confirmGroup.style.display = isLogin ? "none" : "block";
|
|
80
|
+
|
|
81
|
+
emailError.textContent = "";
|
|
82
|
+
passwordError.textContent = "";
|
|
83
|
+
confirmError.textContent = "";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
toggleAuth.addEventListener("click", (e) => {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
toggleMode();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
authForm.addEventListener("submit", (e) => {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
|
|
94
|
+
if (!validate()) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (isLogin) {
|
|
99
|
+
alert("Logged in successfully! (demo)");
|
|
100
|
+
} else {
|
|
101
|
+
alert("Account created successfully! (demo)");
|
|
102
|
+
toggleMode();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
authForm.reset();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
(async () => {
|
|
109
|
+
await loadSlim(tsParticles);
|
|
110
|
+
|
|
111
|
+
await tsParticles.load({
|
|
112
|
+
id: "tsparticles",
|
|
113
|
+
options: {
|
|
114
|
+
background: { color: { value: "transparent" } },
|
|
115
|
+
fpsLimit: 60,
|
|
116
|
+
particles: {
|
|
117
|
+
number: { value: 60, density: { enable: true } },
|
|
118
|
+
color: { value: ["#6c5ce7", "#a29bfe", "#fd79a8", "#00cec9"] },
|
|
119
|
+
shape: { type: "circle" },
|
|
120
|
+
opacity: { value: 0.5, random: true },
|
|
121
|
+
size: { value: { min: 1, max: 3 }, random: true },
|
|
122
|
+
move: {
|
|
123
|
+
enable: true,
|
|
124
|
+
speed: 1,
|
|
125
|
+
direction: "none",
|
|
126
|
+
random: true,
|
|
127
|
+
straight: false,
|
|
128
|
+
outModes: { default: "out" },
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
interactivity: {
|
|
132
|
+
events: {
|
|
133
|
+
onHover: { enable: true, mode: "bubble" },
|
|
134
|
+
},
|
|
135
|
+
modes: {
|
|
136
|
+
bubble: { distance: 200, size: 6, duration: 2, opacity: 0.8 },
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
detectRetina: true,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
})();
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--bg: #0f0f1a;
|
|
3
|
+
--card-bg: rgba(255, 255, 255, 0.05);
|
|
4
|
+
--text: #fff;
|
|
5
|
+
--border: rgba(255, 255, 255, 0.1);
|
|
6
|
+
--input-bg: rgba(255, 255, 255, 0.08);
|
|
7
|
+
--accent: #6c5ce7;
|
|
8
|
+
--accent-hover: #a29bfe;
|
|
9
|
+
--error: #e74c3c;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[data-theme="light"] {
|
|
13
|
+
--bg: #f0f0f5;
|
|
14
|
+
--card-bg: rgba(255, 255, 255, 0.8);
|
|
15
|
+
--text: #1a1a2e;
|
|
16
|
+
--border: rgba(0, 0, 0, 0.1);
|
|
17
|
+
--input-bg: rgba(0, 0, 0, 0.05);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
* {
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
body {
|
|
25
|
+
margin: 0;
|
|
26
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
27
|
+
background: var(--bg);
|
|
28
|
+
color: var(--text);
|
|
29
|
+
transition: background 0.3s, color 0.3s;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.auth-container {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 50%;
|
|
35
|
+
left: 50%;
|
|
36
|
+
transform: translate(-50%, -50%);
|
|
37
|
+
z-index: 10;
|
|
38
|
+
width: 100%;
|
|
39
|
+
max-width: 400px;
|
|
40
|
+
padding: 1rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.auth-card {
|
|
44
|
+
background: var(--card-bg);
|
|
45
|
+
backdrop-filter: blur(10px);
|
|
46
|
+
border: 1px solid var(--border);
|
|
47
|
+
border-radius: 16px;
|
|
48
|
+
padding: 2rem;
|
|
49
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.auth-header {
|
|
53
|
+
display: flex;
|
|
54
|
+
justify-content: space-between;
|
|
55
|
+
align-items: center;
|
|
56
|
+
margin-bottom: 1.5rem;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.auth-header h1 {
|
|
60
|
+
margin: 0;
|
|
61
|
+
font-size: 1.8em;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.theme-btn {
|
|
65
|
+
background: none;
|
|
66
|
+
border: 1px solid var(--border);
|
|
67
|
+
border-radius: 8px;
|
|
68
|
+
padding: 0.4em 0.6em;
|
|
69
|
+
font-size: 1.2em;
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
transition: background 0.2s;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.theme-btn:hover {
|
|
75
|
+
background: var(--input-bg);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.form-group {
|
|
79
|
+
margin-bottom: 1rem;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
label {
|
|
83
|
+
display: block;
|
|
84
|
+
margin-bottom: 0.3em;
|
|
85
|
+
font-size: 0.9em;
|
|
86
|
+
opacity: 0.8;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
input {
|
|
90
|
+
width: 100%;
|
|
91
|
+
padding: 0.7em 1em;
|
|
92
|
+
font-size: 1em;
|
|
93
|
+
border: 1px solid var(--border);
|
|
94
|
+
border-radius: 8px;
|
|
95
|
+
background: var(--input-bg);
|
|
96
|
+
color: var(--text);
|
|
97
|
+
outline: none;
|
|
98
|
+
transition: border-color 0.2s;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
input:focus {
|
|
102
|
+
border-color: var(--accent);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
input::placeholder {
|
|
106
|
+
color: var(--text);
|
|
107
|
+
opacity: 0.4;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.error {
|
|
111
|
+
display: block;
|
|
112
|
+
margin-top: 0.3em;
|
|
113
|
+
font-size: 0.8em;
|
|
114
|
+
color: var(--error);
|
|
115
|
+
min-height: 1em;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
button[type="submit"] {
|
|
119
|
+
width: 100%;
|
|
120
|
+
padding: 0.8em;
|
|
121
|
+
font-size: 1em;
|
|
122
|
+
font-weight: 600;
|
|
123
|
+
border: none;
|
|
124
|
+
border-radius: 8px;
|
|
125
|
+
background: var(--accent);
|
|
126
|
+
color: #fff;
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
transition: background 0.2s;
|
|
129
|
+
margin-top: 0.5rem;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
button[type="submit"]:hover {
|
|
133
|
+
background: var(--accent-hover);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.toggle-text {
|
|
137
|
+
text-align: center;
|
|
138
|
+
margin-top: 1.5rem;
|
|
139
|
+
font-size: 0.9em;
|
|
140
|
+
opacity: 0.7;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.toggle-text a {
|
|
144
|
+
color: var(--accent);
|
|
145
|
+
text-decoration: none;
|
|
146
|
+
margin-left: 0.3em;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.toggle-text a:hover {
|
|
150
|
+
text-decoration: underline;
|
|
151
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"allowImportingTsExtensions": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"noUnusedLocals": true,
|
|
15
|
+
"noUnusedParameters": true,
|
|
16
|
+
"noFallthroughCasesInSwitch": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src"]
|
|
19
|
+
}
|
package/template.json
ADDED