pwa-auth 2.0.4 → 2.0.6

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.
Files changed (128) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +61 -37
  3. package/demo/css/pwa-styles.css +77 -0
  4. package/demo/images/empty.jpg +0 -0
  5. package/demo/index.html +26 -130
  6. package/deploy/css/font.d.ts.map +1 -1
  7. package/deploy/css/form/button.d.ts.map +1 -1
  8. package/deploy/css/form/input.d.ts.map +1 -1
  9. package/deploy/css/form/label.d.ts.map +1 -1
  10. package/deploy/css/form/list.d.ts.map +1 -1
  11. package/deploy/css/svg.d.ts.map +1 -1
  12. package/deploy/css/toggle.d.ts.map +1 -1
  13. package/deploy/custom-elements/drawer/css/drawer.d.ts.map +1 -1
  14. package/deploy/custom-elements/drawer/css/exit.d.ts.map +1 -1
  15. package/deploy/custom-elements/drawer/css/link.d.ts.map +1 -1
  16. package/deploy/custom-elements/drawer/css/paragraph.d.ts.map +1 -1
  17. package/deploy/custom-elements/drawer/css/toggle.d.ts.map +1 -1
  18. package/deploy/custom-elements/drawer/drawer.d.ts.map +1 -1
  19. package/deploy/custom-elements/drawer/drawer.js +1 -1
  20. package/deploy/custom-elements/drawer/input/forgot.d.ts.map +1 -1
  21. package/deploy/custom-elements/drawer/input/forgot.js +1 -1
  22. package/deploy/custom-elements/drawer/input/login.d.ts.map +1 -1
  23. package/deploy/custom-elements/drawer/input/login.js +1 -1
  24. package/deploy/custom-elements/drawer/input/sign-up.d.ts.map +1 -1
  25. package/deploy/custom-elements/drawer/input/sign-up.js +1 -1
  26. package/deploy/custom-elements/icon/css/icon.d.ts.map +1 -1
  27. package/deploy/custom-elements/icon/css/icon.js +0 -1
  28. package/deploy/custom-elements/icon/icon.d.ts +1 -0
  29. package/deploy/custom-elements/icon/icon.d.ts.map +1 -1
  30. package/deploy/custom-elements/icon/icon.js +5 -1
  31. package/deploy/custom-elements/settings/css/navigation.d.ts.map +1 -1
  32. package/deploy/custom-elements/settings/input/delete.d.ts.map +1 -1
  33. package/deploy/custom-elements/settings/input/delete.js +1 -1
  34. package/deploy/custom-elements/settings/input/email.d.ts.map +1 -1
  35. package/deploy/custom-elements/settings/input/email.js +1 -1
  36. package/deploy/custom-elements/settings/input/images.d.ts.map +1 -1
  37. package/deploy/custom-elements/settings/input/images.js +1 -1
  38. package/deploy/custom-elements/settings/input/name.d.ts.map +1 -1
  39. package/deploy/custom-elements/settings/input/name.js +1 -1
  40. package/deploy/custom-elements/settings/input/password.d.ts.map +1 -1
  41. package/deploy/custom-elements/settings/input/password.js +1 -1
  42. package/deploy/custom-elements/settings/input/uploader.d.ts +1 -2
  43. package/deploy/custom-elements/settings/input/uploader.d.ts.map +1 -1
  44. package/deploy/custom-elements/settings/input/uploader.js +16 -23
  45. package/deploy/custom-elements/settings/settings.d.ts +1 -0
  46. package/deploy/custom-elements/settings/settings.d.ts.map +1 -1
  47. package/deploy/custom-elements/settings/settings.js +6 -2
  48. package/deploy/firebase/firebase-login.d.ts +21 -0
  49. package/deploy/firebase/firebase-login.d.ts.map +1 -0
  50. package/deploy/firebase/firebase-login.js +85 -0
  51. package/deploy/firebase/firebase.d.ts +20 -0
  52. package/deploy/firebase/firebase.d.ts.map +1 -0
  53. package/deploy/firebase/firebase.js +76 -0
  54. package/deploy/firebase/start.d.ts.map +1 -0
  55. package/deploy/{start.js → firebase/start.js} +11 -10
  56. package/deploy/lazy-loader.d.ts.map +1 -1
  57. package/deploy/redux/backend.d.ts.map +1 -1
  58. package/deploy/redux/drawer.d.ts.map +1 -1
  59. package/deploy/redux/frontend.d.ts.map +1 -1
  60. package/deploy/redux/frontend.js +1 -1
  61. package/deploy/redux/object.d.ts.map +1 -1
  62. package/deploy/store.d.ts.map +1 -1
  63. package/npm/images/empty.jpg +0 -0
  64. package/npm/pwa-auth.js +1 -1
  65. package/package.json +4 -3
  66. package/source/css/font.ts +17 -0
  67. package/source/css/form/button.ts +55 -0
  68. package/source/css/form/input.ts +25 -0
  69. package/source/css/form/label.ts +25 -0
  70. package/source/css/form/list.ts +23 -0
  71. package/source/css/svg.ts +5 -0
  72. package/source/css/toggle.ts +9 -0
  73. package/source/custom-elements/drawer/css/drawer.ts +64 -0
  74. package/source/custom-elements/drawer/css/exit.ts +49 -0
  75. package/source/custom-elements/drawer/css/link.ts +15 -0
  76. package/source/custom-elements/drawer/css/paragraph.ts +11 -0
  77. package/source/custom-elements/drawer/css/toggle.ts +19 -0
  78. package/source/custom-elements/drawer/drawer.ts +120 -0
  79. package/source/custom-elements/drawer/input/forgot.ts +121 -0
  80. package/source/custom-elements/drawer/input/login.ts +135 -0
  81. package/source/custom-elements/drawer/input/sign-up.ts +158 -0
  82. package/source/custom-elements/icon/css/icon.ts +70 -0
  83. package/source/custom-elements/icon/icon.ts +90 -0
  84. package/source/custom-elements/settings/css/navigation.ts +92 -0
  85. package/source/custom-elements/settings/input/delete.ts +83 -0
  86. package/source/custom-elements/settings/input/email.ts +135 -0
  87. package/source/custom-elements/settings/input/images.ts +57 -0
  88. package/source/custom-elements/settings/input/name.ts +99 -0
  89. package/source/custom-elements/settings/input/password.ts +156 -0
  90. package/source/custom-elements/settings/input/uploader.ts +329 -0
  91. package/source/custom-elements/settings/settings.ts +205 -0
  92. package/source/firebase/firebase-login.ts +246 -0
  93. package/source/firebase/firebase.ts +214 -0
  94. package/source/firebase/start.ts +216 -0
  95. package/source/lazy-loader.ts +20 -0
  96. package/source/redux/backend.ts +94 -0
  97. package/source/redux/drawer.ts +37 -0
  98. package/source/redux/frontend.ts +134 -0
  99. package/source/redux/object.ts +31 -0
  100. package/source/store.ts +19 -0
  101. package/website/404.html +33 -0
  102. package/website/THIRD_PARTY_LICENSES.txt +303 -0
  103. package/website/css/pwa-styles.css +36 -0
  104. package/website/css/styles.css +67 -0
  105. package/website/images/empty.jpg +0 -0
  106. package/website/images/favicon.ico +0 -0
  107. package/website/images/manifest/logo-144.png +0 -0
  108. package/website/images/manifest/logo-192.png +0 -0
  109. package/website/images/manifest/logo-48.png +0 -0
  110. package/website/images/manifest/logo-512.png +0 -0
  111. package/website/images/manifest/logo-72.png +0 -0
  112. package/website/images/manifest/logo-96.png +0 -0
  113. package/website/images/manifest/maskable_icon_x128.png +0 -0
  114. package/website/images/manifest/maskable_icon_x192.png +0 -0
  115. package/website/images/manifest/maskable_icon_x384.png +0 -0
  116. package/website/images/manifest/maskable_icon_x48.png +0 -0
  117. package/website/images/manifest/maskable_icon_x512.png +0 -0
  118. package/website/images/manifest/maskable_icon_x72.png +0 -0
  119. package/website/images/manifest/maskable_icon_x96.png +0 -0
  120. package/website/index.html +64 -0
  121. package/website/js/pwa-auth.js +306 -0
  122. package/website/sitemap.xml +11 -0
  123. package/deploy/interface.d.ts +0 -37
  124. package/deploy/interface.d.ts.map +0 -1
  125. package/deploy/interface.js +0 -176
  126. package/deploy/start.d.ts.map +0 -1
  127. /package/demo/{styles.css → css/styles.css} +0 -0
  128. /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,90 @@
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 subscribe */
13
+ @property({type: Boolean, reflect: true}) public subscribe = false;
14
+
15
+ /** @attr emptyArtwork */
16
+ @property({type: String, reflect: true}) public emptyArtwork = '';
17
+
18
+ @state() private _user = false;
19
+ @state() private _photoURL = '';
20
+ // @state() private _sign = false;
21
+
22
+ constructor() { super(); }
23
+
24
+ protected firstUpdated() {
25
+ this.shadowRoot!.querySelector('.toggles')!.addEventListener('click', () => {
26
+ // console.log('logged-in: ',this._user);
27
+ store.dispatch(toggleSign());
28
+ } );
29
+ }
30
+
31
+ stateChanged(state: AppState) {
32
+ this._user = state.frontend!.login;
33
+ this._photoURL = state.backend!.photoURL;
34
+ // this._sign = state.frontend!.register;
35
+ }
36
+
37
+ static get styles():CSSResultArray { return [ iconStyles ] }
38
+
39
+ protected render() {
40
+ return html`
41
+
42
+ <!-- two classes: icon / login -->
43
+ <button
44
+ class="${this._user ? 'icon' : 'login'} toggles"
45
+ aria-label="login">
46
+
47
+ ${ this._user ? html`
48
+ <!-- <div
49
+ class = "iconArea"> -->
50
+ <input
51
+ type = "image"
52
+ class = "userImage"
53
+ alt = "Login"
54
+ height = "38px"
55
+ width = "38px"
56
+ src = "${this._photoURL ? this._photoURL : this.emptyArtwork}">
57
+ <!-- </div> -->
58
+ ` : this.subscribe ? 'Subscribe' : 'Login' }
59
+
60
+ </button>
61
+
62
+ `;
63
+ }
64
+ }
65
+
66
+ declare global {
67
+ interface HTMLElementTagNameMap {
68
+ 'user-icon': UserIcon;
69
+ }
70
+ }
71
+
72
+ /*
73
+ <!--
74
+ -->
75
+ <!--
76
+ \${ this._user
77
+ \? html\`
78
+ <div
79
+ class = "iconArea">
80
+ <input
81
+ type = "image"
82
+ class = "userImage"
83
+ alt = "Login"
84
+ height = "32px"
85
+ width = "32px"
86
+ src = "\${this._photoURL}"><!-- id = "image"
87
+ </div>
88
+ \`
89
+ \: faceIcon }-->
90
+ */
@@ -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
+