@tsparticles/template-login 4.1.3 → 4.2.1
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/CHANGELOG.md +16 -0
- package/README.md +3 -0
- package/package.json +4 -3
- package/template/angular/package.json +34 -0
- package/template/angular/src/app/app.component.css +151 -0
- package/template/angular/src/app/app.component.html +32 -0
- package/template/angular/src/app/app.component.ts +105 -0
- package/template/angular/src/app/app.module.ts +13 -0
- package/template/angular-confetti/package.json +36 -0
- package/template/angular-confetti/src/app/app.component.css +151 -0
- package/template/angular-confetti/src/app/app.component.html +32 -0
- package/template/angular-confetti/src/app/app.component.ts +105 -0
- package/template/angular-confetti/src/app/app.module.ts +13 -0
- package/template/angular-fireworks/package.json +36 -0
- package/template/angular-fireworks/src/app/app.component.css +151 -0
- package/template/angular-fireworks/src/app/app.component.html +32 -0
- package/template/angular-fireworks/src/app/app.component.ts +105 -0
- package/template/angular-fireworks/src/app/app.module.ts +13 -0
- package/template/astro/package.json +22 -0
- package/template/astro/src/pages/index.astro +173 -0
- package/template/ember/app/templates/application.hbs +61 -0
- package/template/ember/package.json +42 -0
- package/template/inferno/package.json +24 -0
- package/template/inferno/src/App.css +151 -0
- package/template/inferno/src/App.tsx +158 -0
- package/template/jquery/package.json +22 -0
- package/template/jquery/src/main.ts +110 -0
- package/template/jquery/src/style.css +151 -0
- package/template/lit/package.json +22 -0
- package/template/lit/src/my-app.ts +143 -0
- package/template/nextjs/package.json +25 -0
- package/template/nextjs/src/app/page.tsx +168 -0
- package/template/nextjs/src/app/providers.tsx +13 -0
- package/template/nuxt2/package.json +17 -0
- package/template/nuxt2/pages/index.vue +303 -0
- package/template/nuxt3/app.vue +288 -0
- package/template/nuxt3/package.json +21 -0
- package/template/nuxt4/app.vue +288 -0
- package/template/nuxt4/package.json +21 -0
- package/template/preact/package.json +23 -0
- package/template/preact/src/App.css +151 -0
- package/template/preact/src/App.tsx +140 -0
- package/template/qwik/package.json +22 -0
- package/template/qwik/src/App.tsx +139 -0
- package/template/react/package.json +19 -0
- package/template/react/src/App.css +151 -0
- package/template/react/src/App.tsx +140 -0
- package/template/riot/package.json +24 -0
- package/template/riot/src/app.riot +156 -0
- package/template/solid/package.json +18 -0
- package/template/solid/src/App.tsx +169 -0
- package/template/solid/src/index.css +151 -0
- package/template/solid/src/main.tsx +9 -0
- package/template/stencil/package.json +20 -0
- package/template/stencil/src/components/app-home/app-home.tsx +164 -0
- package/template/svelte/package.json +20 -0
- package/template/svelte/src/App.svelte +325 -0
- package/template/svelte/src/main.ts +12 -0
- package/template/vanilla/LICENSE +21 -0
- package/template/vanilla/package.json +1 -1
- package/template/vanilla/src/main.ts +1 -1
- package/template/vue2/package.json +24 -0
- package/template/vue2/src/App.vue +287 -0
- package/template/vue3/package.json +19 -0
- package/template/vue3/src/App.vue +286 -0
- package/template/vue3/src/main.ts +14 -0
- package/template/webcomponents/package.json +21 -0
- package/template/webcomponents/src/main.ts +125 -0
- package/template/webcomponents/src/style.css +151 -0
|
@@ -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,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{packageName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"lit": "^3.5.0",
|
|
13
|
+
"@tsparticles/lit": "^4.1.3",
|
|
14
|
+
"@tsparticles/slim": "^4.1.3",
|
|
15
|
+
"@tsparticles/configs": "^4.1.3",
|
|
16
|
+
"@tsparticles/engine": "^4.1.3"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5.7.2",
|
|
20
|
+
"vite": "^6.0.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { LitElement, html } from "lit";
|
|
2
|
+
import { customElement, state } from "lit/decorators.js";
|
|
3
|
+
import type { ISourceOptions } from "@tsparticles/engine";
|
|
4
|
+
|
|
5
|
+
const options: ISourceOptions = {
|
|
6
|
+
background: { color: { value: "transparent" } },
|
|
7
|
+
fpsLimit: 60,
|
|
8
|
+
particles: {
|
|
9
|
+
number: { value: 60, density: { enable: true } },
|
|
10
|
+
color: { value: ["#6c5ce7", "#a29bfe", "#fd79a8", "#00cec9"] },
|
|
11
|
+
shape: { type: "circle" },
|
|
12
|
+
opacity: { value: 0.5, random: true },
|
|
13
|
+
size: { value: { min: 1, max: 3 }, random: true },
|
|
14
|
+
move: { enable: true, speed: 1, direction: "none", random: true, straight: false, outModes: { default: "out" } },
|
|
15
|
+
},
|
|
16
|
+
interactivity: {
|
|
17
|
+
events: { onHover: { enable: true, mode: "bubble" } },
|
|
18
|
+
modes: { bubble: { distance: 200, size: 6, duration: 2, opacity: 0.8 } },
|
|
19
|
+
},
|
|
20
|
+
detectRetina: true,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function validateEmail(val: string): boolean {
|
|
24
|
+
return /^[^\s@]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/.test(val);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@customElement("my-app")
|
|
28
|
+
export class MyApp extends LitElement {
|
|
29
|
+
@state() private isLogin = true;
|
|
30
|
+
@state() private theme = localStorage.getItem("theme") || "dark";
|
|
31
|
+
@state() private email = "";
|
|
32
|
+
@state() private password = "";
|
|
33
|
+
@state() private confirm = "";
|
|
34
|
+
@state() private emailErr = "";
|
|
35
|
+
@state() private passErr = "";
|
|
36
|
+
@state() private confirmErr = "";
|
|
37
|
+
|
|
38
|
+
connectedCallback(): void {
|
|
39
|
+
super.connectedCallback();
|
|
40
|
+
document.documentElement.setAttribute("data-theme", this.theme);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private setTheme(t: string): void {
|
|
44
|
+
this.theme = t;
|
|
45
|
+
document.documentElement.setAttribute("data-theme", t);
|
|
46
|
+
localStorage.setItem("theme", t);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private toggleTheme(): void {
|
|
50
|
+
this.setTheme(this.theme === "dark" ? "light" : "dark");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private handleSubmit(e: Event): void {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
let valid = true;
|
|
56
|
+
|
|
57
|
+
if (!this.email || !validateEmail(this.email)) {
|
|
58
|
+
this.emailErr = "Please enter a valid email address";
|
|
59
|
+
valid = false;
|
|
60
|
+
} else {
|
|
61
|
+
this.emailErr = "";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!this.password || this.password.length < 6) {
|
|
65
|
+
this.passErr = "Password must be at least 6 characters";
|
|
66
|
+
valid = false;
|
|
67
|
+
} else {
|
|
68
|
+
this.passErr = "";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!this.isLogin) {
|
|
72
|
+
if (this.password !== this.confirm) {
|
|
73
|
+
this.confirmErr = "Passwords do not match";
|
|
74
|
+
valid = false;
|
|
75
|
+
} else {
|
|
76
|
+
this.confirmErr = "";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!valid) return;
|
|
81
|
+
|
|
82
|
+
if (this.isLogin) {
|
|
83
|
+
alert("Logged in successfully! (demo)");
|
|
84
|
+
} else {
|
|
85
|
+
alert("Account created successfully! (demo)");
|
|
86
|
+
this.isLogin = true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.email = "";
|
|
90
|
+
this.password = "";
|
|
91
|
+
this.confirm = "";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private toggleMode(e: Event): void {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
this.isLogin = !this.isLogin;
|
|
97
|
+
this.emailErr = "";
|
|
98
|
+
this.passErr = "";
|
|
99
|
+
this.confirmErr = "";
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
render() {
|
|
103
|
+
return html`
|
|
104
|
+
<lit-particles id="tsparticles" .options=${options}></lit-particles>
|
|
105
|
+
<div class="auth-container">
|
|
106
|
+
<div class="auth-card">
|
|
107
|
+
<div class="auth-header">
|
|
108
|
+
<h1>${this.isLogin ? "Login" : "Register"}</h1>
|
|
109
|
+
<button class="theme-btn" @click=${this.toggleTheme} aria-label="Toggle theme">${this.theme === "dark" ? "🌙" : "☀️"}</button>
|
|
110
|
+
</div>
|
|
111
|
+
<form @submit=${this.handleSubmit} novalidate>
|
|
112
|
+
<div class="form-group">
|
|
113
|
+
<label for="email">Email</label>
|
|
114
|
+
<input id="email" type="email" placeholder="you@example.com" .value=${this.email} @input=${(e: InputEvent) => { this.email = (e.target as HTMLInputElement).value; }} required />
|
|
115
|
+
<span class="error">${this.emailErr}</span>
|
|
116
|
+
</div>
|
|
117
|
+
<div class="form-group">
|
|
118
|
+
<label for="password">Password</label>
|
|
119
|
+
<input id="password" type="password" placeholder="Enter password" .value=${this.password} @input=${(e: InputEvent) => { this.password = (e.target as HTMLInputElement).value; }} required />
|
|
120
|
+
<span class="error">${this.passErr}</span>
|
|
121
|
+
</div>
|
|
122
|
+
${!this.isLogin ? html`
|
|
123
|
+
<div class="form-group">
|
|
124
|
+
<label for="confirmPassword">Confirm Password</label>
|
|
125
|
+
<input id="confirmPassword" type="password" placeholder="Confirm password" .value=${this.confirm} @input=${(e: InputEvent) => { this.confirm = (e.target as HTMLInputElement).value; }} />
|
|
126
|
+
<span class="error">${this.confirmErr}</span>
|
|
127
|
+
</div>
|
|
128
|
+
` : ""}
|
|
129
|
+
<button type="submit">${this.isLogin ? "Sign In" : "Create Account"}</button>
|
|
130
|
+
</form>
|
|
131
|
+
<p class="toggle-text">
|
|
132
|
+
<span>${this.isLogin ? "Don't have an account?" : "Already have an account?"}</span>
|
|
133
|
+
<a href="#" @click=${this.toggleMode}>${this.isLogin ? "Register" : "Login"}</a>
|
|
134
|
+
</p>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
createRenderRoot() {
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{packageName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev",
|
|
7
|
+
"build": "next build",
|
|
8
|
+
"preview": "next start"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"next": "^15.3.2",
|
|
12
|
+
"react": "^19.2.5",
|
|
13
|
+
"react-dom": "^19.2.5",
|
|
14
|
+
"@tsparticles/nextjs": "^4.1.3",
|
|
15
|
+
"@tsparticles/slim": "^4.1.3",
|
|
16
|
+
"@tsparticles/configs": "^4.1.3",
|
|
17
|
+
"@tsparticles/engine": "^4.1.3"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^6.0.3",
|
|
21
|
+
"@types/node": "^22.15.3",
|
|
22
|
+
"@types/react": "^19.1.4",
|
|
23
|
+
"@types/react-dom": "^19.1.3"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
import { NextParticles } from "@tsparticles/nextjs";
|
|
5
|
+
import type { ISourceOptions } from "@tsparticles/engine";
|
|
6
|
+
|
|
7
|
+
const options: ISourceOptions = {
|
|
8
|
+
background: { color: { value: "transparent" } },
|
|
9
|
+
fpsLimit: 60,
|
|
10
|
+
particles: {
|
|
11
|
+
number: { value: 60, density: { enable: true } },
|
|
12
|
+
color: { value: ["#6c5ce7", "#a29bfe", "#fd79a8", "#00cec9"] },
|
|
13
|
+
shape: { type: "circle" },
|
|
14
|
+
opacity: { value: 0.5, random: true },
|
|
15
|
+
size: { value: { min: 1, max: 3 }, random: true },
|
|
16
|
+
move: { enable: true, speed: 1, direction: "none", random: true, straight: false, outModes: { default: "out" } },
|
|
17
|
+
},
|
|
18
|
+
interactivity: {
|
|
19
|
+
events: { onHover: { enable: true, mode: "bubble" } },
|
|
20
|
+
modes: { bubble: { distance: 200, size: 6, duration: 2, opacity: 0.8 } },
|
|
21
|
+
},
|
|
22
|
+
detectRetina: true,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function validateEmail(email: string): boolean {
|
|
26
|
+
return /^[^\s@]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/.test(email);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default function Home() {
|
|
30
|
+
const [theme, setTheme] = useState("dark");
|
|
31
|
+
const [isLogin, setIsLogin] = useState(true);
|
|
32
|
+
const [email, setEmail] = useState("");
|
|
33
|
+
const [password, setPassword] = useState("");
|
|
34
|
+
const [confirm, setConfirm] = useState("");
|
|
35
|
+
const [emailErr, setEmailErr] = useState("");
|
|
36
|
+
const [passErr, setPassErr] = useState("");
|
|
37
|
+
const [confirmErr, setConfirmErr] = useState("");
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const saved = localStorage.getItem("theme") || "dark";
|
|
41
|
+
setTheme(saved);
|
|
42
|
+
document.documentElement.setAttribute("data-theme", saved);
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
document.documentElement.setAttribute("data-theme", theme);
|
|
47
|
+
localStorage.setItem("theme", theme);
|
|
48
|
+
}, [theme]);
|
|
49
|
+
|
|
50
|
+
function toggleTheme() {
|
|
51
|
+
setTheme((t) => (t === "dark" ? "light" : "dark"));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function handleSubmit(e: React.FormEvent) {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
let valid = true;
|
|
57
|
+
|
|
58
|
+
if (!email || !validateEmail(email)) {
|
|
59
|
+
setEmailErr("Please enter a valid email address");
|
|
60
|
+
valid = false;
|
|
61
|
+
} else {
|
|
62
|
+
setEmailErr("");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!password || password.length < 6) {
|
|
66
|
+
setPassErr("Password must be at least 6 characters");
|
|
67
|
+
valid = false;
|
|
68
|
+
} else {
|
|
69
|
+
setPassErr("");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!isLogin) {
|
|
73
|
+
if (password !== confirm) {
|
|
74
|
+
setConfirmErr("Passwords do not match");
|
|
75
|
+
valid = false;
|
|
76
|
+
} else {
|
|
77
|
+
setConfirmErr("");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!valid) return;
|
|
82
|
+
|
|
83
|
+
if (isLogin) {
|
|
84
|
+
alert("Logged in successfully! (demo)");
|
|
85
|
+
} else {
|
|
86
|
+
alert("Account created successfully! (demo)");
|
|
87
|
+
setIsLogin(true);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
setEmail("");
|
|
91
|
+
setPassword("");
|
|
92
|
+
setConfirm("");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function toggleMode(e: React.MouseEvent) {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
setIsLogin((m) => !m);
|
|
98
|
+
setEmailErr("");
|
|
99
|
+
setPassErr("");
|
|
100
|
+
setConfirmErr("");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<html lang="en">
|
|
105
|
+
<head>
|
|
106
|
+
<title>{{projectName}}</title>
|
|
107
|
+
<style>{`
|
|
108
|
+
:root { --bg: #0f0f1a; --card-bg: rgba(255, 255, 255, 0.05); --text: #fff; --border: rgba(255, 255, 255, 0.1); --input-bg: rgba(255, 255, 255, 0.08); --accent: #6c5ce7; --accent-hover: #a29bfe; --error: #e74c3c; }
|
|
109
|
+
[data-theme="light"] { --bg: #f0f0f5; --card-bg: rgba(255, 255, 255, 0.8); --text: #1a1a2e; --border: rgba(0, 0, 0, 0.1); --input-bg: rgba(0, 0, 0, 0.05); }
|
|
110
|
+
* { box-sizing: border-box; }
|
|
111
|
+
body { margin: 0; font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); transition: background 0.3s, color 0.3s; }
|
|
112
|
+
.auth-container { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 10; width: 100%; max-width: 400px; padding: 1rem; }
|
|
113
|
+
.auth-card { background: var(--card-bg); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); }
|
|
114
|
+
.auth-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
|
|
115
|
+
.auth-header h1 { margin: 0; font-size: 1.8em; }
|
|
116
|
+
.theme-btn { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 0.4em 0.6em; font-size: 1.2em; cursor: pointer; transition: background 0.2s; }
|
|
117
|
+
.theme-btn:hover { background: var(--input-bg); }
|
|
118
|
+
.form-group { margin-bottom: 1rem; }
|
|
119
|
+
label { display: block; margin-bottom: 0.3em; font-size: 0.9em; opacity: 0.8; }
|
|
120
|
+
input { width: 100%; padding: 0.7em 1em; font-size: 1em; border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); color: var(--text); outline: none; transition: border-color 0.2s; }
|
|
121
|
+
input:focus { border-color: var(--accent); }
|
|
122
|
+
input::placeholder { color: var(--text); opacity: 0.4; }
|
|
123
|
+
.error { display: block; margin-top: 0.3em; font-size: 0.8em; color: var(--error); min-height: 1em; }
|
|
124
|
+
button[type="submit"] { width: 100%; padding: 0.8em; font-size: 1em; font-weight: 600; border: none; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; transition: background 0.2s; margin-top: 0.5rem; }
|
|
125
|
+
button[type="submit"]:hover { background: var(--accent-hover); }
|
|
126
|
+
.toggle-text { text-align: center; margin-top: 1.5rem; font-size: 0.9em; opacity: 0.7; }
|
|
127
|
+
.toggle-text a { color: var(--accent); text-decoration: none; margin-left: 0.3em; }
|
|
128
|
+
.toggle-text a:hover { text-decoration: underline; }
|
|
129
|
+
`}</style>
|
|
130
|
+
</head>
|
|
131
|
+
<body>
|
|
132
|
+
<NextParticles id="tsparticles" options={options} />
|
|
133
|
+
<div className="auth-container">
|
|
134
|
+
<div className="auth-card">
|
|
135
|
+
<div className="auth-header">
|
|
136
|
+
<h1>{isLogin ? "Login" : "Register"}</h1>
|
|
137
|
+
<button className="theme-btn" onClick={toggleTheme} aria-label="Toggle theme">{theme === "dark" ? "🌙" : "☀️"}</button>
|
|
138
|
+
</div>
|
|
139
|
+
<form onSubmit={handleSubmit} noValidate>
|
|
140
|
+
<div className="form-group">
|
|
141
|
+
<label htmlFor="email">Email</label>
|
|
142
|
+
<input id="email" type="email" placeholder="you@example.com" value={email} onChange={(e) => setEmail(e.target.value)} required />
|
|
143
|
+
<span className="error">{emailErr}</span>
|
|
144
|
+
</div>
|
|
145
|
+
<div className="form-group">
|
|
146
|
+
<label htmlFor="password">Password</label>
|
|
147
|
+
<input id="password" type="password" placeholder="Enter password" value={password} onChange={(e) => setPassword(e.target.value)} required />
|
|
148
|
+
<span className="error">{passErr}</span>
|
|
149
|
+
</div>
|
|
150
|
+
{!isLogin && (
|
|
151
|
+
<div className="form-group">
|
|
152
|
+
<label htmlFor="confirmPassword">Confirm Password</label>
|
|
153
|
+
<input id="confirmPassword" type="password" placeholder="Confirm password" value={confirm} onChange={(e) => setConfirm(e.target.value)} />
|
|
154
|
+
<span className="error">{confirmErr}</span>
|
|
155
|
+
</div>
|
|
156
|
+
)}
|
|
157
|
+
<button type="submit">{isLogin ? "Sign In" : "Create Account"}</button>
|
|
158
|
+
</form>
|
|
159
|
+
<p className="toggle-text">
|
|
160
|
+
<span>{isLogin ? "Don't have an account?" : "Already have an account?"}</span>
|
|
161
|
+
<a href="#" onClick={toggleMode}>{isLogin ? "Register" : "Login"}</a>
|
|
162
|
+
</p>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</body>
|
|
166
|
+
</html>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { NextParticlesProvider } from "@tsparticles/nextjs";
|
|
4
|
+
import { loadSlim } from "@tsparticles/slim";
|
|
5
|
+
import type { Engine } from "@tsparticles/engine";
|
|
6
|
+
|
|
7
|
+
export default function Providers({ children }: { children: React.ReactNode }) {
|
|
8
|
+
return (
|
|
9
|
+
<NextParticlesProvider init={async (engine: Engine): Promise<void> => { await loadSlim(engine); }}>
|
|
10
|
+
{children}
|
|
11
|
+
</NextParticlesProvider>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{packageName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "nuxt",
|
|
7
|
+
"build": "nuxt build",
|
|
8
|
+
"preview": "nuxt start"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"nuxt": "^2.18.1",
|
|
12
|
+
"@tsparticles/nuxt2": "^4.1.3",
|
|
13
|
+
"@tsparticles/slim": "^4.1.3",
|
|
14
|
+
"@tsparticles/configs": "^4.1.3",
|
|
15
|
+
"@tsparticles/engine": "^4.1.3"
|
|
16
|
+
}
|
|
17
|
+
}
|