pwa-auth 2.0.4 → 2.0.5
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 +13 -1
- package/README.md +54 -34
- package/demo/index.html +22 -126
- package/demo/pwa-styles.css +77 -0
- package/deploy/css/font.d.ts.map +1 -1
- package/deploy/css/form/button.d.ts.map +1 -1
- package/deploy/css/form/input.d.ts.map +1 -1
- package/deploy/css/form/label.d.ts.map +1 -1
- package/deploy/css/form/list.d.ts.map +1 -1
- package/deploy/css/svg.d.ts.map +1 -1
- package/deploy/css/toggle.d.ts.map +1 -1
- package/deploy/custom-elements/drawer/css/drawer.d.ts.map +1 -1
- package/deploy/custom-elements/drawer/css/exit.d.ts.map +1 -1
- package/deploy/custom-elements/drawer/css/link.d.ts.map +1 -1
- package/deploy/custom-elements/drawer/css/paragraph.d.ts.map +1 -1
- package/deploy/custom-elements/drawer/css/toggle.d.ts.map +1 -1
- package/deploy/custom-elements/drawer/drawer.d.ts.map +1 -1
- package/deploy/custom-elements/drawer/drawer.js +1 -1
- package/deploy/custom-elements/drawer/input/forgot.d.ts.map +1 -1
- package/deploy/custom-elements/drawer/input/forgot.js +1 -1
- package/deploy/custom-elements/drawer/input/login.d.ts.map +1 -1
- package/deploy/custom-elements/drawer/input/login.js +1 -1
- package/deploy/custom-elements/drawer/input/sign-up.d.ts.map +1 -1
- package/deploy/custom-elements/drawer/input/sign-up.js +1 -1
- package/deploy/custom-elements/icon/css/icon.d.ts.map +1 -1
- package/deploy/custom-elements/icon/css/icon.js +0 -1
- package/deploy/custom-elements/icon/icon.d.ts.map +1 -1
- package/deploy/custom-elements/settings/css/navigation.d.ts.map +1 -1
- package/deploy/custom-elements/settings/input/delete.d.ts.map +1 -1
- package/deploy/custom-elements/settings/input/delete.js +1 -1
- package/deploy/custom-elements/settings/input/email.d.ts.map +1 -1
- package/deploy/custom-elements/settings/input/email.js +1 -1
- package/deploy/custom-elements/settings/input/images.d.ts.map +1 -1
- package/deploy/custom-elements/settings/input/images.js +1 -1
- package/deploy/custom-elements/settings/input/name.d.ts.map +1 -1
- package/deploy/custom-elements/settings/input/name.js +1 -1
- package/deploy/custom-elements/settings/input/password.d.ts.map +1 -1
- package/deploy/custom-elements/settings/input/password.js +1 -1
- package/deploy/custom-elements/settings/input/uploader.d.ts +0 -2
- package/deploy/custom-elements/settings/input/uploader.d.ts.map +1 -1
- package/deploy/custom-elements/settings/input/uploader.js +11 -22
- package/deploy/custom-elements/settings/settings.d.ts.map +1 -1
- package/deploy/firebase/firebase-login.d.ts +21 -0
- package/deploy/firebase/firebase-login.d.ts.map +1 -0
- package/deploy/firebase/firebase-login.js +85 -0
- package/deploy/firebase/firebase.d.ts +20 -0
- package/deploy/firebase/firebase.d.ts.map +1 -0
- package/deploy/firebase/firebase.js +76 -0
- package/deploy/firebase/start.d.ts.map +1 -0
- package/deploy/{start.js → firebase/start.js} +5 -4
- package/deploy/lazy-loader.d.ts.map +1 -1
- package/deploy/redux/backend.d.ts.map +1 -1
- package/deploy/redux/drawer.d.ts.map +1 -1
- package/deploy/redux/frontend.d.ts.map +1 -1
- package/deploy/redux/object.d.ts.map +1 -1
- package/deploy/store.d.ts.map +1 -1
- package/npm/pwa-auth.js +1 -1
- package/package.json +4 -3
- package/source/css/font.ts +17 -0
- package/source/css/form/button.ts +55 -0
- package/source/css/form/input.ts +25 -0
- package/source/css/form/label.ts +25 -0
- package/source/css/form/list.ts +23 -0
- package/source/css/svg.ts +5 -0
- package/source/css/toggle.ts +9 -0
- package/source/custom-elements/drawer/css/drawer.ts +64 -0
- package/source/custom-elements/drawer/css/exit.ts +49 -0
- package/source/custom-elements/drawer/css/link.ts +15 -0
- package/source/custom-elements/drawer/css/paragraph.ts +11 -0
- package/source/custom-elements/drawer/css/toggle.ts +19 -0
- package/source/custom-elements/drawer/drawer.ts +120 -0
- package/source/custom-elements/drawer/input/forgot.ts +121 -0
- package/source/custom-elements/drawer/input/login.ts +135 -0
- package/source/custom-elements/drawer/input/sign-up.ts +158 -0
- package/source/custom-elements/icon/css/icon.ts +70 -0
- package/source/custom-elements/icon/icon.ts +87 -0
- package/source/custom-elements/settings/css/navigation.ts +92 -0
- package/source/custom-elements/settings/input/delete.ts +83 -0
- package/source/custom-elements/settings/input/email.ts +135 -0
- package/source/custom-elements/settings/input/images.ts +57 -0
- package/source/custom-elements/settings/input/name.ts +99 -0
- package/source/custom-elements/settings/input/password.ts +156 -0
- package/source/custom-elements/settings/input/uploader.ts +326 -0
- package/source/custom-elements/settings/settings.ts +202 -0
- package/source/firebase/firebase-login.ts +246 -0
- package/source/firebase/firebase.ts +214 -0
- package/source/firebase/start.ts +216 -0
- package/source/lazy-loader.ts +20 -0
- package/source/redux/backend.ts +94 -0
- package/source/redux/drawer.ts +37 -0
- package/source/redux/frontend.ts +134 -0
- package/source/redux/object.ts +31 -0
- package/source/store.ts +19 -0
- package/website/404.html +33 -0
- package/website/THIRD_PARTY_LICENSES.txt +303 -0
- package/website/css/pwa-styles.css +36 -0
- package/website/css/styles.css +67 -0
- package/website/images/empty.jpg +0 -0
- package/website/images/favicon.ico +0 -0
- package/website/images/manifest/logo-144.png +0 -0
- package/website/images/manifest/logo-192.png +0 -0
- package/website/images/manifest/logo-48.png +0 -0
- package/website/images/manifest/logo-512.png +0 -0
- package/website/images/manifest/logo-72.png +0 -0
- package/website/images/manifest/logo-96.png +0 -0
- package/website/images/manifest/maskable_icon_x128.png +0 -0
- package/website/images/manifest/maskable_icon_x192.png +0 -0
- package/website/images/manifest/maskable_icon_x384.png +0 -0
- package/website/images/manifest/maskable_icon_x48.png +0 -0
- package/website/images/manifest/maskable_icon_x512.png +0 -0
- package/website/images/manifest/maskable_icon_x72.png +0 -0
- package/website/images/manifest/maskable_icon_x96.png +0 -0
- package/website/index.html +64 -0
- package/website/js/pwa-auth.js +306 -0
- package/website/sitemap.xml +11 -0
- package/deploy/interface.d.ts +0 -37
- package/deploy/interface.d.ts.map +0 -1
- package/deploy/interface.js +0 -176
- package/deploy/start.d.ts.map +0 -1
- /package/deploy/{start.d.ts → firebase/start.d.ts} +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { html, LitElement, css } from 'lit';
|
|
2
|
+
import { customElement, state } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
|
+
import { EmailAuthProvider, signInWithCredential } from 'firebase/auth';
|
|
5
|
+
import { auth } from '../../../firebase/start';
|
|
6
|
+
|
|
7
|
+
import { buttonStyle } from '../../../css/form/button';
|
|
8
|
+
import { labelStyle } from '../../../css/form/label';
|
|
9
|
+
import { inputStyle } from '../../../css/form/input';
|
|
10
|
+
import { listStyle } from '../../../css/form/list';
|
|
11
|
+
import { toggleStyle } from '../css/toggle';
|
|
12
|
+
|
|
13
|
+
import store from '../../../store';
|
|
14
|
+
import { signUpAction } from '../../../redux/frontend';
|
|
15
|
+
|
|
16
|
+
@customElement('user-log-in')
|
|
17
|
+
export class UserLogIn extends LitElement {
|
|
18
|
+
|
|
19
|
+
@state() private email = '';
|
|
20
|
+
@state() private password = '';
|
|
21
|
+
|
|
22
|
+
constructor() { super(); }
|
|
23
|
+
|
|
24
|
+
static get styles() { return [
|
|
25
|
+
listStyle,
|
|
26
|
+
labelStyle,
|
|
27
|
+
inputStyle,
|
|
28
|
+
buttonStyle,
|
|
29
|
+
toggleStyle,
|
|
30
|
+
css`
|
|
31
|
+
|
|
32
|
+
.double {
|
|
33
|
+
display: grid;
|
|
34
|
+
grid-template-columns: 1fr auto;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
`
|
|
38
|
+
] };
|
|
39
|
+
|
|
40
|
+
protected render() {
|
|
41
|
+
return html`
|
|
42
|
+
|
|
43
|
+
<!-- Log-in State -->
|
|
44
|
+
<form
|
|
45
|
+
@submit=${this._handleSubmit}
|
|
46
|
+
autocomplete="on">
|
|
47
|
+
|
|
48
|
+
<ul>
|
|
49
|
+
|
|
50
|
+
<li>
|
|
51
|
+
<label for="pwa-login-email">Email</label>
|
|
52
|
+
<input
|
|
53
|
+
id="pwa-login-email"
|
|
54
|
+
type="email"
|
|
55
|
+
@change="${this.handleEmail}">
|
|
56
|
+
</li>
|
|
57
|
+
|
|
58
|
+
<li>
|
|
59
|
+
<label for="pwa-login-pass">Password</label>
|
|
60
|
+
<input
|
|
61
|
+
id="pwa-login-pass"
|
|
62
|
+
type="password"
|
|
63
|
+
@change="${this.handlePassword}">
|
|
64
|
+
</li>
|
|
65
|
+
|
|
66
|
+
<li>
|
|
67
|
+
<button
|
|
68
|
+
class="login action-button"
|
|
69
|
+
@click="${this.login}">Sign in</button>
|
|
70
|
+
|
|
71
|
+
</li>
|
|
72
|
+
|
|
73
|
+
<!-- Change State -->
|
|
74
|
+
<li>
|
|
75
|
+
<p class="divider">Or</p>
|
|
76
|
+
<button
|
|
77
|
+
class="new"
|
|
78
|
+
@click="${ this.change }">create a new account</button>
|
|
79
|
+
</li>
|
|
80
|
+
|
|
81
|
+
</ul>
|
|
82
|
+
|
|
83
|
+
</form>
|
|
84
|
+
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private change() {
|
|
89
|
+
store.dispatch(signUpAction());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Sync Email
|
|
93
|
+
private handleEmail(event: Event) {
|
|
94
|
+
const input = event.target as HTMLInputElement;
|
|
95
|
+
this.email = input.value; // Update the property with the input value
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Sync Password
|
|
99
|
+
private handlePassword(event: Event) {
|
|
100
|
+
const input = event.target as HTMLInputElement;
|
|
101
|
+
this.password = input.value; // Update the property with the input value
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Form Default
|
|
105
|
+
private _handleSubmit(event: Event) {
|
|
106
|
+
event.preventDefault(); // Prevent Form Default Behaviour
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Login Action
|
|
110
|
+
private login() {
|
|
111
|
+
if (this.email.length < 4) { alert('Please enter an email address.'); return; }
|
|
112
|
+
if (this.password.length < 4) { alert('Please enter a password.'); return; }
|
|
113
|
+
this.signIn(this.email,this.password); // Sign in with email and password
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
// Firebase Authentication Function: Sign in using Email and Password
|
|
118
|
+
private signIn = async (email:any, password:any) => {
|
|
119
|
+
|
|
120
|
+
const authCredential = EmailAuthProvider.credential(email, password);
|
|
121
|
+
|
|
122
|
+
await signInWithCredential(auth, authCredential).catch((error)=>{console.log(error)}); /*.then((/*credentials*)=>{/*onsole.log(credentials)})*/
|
|
123
|
+
|
|
124
|
+
// await signInWithEmailAndPassword(auth, email, password);
|
|
125
|
+
// EmailAuthProvider.credential(email, password);
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare global {
|
|
132
|
+
interface HTMLElementTagNameMap {
|
|
133
|
+
'user-log-in': UserLogIn;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { css, html, LitElement } from 'lit';
|
|
2
|
+
import { customElement, state } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
|
+
import { createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
|
|
5
|
+
import { auth, logAccount } from '../../../firebase/start';
|
|
6
|
+
|
|
7
|
+
import { buttonStyle } from '../../../css/form/button';
|
|
8
|
+
import { labelStyle } from '../../../css/form/label';
|
|
9
|
+
import { inputStyle } from '../../../css/form/input';
|
|
10
|
+
import { listStyle } from '../../../css/form/list';
|
|
11
|
+
import { toggleStyle } from '../css/toggle';
|
|
12
|
+
|
|
13
|
+
import store from '../../../store';
|
|
14
|
+
import { signUpAction } from '../../../redux/frontend';
|
|
15
|
+
|
|
16
|
+
@customElement('user-sign-up')
|
|
17
|
+
export class UserSignUp extends LitElement {
|
|
18
|
+
|
|
19
|
+
@state() private email = '';
|
|
20
|
+
@state() private password = '';
|
|
21
|
+
|
|
22
|
+
constructor() { super(); }
|
|
23
|
+
|
|
24
|
+
static get styles() { return [
|
|
25
|
+
listStyle,
|
|
26
|
+
labelStyle,
|
|
27
|
+
inputStyle,
|
|
28
|
+
buttonStyle,
|
|
29
|
+
toggleStyle,
|
|
30
|
+
css`
|
|
31
|
+
|
|
32
|
+
.double {
|
|
33
|
+
display: grid;
|
|
34
|
+
grid-template-columns: 1fr auto;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
`
|
|
38
|
+
] };
|
|
39
|
+
|
|
40
|
+
protected render() {
|
|
41
|
+
return html`
|
|
42
|
+
|
|
43
|
+
<!-- Sign Up State-->
|
|
44
|
+
<form
|
|
45
|
+
@submit=${this._handleSubmit}
|
|
46
|
+
autocomplete="on">
|
|
47
|
+
|
|
48
|
+
<ul>
|
|
49
|
+
|
|
50
|
+
<li>
|
|
51
|
+
<label for="pwa-signup-email">Email</label>
|
|
52
|
+
<input
|
|
53
|
+
id="pwa-signup-email"
|
|
54
|
+
type="email"
|
|
55
|
+
@change="${this.handleEmail}">
|
|
56
|
+
</li>
|
|
57
|
+
|
|
58
|
+
<!-- <label><input id="verifyEmail" type="email" >Verify Email</label> -->
|
|
59
|
+
|
|
60
|
+
<li>
|
|
61
|
+
<label for="pwa-signup-pass">Password</label>
|
|
62
|
+
<input
|
|
63
|
+
id="pwa-signup-pass"
|
|
64
|
+
type="password"
|
|
65
|
+
@change="${this.handlePassword}">
|
|
66
|
+
</li>
|
|
67
|
+
|
|
68
|
+
<li>
|
|
69
|
+
<button
|
|
70
|
+
class="newUser action-button"
|
|
71
|
+
@click="${this.signUp}">Sign up</button>
|
|
72
|
+
</li>
|
|
73
|
+
|
|
74
|
+
<!-- <label><input id="veriftPassword" type="password" >Verify Password</label> -->
|
|
75
|
+
|
|
76
|
+
<!-- Change State -->
|
|
77
|
+
<li>
|
|
78
|
+
<p class="divider">Or</p>
|
|
79
|
+
<button
|
|
80
|
+
class="new"
|
|
81
|
+
@click="${ this.change }">login with existing email</button>
|
|
82
|
+
</li>
|
|
83
|
+
|
|
84
|
+
</ul>
|
|
85
|
+
|
|
86
|
+
</form>
|
|
87
|
+
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private change() {
|
|
92
|
+
store.dispatch(signUpAction());
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Form Default Behavior
|
|
96
|
+
private _handleSubmit(event: Event) {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Sync Email
|
|
101
|
+
private handleEmail(event: Event) {
|
|
102
|
+
const input = event.target as HTMLInputElement;
|
|
103
|
+
this.email = input.value; // Update the property with the input value
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Sync Password
|
|
107
|
+
private handlePassword(event: Event) {
|
|
108
|
+
const input = event.target as HTMLInputElement;
|
|
109
|
+
this.password = input.value; // Update the property with the input value
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Sign Up Action
|
|
113
|
+
private signUp() {
|
|
114
|
+
if (this.email.length < 4) { alert('Please enter an email address.'); return; }
|
|
115
|
+
if (this.password.length < 4) { alert('Please enter a password.'); return; }
|
|
116
|
+
this.newAccount(this.email, this.password); // Sign UP with email and password.
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Create New Account using Email and Password
|
|
120
|
+
private newAccount = async (email:any, password:any) => {
|
|
121
|
+
|
|
122
|
+
await createUserWithEmailAndPassword(auth, email, password)
|
|
123
|
+
|
|
124
|
+
.then((userCredential) => {
|
|
125
|
+
|
|
126
|
+
// User created
|
|
127
|
+
const user = userCredential.user;
|
|
128
|
+
// Send email verification
|
|
129
|
+
sendEmailVerification(user)
|
|
130
|
+
.then(() => {
|
|
131
|
+
// Email verification sent
|
|
132
|
+
console.log("Verification email sent.");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
}).then( () => { logAccount(); } );
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
/* To Do: Integration
|
|
141
|
+
|
|
142
|
+
// Google Tag Manager Conversion - Integrateion
|
|
143
|
+
private gtag_report_conversion = async () => {
|
|
144
|
+
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
gtag('event', 'conversion', {'send_to': 'AW-/'});
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
declare global {
|
|
155
|
+
interface HTMLElementTagNameMap {
|
|
156
|
+
'user-sign-up': UserSignUp;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export const iconStyles = css`
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
margin: auto;
|
|
7
|
+
display: grid;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* Shared Styles */
|
|
11
|
+
.icon, .login {
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
margin: auto;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
border: var(--pwa_icon_border);
|
|
16
|
+
background-color: var(--pwa_icon_background);
|
|
17
|
+
color: white;
|
|
18
|
+
font-size: 15px;
|
|
19
|
+
text-decoration: none;
|
|
20
|
+
transition-duration: 2s;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* Hover Styles */
|
|
24
|
+
.icon:hover,
|
|
25
|
+
.login:hover {
|
|
26
|
+
background-color: var(--pwa_icon_hover);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Logged-in State: The Icon Button */
|
|
30
|
+
.icon {
|
|
31
|
+
height: var(--pwa_icon_diameter);
|
|
32
|
+
width: var(--pwa_icon_diameter);
|
|
33
|
+
border-radius: 50%;
|
|
34
|
+
padding: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* The Login Button */
|
|
38
|
+
.login {
|
|
39
|
+
width: auto;
|
|
40
|
+
border-radius: var(--pwa_icon_radius);
|
|
41
|
+
height: var(--pwa_icon_height);
|
|
42
|
+
padding: var(--pwa_icon_padding);
|
|
43
|
+
font-family: var(--pwa_icon_font);
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
text-align: center;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Icon Artwork */
|
|
49
|
+
.userImage {
|
|
50
|
+
object-fit: cover;
|
|
51
|
+
transition-property: all;
|
|
52
|
+
transition-duration: 2s;
|
|
53
|
+
clip-path: circle(50%);
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
width: calc(var(--pwa_icon_diameter) - 2px);
|
|
56
|
+
height: calc(var(--pwa_icon_diameter) - 2px);
|
|
57
|
+
margin: auto;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
/* Icon Artwork Wrapper
|
|
63
|
+
.iconArea {
|
|
64
|
+
border-radius: 50%;
|
|
65
|
+
overflow: hidden;
|
|
66
|
+
width: calc(var(--pwa_icon_diameter) - 2px);
|
|
67
|
+
height: calc(var(--pwa_icon_diameter) - 2px);
|
|
68
|
+
margin: auto;
|
|
69
|
+
}
|
|
70
|
+
*/
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { CSSResultArray, html, LitElement } from 'lit';
|
|
2
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
3
|
+
import { connect } from 'pwa-helpers/connect-mixin.js';
|
|
4
|
+
import { store, AppState } from '../../store';
|
|
5
|
+
import { iconStyles } from './css/icon';
|
|
6
|
+
import { toggleSign } from '../../redux/frontend';
|
|
7
|
+
// import { faceIcon } from '../../css/svg';
|
|
8
|
+
|
|
9
|
+
@customElement('user-icon')
|
|
10
|
+
export class UserIcon extends connect(store)(LitElement) {
|
|
11
|
+
|
|
12
|
+
/** @attr url */
|
|
13
|
+
@property({type: Boolean, reflect: true}) public subscribe = false;
|
|
14
|
+
|
|
15
|
+
@state() private _user = false;
|
|
16
|
+
@state() private _photoURL = '';
|
|
17
|
+
// @state() private _sign = false;
|
|
18
|
+
|
|
19
|
+
constructor() { super(); }
|
|
20
|
+
|
|
21
|
+
protected firstUpdated() {
|
|
22
|
+
this.shadowRoot!.querySelector('.toggles')!.addEventListener('click', () => {
|
|
23
|
+
// console.log('logged-in: ',this._user);
|
|
24
|
+
store.dispatch(toggleSign());
|
|
25
|
+
} );
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
stateChanged(state: AppState) {
|
|
29
|
+
this._user = state.frontend!.login;
|
|
30
|
+
this._photoURL = state.backend!.photoURL;
|
|
31
|
+
// this._sign = state.frontend!.register;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static get styles():CSSResultArray { return [ iconStyles ] }
|
|
35
|
+
|
|
36
|
+
protected render() {
|
|
37
|
+
return html`
|
|
38
|
+
|
|
39
|
+
<!-- two classes: icon / login -->
|
|
40
|
+
<button
|
|
41
|
+
class="${this._user ? 'icon' : 'login'} toggles"
|
|
42
|
+
aria-label="login">
|
|
43
|
+
|
|
44
|
+
${ this._user ? html`
|
|
45
|
+
<!-- <div
|
|
46
|
+
class = "iconArea"> -->
|
|
47
|
+
<input
|
|
48
|
+
type = "image"
|
|
49
|
+
class = "userImage"
|
|
50
|
+
alt = "Login"
|
|
51
|
+
height = "38px"
|
|
52
|
+
width = "38px"
|
|
53
|
+
src = "${this._photoURL}">
|
|
54
|
+
<!-- </div> -->
|
|
55
|
+
` : this.subscribe ? 'Subscribe' : 'Login' }
|
|
56
|
+
|
|
57
|
+
</button>
|
|
58
|
+
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare global {
|
|
64
|
+
interface HTMLElementTagNameMap {
|
|
65
|
+
'user-icon': UserIcon;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
<!--
|
|
71
|
+
-->
|
|
72
|
+
<!--
|
|
73
|
+
\${ this._user
|
|
74
|
+
\? html\`
|
|
75
|
+
<div
|
|
76
|
+
class = "iconArea">
|
|
77
|
+
<input
|
|
78
|
+
type = "image"
|
|
79
|
+
class = "userImage"
|
|
80
|
+
alt = "Login"
|
|
81
|
+
height = "32px"
|
|
82
|
+
width = "32px"
|
|
83
|
+
src = "\${this._photoURL}"><!-- id = "image"
|
|
84
|
+
</div>
|
|
85
|
+
\`
|
|
86
|
+
\: faceIcon }-->
|
|
87
|
+
*/
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export const navigation = css`
|
|
4
|
+
|
|
5
|
+
nav { overflow: hidden; }
|
|
6
|
+
|
|
7
|
+
/* Navigation Menu */
|
|
8
|
+
nav > ul {
|
|
9
|
+
|
|
10
|
+
list-style-type: none;
|
|
11
|
+
margin: 0px;
|
|
12
|
+
padding: 0px;
|
|
13
|
+
display: grid;
|
|
14
|
+
grid-template-columns: 1fr 1fr 1fr 1fr;
|
|
15
|
+
grid-gap: 8px;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Navigation Button */
|
|
20
|
+
nav > ul > li > button {
|
|
21
|
+
|
|
22
|
+
color: var(--pwa_nav_button);
|
|
23
|
+
border: 0;
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 36px;
|
|
26
|
+
margin: auto;
|
|
27
|
+
padding: 0px;
|
|
28
|
+
font-weight: 800;
|
|
29
|
+
font-size: .8em;
|
|
30
|
+
border-radius: 5px;
|
|
31
|
+
background-color: transparent;
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Navigation Button - Active */
|
|
36
|
+
nav > ul > li > button[on] {
|
|
37
|
+
|
|
38
|
+
color: var(--pwa_nav_select);
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Navigation Button - Hover */
|
|
43
|
+
nav > ul > li > button:hover {
|
|
44
|
+
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
section[on] { display: grid; }
|
|
50
|
+
section { display: none; }
|
|
51
|
+
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
/* Navigation Button - Media Text Justification
|
|
56
|
+
@media (max-width: 460px) {
|
|
57
|
+
|
|
58
|
+
button[value=profile], button[value=email] { text-align: left; }
|
|
59
|
+
button[value=delete], button[value=password] { text-align: right; }
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.formTitle {
|
|
64
|
+
display: grid;
|
|
65
|
+
grid-auto-flow: column;
|
|
66
|
+
grid-gap: 8px;
|
|
67
|
+
grid-template-columns: min-content;
|
|
68
|
+
}*/
|
|
69
|
+
|
|
70
|
+
/* Uploader - Page Border Divider
|
|
71
|
+
.profile {
|
|
72
|
+
width: 200px;
|
|
73
|
+
margin: auto;
|
|
74
|
+
}*/
|
|
75
|
+
|
|
76
|
+
/* Uploader - Display Photo
|
|
77
|
+
.userImage {
|
|
78
|
+
border-radius: 50%;
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
margin: auto;
|
|
81
|
+
border: 2px solid #303030;
|
|
82
|
+
box-shadow: 1px 1px 2px black, 0 0 25px grey, 0 0 5px #fff;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Uploader - button Visual Indicator Outline
|
|
86
|
+
button:focus { outline: none; }
|
|
87
|
+
|
|
88
|
+
/* Uploader -
|
|
89
|
+
.file-container { }
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
*/
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { CSSResultArray, LitElement, css, html } from "lit";
|
|
2
|
+
import { state } from "lit/decorators.js";
|
|
3
|
+
import { connect } from "pwa-helpers";
|
|
4
|
+
import store, { AppState } from "../../../store";
|
|
5
|
+
import { buttonStyle } from "../../../css/form/button";
|
|
6
|
+
import { auth } from '../../../firebase/start';
|
|
7
|
+
|
|
8
|
+
export class DeleteUser extends connect(store)(LitElement) {
|
|
9
|
+
|
|
10
|
+
@state() private login : boolean = false;
|
|
11
|
+
@state() private email : string ='';
|
|
12
|
+
|
|
13
|
+
constructor() { super(); }
|
|
14
|
+
|
|
15
|
+
protected firstUpdated() {
|
|
16
|
+
|
|
17
|
+
this.shadowRoot!.querySelector('.deleteUser')!.addEventListener('click',() => {
|
|
18
|
+
this.alertDelete();
|
|
19
|
+
} );
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
stateChanged(state: AppState) {
|
|
24
|
+
this.login = state.frontend!.login;
|
|
25
|
+
this.email = state.backend!.email;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static get styles(): CSSResultArray { return [
|
|
29
|
+
buttonStyle,
|
|
30
|
+
css`
|
|
31
|
+
|
|
32
|
+
:host {
|
|
33
|
+
display: grid;
|
|
34
|
+
grid-template-rows: auto auto;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
p {
|
|
38
|
+
padding: 0 16px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
` ]; }
|
|
42
|
+
|
|
43
|
+
render() {
|
|
44
|
+
return html`
|
|
45
|
+
|
|
46
|
+
<p>Permanently delete the user account and data related to: ${this.email}</p>
|
|
47
|
+
|
|
48
|
+
<button
|
|
49
|
+
class="action-button deleteUser"
|
|
50
|
+
?disabled="${this.login === false}">Delete</button>
|
|
51
|
+
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Delete Account */
|
|
56
|
+
private alertDelete() { if (auth.currentUser) { this.deleteUser(); } else { alert('Please Login'); } }
|
|
57
|
+
private deleteUser() {
|
|
58
|
+
const d = confirm("Delete Account?");
|
|
59
|
+
if ( d == true ) { this.officialDelete(); console.log("user gone"); }
|
|
60
|
+
else { console.log("user here"); }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Delete Declaration
|
|
64
|
+
private officialDelete = async () => {
|
|
65
|
+
|
|
66
|
+
if(auth.currentUser) {
|
|
67
|
+
|
|
68
|
+
return auth.currentUser.delete().then( () => { }).catch( () => { });
|
|
69
|
+
|
|
70
|
+
} else { alert('Please Sign-in') }
|
|
71
|
+
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
customElements.define('delete-user', DeleteUser);
|
|
77
|
+
|
|
78
|
+
declare global {
|
|
79
|
+
interface HTMLElementTagNameMap {
|
|
80
|
+
'delete-user': DeleteUser;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|