pwa-auth 0.0.16 → 1.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +76 -4
  2. package/README.md +113 -84
  3. package/demo/index.html +118 -0
  4. package/demo/styles.css +52 -0
  5. package/images/empty.jpg +0 -0
  6. package/images/favicon.ico +0 -0
  7. package/images/manifest/logo-144.png +0 -0
  8. package/images/manifest/logo-192.png +0 -0
  9. package/images/manifest/logo-48.png +0 -0
  10. package/images/manifest/logo-512.png +0 -0
  11. package/images/manifest/logo-72.png +0 -0
  12. package/images/manifest/logo-96.png +0 -0
  13. package/images/manifest/maskable_icon_x128.png +0 -0
  14. package/images/manifest/maskable_icon_x192.png +0 -0
  15. package/images/manifest/maskable_icon_x384.png +0 -0
  16. package/images/manifest/maskable_icon_x48.png +0 -0
  17. package/images/manifest/maskable_icon_x512.png +0 -0
  18. package/images/manifest/maskable_icon_x72.png +0 -0
  19. package/images/manifest/maskable_icon_x96.png +0 -0
  20. package/images/npm.svg +85 -85
  21. package/license +21 -21
  22. package/manifest.json +47 -44
  23. package/npm/pwa-auth.js +3163 -0
  24. package/npm/pwa-auth.js.map +1 -0
  25. package/package.json +50 -39
  26. package/deploy/store.js +0 -18
  27. package/deploy/styles-drawer.js +0 -139
  28. package/deploy/styles-settings.js +0 -57
  29. package/deploy/styles.js +0 -88
  30. package/deploy/user-action.js +0 -69
  31. package/deploy/user-drawer.js +0 -168
  32. package/deploy/user-functions.js +0 -191
  33. package/deploy/user-icon.js +0 -106
  34. package/deploy/user-reducer.js +0 -41
  35. package/deploy/user-settings.js +0 -427
  36. package/index.html +0 -111
  37. package/launch/application-shell.js +0 -95
  38. package/launch/package-lock.json +0 -3198
  39. package/launch/package.json +0 -17
  40. package/polymer.json +0 -24
  41. package/pwa-auth.js +0 -16
  42. package/src/store.ts +0 -52
  43. package/src/styles-drawer.ts +0 -143
  44. package/src/styles-settings.ts +0 -61
  45. package/src/styles.ts +0 -95
  46. package/src/user-action.ts +0 -91
  47. package/src/user-drawer.ts +0 -168
  48. package/src/user-functions.ts +0 -190
  49. package/src/user-icon.ts +0 -104
  50. package/src/user-reducer.ts +0 -91
  51. package/src/user-settings.ts +0 -421
  52. package/tsconfig.json +0 -19
@@ -1,17 +0,0 @@
1
- {
2
- "name": "pwa-shell",
3
- "author": "Modern Projects <jack.solutionbox@gmail.com>(https://www.contractorscentre.com)",
4
- "version": "0.0.1",
5
- "description": "Application Shell for Progressive Website Application.",
6
- "homepage": "https://www.inmostfire.com",
7
- "main": "application-shell.js",
8
- "license": "BSD-3-Clause",
9
- "flat": true,
10
- "dependencies": {
11
- "@polymer/app-layout": "^3.1.0",
12
- "i": "^0.3.6",
13
- "npm": "^6.11.3",
14
- "pwa-auth": "^0.0.15",
15
- "submit-content": "^0.0.2"
16
- }
17
- }
package/polymer.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "entrypoint": "index.html",
3
- "shell": "pwa-auth.js",
4
- "moduleResolution": "node",
5
- "npm": true,
6
- "license": "MIT",
7
- "extraDependencies": [
8
- "manifest.json",
9
- "robots.txt",
10
- "node_modules/@webcomponents/webcomponentsjs/**",
11
- "node_modules/@webcomponents/webcomponentsjs/bundles/**"
12
- ],
13
- "builds":
14
- [
15
- {
16
- "name": "es5-bundled",
17
- "js": { "minify": true, "compile": true, "transformModulesToAmd": true },
18
- "css": { "minify": true },
19
- "html": { "minify": true },
20
- "bundle": { "inlineScripts": false },
21
- "addServiceWorker": true
22
- }
23
- ]
24
- }
package/pwa-auth.js DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- @license
3
- Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
4
- This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
- The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
- The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
- Code distributed by Google as part of the polymer project is also
8
- subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
- */
10
-
11
- export { UserDrawer } from './deploy/user-drawer.js';
12
- export { UserSettings } from './deploy/user-settings.js';
13
- export { UserIcon } from './deploy/user-icon.js';
14
- // module.exports = require('./src/user-drawer.js');
15
- // module.exports = require('./src/user-settings.js');
16
- // module.exports = require('./src/user-icon.js');
package/src/store.ts DELETED
@@ -1,52 +0,0 @@
1
- /**
2
- @license
3
- Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
4
- This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
- The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
- The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
- Code distributed by Google as part of the polymer project is also
8
- subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
- */
10
-
11
- declare global {
12
- interface Window {
13
- process?: Object;
14
- __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof compose;
15
- }
16
- }
17
-
18
- import {
19
- createStore,
20
- compose,
21
- applyMiddleware,
22
- combineReducers,
23
- Reducer,
24
- StoreEnhancer } from 'redux';
25
- import thunk, { ThunkMiddleware } from 'redux-thunk';
26
- import { lazyReducerEnhancer } from 'pwa-helpers/lazy-reducer-enhancer.js';
27
- import user, { AppState } from './user-reducer';
28
- import { AppAction } from './user-action';
29
-
30
- // Overall state extends static states and partials lazy states.
31
- export interface RootState {
32
- user?: AppState;
33
- }
34
-
35
- export type RootAction = AppAction ;
36
-
37
- // Sets up a Chrome extension for time travel debugging.
38
- // See https://github.com/zalmoxisus/redux-devtools-extension for more information.
39
- const devCompose: <Ext0, Ext1, StateExt0, StateExt1>(
40
- f1: StoreEnhancer<Ext0, StateExt0>, f2: StoreEnhancer<Ext1, StateExt1>
41
- ) => StoreEnhancer<Ext0 & Ext1, StateExt0 & StateExt1> =
42
- window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
43
-
44
- export const store = createStore(
45
- state => state as Reducer<RootState, RootAction>,
46
- devCompose(
47
- lazyReducerEnhancer(combineReducers),
48
- applyMiddleware(thunk as ThunkMiddleware<RootState, RootAction>)
49
- )
50
- );
51
-
52
- store.addReducers({ user });
@@ -1,143 +0,0 @@
1
-
2
- /**
3
- @license
4
- Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
5
- This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
- The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
- The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
- Code distributed by Google as part of the polymer project is also
9
- subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10
- */
11
-
12
- // @ts-check
13
-
14
- import { css } from 'lit-element';
15
-
16
- export const User = css`
17
-
18
- /* Google Icon Load */
19
- .icon {
20
- background: url('https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Google_%22G%22_Logo.svg/28px-Google_%22G%22_Logo.svg.png') transparent 5px 50% no-repeat;
21
- display: inline-block;
22
- vertical-align: middle;
23
- width: 42px;
24
- height: 42px;
25
- }
26
-
27
- .visibility[on] {
28
- visibility: visible;
29
- transform: translate3d(0, 0, 0);
30
- }
31
-
32
- .visibility {
33
- position: fixed;
34
- right: 0;
35
- visibility: hidden;
36
- will-change: transform;
37
- transform: translate3d(0, -150%, 0);
38
- transition-property: visibility, transform;
39
- transition-duration: 1.4s;
40
- display: block;
41
- }
42
-
43
- .userDrawer {
44
- z-index: 1;
45
- max-width: 600px;
46
- margin: auto;
47
- background-color: #fff;
48
- color: #303030;
49
- padding: 8px 18px;
50
- box-sizing: border-box;
51
- border: 3px #303030 solid;
52
- border-radius: 20px;
53
- }
54
-
55
- .exit {
56
- display: grid;
57
- grid-template-columns: 80px 1fr 80px;
58
- }
59
-
60
- .exit > h3 {
61
- font-weight: 800;
62
- font-size: .9em;
63
- margin: 0px auto;
64
- opacity: .8;
65
- line-height: 36px;
66
- }
67
-
68
- .exit > .remove {
69
- background-color: transparent;
70
- border: 0px;
71
- color: red;
72
- font-weight: 800;
73
- font-size: .7em;
74
- text-transform: uppercase;
75
- opacity: .6;
76
- }
77
-
78
- .exit > .refresh {
79
- background-color: transparent;
80
- border: 0px;
81
- fill: blue;
82
- height: 36px;
83
- width: 36px;
84
- padding: 0px;
85
- }
86
-
87
- .sign-right {
88
- height: 36px;
89
- width: 36px;
90
- margin: auto;
91
- background-color: transparent;
92
- border: 0px;
93
- fill: red;
94
- opacity: .8;
95
- }
96
-
97
- .google {
98
- margin: auto;
99
- color: #444;
100
- width: 210px;
101
- border-radius: 5px;
102
- border: thin solid #888;
103
- box-shadow: 1px 1px 1px grey;
104
- white-space: nowrap;
105
-
106
- background-color: #ffffff;
107
- size: 14px;
108
- font: Roboto-Medium;
109
- line-height: 26px;
110
- padding: 8dp;
111
- border-color: #4267b2;
112
- border-radius: 10px;
113
- -webkit-font-smoothing: antialiased;
114
- font-weight: bold;
115
- justify-content: center;
116
- text-align: center;
117
- text-shadow: none;
118
- }
119
-
120
- .google:hover {
121
- cursor: pointer;
122
- }
123
-
124
- .imageGoogle { height: 18dp; width: 18xp; }
125
- label { font-size: .9em; }
126
- .setLog > p { margin: 12px; box-sizing: border-box; }
127
- .divide { border: 2px solid #606060; margin: 6px 0 0 0; border-radius: 50%; }
128
- @media (max-width: 460px) { .google, label, #bat { font-size: .8em; } }
129
-
130
- input {
131
- box-sizing: border-box;
132
- width: 100%;
133
- padding: 12px 20px;
134
- margin: 8px 0 0 0;
135
- display: inline-block;
136
- border: 1px solid #ccc;
137
- border-radius: 4px;
138
- }
139
-
140
- a { text-transform: uppercase; font-size: .6em; color: rgb(105,105,105); font-weight: 800; text-decoration: none; }
141
- p {text-align: center;}
142
- .inpat { display:grid; grid-template-columns: 60% 40%;}
143
- `;
@@ -1,61 +0,0 @@
1
-
2
- /**
3
- @license
4
- Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
5
- This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
- The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
- The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
- Code distributed by Google as part of the polymer project is also
9
- subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10
- */
11
-
12
- // @ts-check
13
-
14
- import { css } from 'lit-element';
15
-
16
- export const Settings = css`
17
-
18
- form { box-sizing: border-box; }
19
- .pageTitle { margin: 0; }
20
-
21
- form {
22
- max-width: 600px;
23
- margin: auto;
24
- border: 0;
25
- }
26
-
27
- .setMenu {
28
- display: grid;
29
- grid-template-columns: 1fr 1fr 1fr 1fr;
30
- grid-gap: 8px;
31
- margin: 0px;
32
- padding: 0px;
33
- }
34
-
35
- .topButton {
36
- color: grey;
37
- border: 0;
38
- width: 100%;
39
- height: 36px;
40
- margin: auto;
41
- padding: 0px;
42
- font-weight: 800;
43
- font-size: .8em;
44
- border-radius: 5px;
45
- background-color: transparent;
46
- }
47
-
48
- .topButton[on] {
49
- /* background-color: rgba(0,0,0, .1); */
50
- color: var(--app-black-color);
51
- }
52
-
53
- .topButton:hover {
54
- cursor: pointer;
55
- }
56
-
57
- .topButton > p {
58
- margin: 0px;
59
- }
60
-
61
- `;
package/src/styles.ts DELETED
@@ -1,95 +0,0 @@
1
-
2
- /**
3
- @license
4
- Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
5
- This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
- The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
- The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
- Code distributed by Google as part of the polymer project is also
9
- subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10
- */
11
-
12
- // @ts-check
13
-
14
- import { html, css } from 'lit-element';
15
-
16
- export const userStyles = css`
17
-
18
- .spec[on] { display: block; }
19
- .spec { display: none; }
20
-
21
- .x-font {
22
- font-family: Roboto, Arial, sans-serif; /* 'Montserrat' */
23
- line-height: 1.1;
24
- letter-spacing: .007em;
25
- font-size: 14px;
26
- font-weight: 500;
27
- text-align: center;
28
- text-decoration-style: solid;
29
- text-transform: uppercase;
30
- }
31
-
32
- ul {
33
- list-style-type: none;
34
- padding: 0;
35
- margin: 0;
36
- }
37
-
38
- input[type=submit]:hover { background-color: #45a049; }
39
- input[type=submit] {
40
- box-sizing: border-box;
41
- width: 100%;
42
- background-color: #4CAF50;
43
- color: white;
44
- padding: 14px 20px;
45
- margin: 8px 0;
46
- border: none;
47
- border-radius: 4px;
48
- cursor: pointer;
49
- }
50
-
51
- input.invalid { background-color: #ffdddd; }
52
- input[type=text],
53
- input[type=email],
54
- input[type=password], select {
55
- box-sizing: border-box;
56
- width: 100%;
57
- padding: 8px 16px;
58
- border-radius: 4px;
59
- background-color: rgba(228, 241, 254, 1);
60
- border: 1px #ccc solid;
61
- border-bottom: 2px var(--app-black-color) solid;
62
- border-radius: 5px;
63
- text-align: center;
64
- }
65
-
66
- .action-button:focus, .topButton:focus {outline:0;}
67
- .action-button {
68
- display: inline-block;
69
- box-sizing: border-box;
70
- white-space: nowrap;
71
- margin: 10px 0 10px 0;
72
- font-weight: 400;
73
- text-align: center;
74
- vertical-align: middle;
75
- touch-action: manipulation;
76
- -webkit-appearance: button;
77
- cursor: pointer;
78
- font-size: 16px;
79
- height: 38px;
80
- line-height: 16px;
81
- width: 100%;
82
- padding: 10px 16px;
83
- border-radius: 6px;
84
- color: #fff;
85
- background-color: #6cc04a;
86
- border-color: #60b23e;
87
- box-shadow: 1px 1px 1px grey;
88
- }
89
-
90
- `;
91
-
92
- export const settings = html`<svg viewBox="0 0 24 24"><path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"></path></svg>`;
93
- export const close = html`<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></svg>`;
94
-
95
-
@@ -1,91 +0,0 @@
1
-
2
- /**
3
- @license
4
- Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
5
- This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
- The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
- The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
- Code distributed by Google as part of the polymer project is also
9
- subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10
- */
11
-
12
- import { Action, ActionCreator } from 'redux';
13
- import { ThunkAction } from 'redux-thunk';
14
- import { RootState } from './store.js';
15
-
16
- export const LOGGED_IN = 'LOGGED_IN';
17
- export const SETTINGS_PAGE = 'SETTINGS_PAGE';
18
-
19
- export const PROFILE_TYPE = 'PROFILE_TYPE';
20
- export const SIGN_IN = 'SIGN_IN';
21
-
22
- export const SET_USER = 'SET_USER';
23
- export const SET_IMAGE = 'SET_IMAGE';
24
- export const SET_NAME = 'SET_NAME';
25
-
26
- export const OPEN_SIGN = 'OPEN_SIGN';
27
- export const CLOSE_SIGN = 'CLOSE_SIGN';
28
-
29
- export const SIGN_UP_OPEN = "SIGN_UP_OPEN";
30
- export const SIGN_UP_CLOSE = "SIGN_UP_CLOSE";
31
-
32
- // export interface updateLoginX extends Action<'LOGGED_IN'> { logged: boolean };
33
- export interface navigateX extends Action<'SETTINGS_PAGE'> { option: string };
34
- export interface setImageX extends Action<'SET_IMAGE'> { image: string };
35
- export interface setNameX extends Action<'SET_NAME'> { name: string };
36
-
37
- export interface setAuthX extends Action<'LOGGED_IN'> { currentUser: boolean };
38
- export interface setUserX extends Action<'SET_USER'> { user: string };
39
- export interface profileX extends Action<'PROFILE_TYPE'> { profileType: string };
40
-
41
- export interface openSignX extends Action<'OPEN_SIGN'> { };
42
- export interface closeSignX extends Action<'CLOSE_SIGN'> { };
43
-
44
- export interface signUpOpen extends Action<'SIGN_UP_OPEN'> { };
45
- export interface signUpClose extends Action<'SIGN_UP_CLOSE'> { };
46
-
47
- export type AppAction = closeSignX | openSignX | signUpOpen | signUpClose | navigateX | setImageX | setNameX | setAuthX | setUserX | profileX;
48
-
49
- // export type AppAction = closeSignX | openSignX | signUpOpen | signUpClose | setImageX | setNameX ;
50
-
51
- type ThunkResult = ThunkAction<void, RootState, undefined, AppAction>;
52
-
53
- // NAVIGATION
54
- export const navigate: ActionCreator<navigateX> = (option: string) => {
55
- switch(option) {
56
-
57
- case 'profile':
58
- break;
59
- case 'email':
60
- break;
61
- case 'password':
62
- break;
63
- case 'delete':
64
- break;
65
-
66
- default: option = 'profile';
67
-
68
- }
69
- return { type: SETTINGS_PAGE, option }
70
- }
71
-
72
- export const openSign: ActionCreator<ThunkResult> = ( snackState: boolean ) => (dispatch, getState) => {
73
- if ( getState().user!.snackState === true) { dispatch({ type: CLOSE_SIGN, snackState }); }
74
- else { dispatch({ type: OPEN_SIGN, snackState }); }
75
- }
76
- export const signUp: ActionCreator<ThunkResult> = ( register: boolean ) => (dispatch, getState) => {
77
- if ( getState().user!.register === false) { dispatch({ type: SIGN_UP_OPEN, register }); }
78
- else { dispatch({ type: SIGN_UP_CLOSE, register }); }
79
- }
80
-
81
- // export const updateLogin: ActionCreator<updateLoginX> = ( logged: boolean ) => { return { type: LOGGED_IN, logged }; };
82
- export const setAuth: ActionCreator<setAuthX> = ( currentUser: boolean ) => { return { type: LOGGED_IN, currentUser }; };
83
- export const setUser: ActionCreator<setUserX> = ( user: string ) => { return { type: SET_USER, user }; };
84
-
85
- export const setImage: ActionCreator<setImageX> = ( image: string ) => { return { type: SET_IMAGE, image }; };
86
- export const setName: ActionCreator<setNameX> = ( name: string ) => { return { type: SET_NAME, name }; };
87
- export const closeSign: ActionCreator<closeSignX> = ( closeLogIN: boolean ) => { return { type: CLOSE_SIGN, closeLogIN } };
88
-
89
- // export const profile: ActionCreator<profileX> = ( profileType: string ) => { return { type: PROFILE_TYPE, profileType } };
90
- // export const signUp = (register) => { return { type: IN_UP, register }; }
91
-
@@ -1,168 +0,0 @@
1
-
2
-
3
- /**
4
- @license
5
- Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
6
- This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
7
- The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
8
- The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
9
- Code distributed by Google as part of the polymer project is also
10
- subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
11
- */
12
-
13
- // @ts-check
14
-
15
- import { html, LitElement, css, customElement, property } from 'lit-element';
16
- import { connect } from 'pwa-helpers/connect-mixin.js';
17
- import { store, RootState } from './store';
18
- import { userStyles, close } from './styles';
19
- import { User } from './styles-drawer';
20
- import { closeSign, signUp } from './user-action';
21
- import { logOut, anon, google } from './user-functions';
22
-
23
- @customElement('user-drawer')
24
- export class UserDrawer extends connect(store)(LitElement) {
25
-
26
- @property({type: Boolean})
27
- private _log = false;
28
-
29
- @property({type: Boolean})
30
- private _subscribe = false;
31
-
32
- @property({type: Boolean})
33
- private _sign = false;
34
-
35
- constructor() {
36
- super();
37
- }
38
-
39
- protected firstUpdated() {
40
- this.shadowRoot!.getElementById('close') .addEventListener('click', () => { store.dispatch( closeSign(false) ) } );
41
- this.shadowRoot!.getElementById('or') .addEventListener('click', () => { anon() } );
42
- this.shadowRoot!.getElementById('googleSignIn') .addEventListener('click', () => { google() } );
43
- this.shadowRoot!.getElementById('leave') .addEventListener('click', () => { logOut() } );
44
- this.shadowRoot!.getElementById('log') .addEventListener('click', () => { this._signIn() } );
45
- this.shadowRoot!.getElementById('newUser') .addEventListener('click', () => { this._signUp() } );
46
- this.shadowRoot!.getElementById('new') .addEventListener('click', () => { store.dispatch( signUp() ) } );
47
- }
48
-
49
- stateChanged(state: RootState) {
50
- this._subscribe = state.user!.snackState;
51
- this._log = state.user!.currentUser;
52
- this._sign = state.user!.register;
53
- // this.welcome = state.user.welcome;
54
- }
55
-
56
- private _drawerOpenedChanged(e: Event) {
57
- store.dispatch(updateDrawerState((e.target as AppDrawerElement).opened));
58
- }
59
-
60
- private _signIn() {
61
- const a = this.shadowRoot!.getElementById('logs');
62
- a.addEventListener('click', (e:Event) => { e.preventDefault(); });
63
- // Prevent Form's Page Refresh
64
- const email = this.shadowRoot!.getElementById('txtEmail').value;
65
- const password = this.shadowRoot!.getElementById('txtPassword').value;
66
- // @ts-ignore
67
- firebase.auth().signInWithEmailAndPassword(email, password).catch( (error) => {
68
- const errorCode = error.code;
69
- const errorMessage = error.message;
70
- });
71
- }
72
-
73
- private _signUp() {
74
- const email = this.shadowRoot!.getElementById('newtEmail').value;
75
- const pass = this.shadowRoot!.getElementById('newPassword').value;
76
- if (email.length < 4) {
77
- alert('Please enter an email address.');
78
- return;
79
- }
80
- if (pass.length < 4) {
81
- alert('Please enter a password.');
82
- return;
83
- }
84
- // @ts-ignore
85
- firebase.auth().createUserWithEmailAndPassword(email, pass).catch( (error) => {
86
- const errorCode = error.code;
87
- const errorMessage = error.message;
88
- // [START_EXCLUDE]
89
- if (errorCode == 'auth/weak-password') {
90
- alert('The password is too weak.');
91
- } else {
92
- alert(errorMessage);
93
- }
94
- console.log(error);
95
-
96
- });
97
- }
98
-
99
- static get styles() {
100
- return [
101
- userStyles,
102
- User,
103
- css`
104
- :host {
105
-
106
- }
107
- `
108
- ]}
109
-
110
- protected render() {
111
- return html`
112
-
113
- <!-- Login Wrapper -->
114
- <div class="visibility userDrawer" ?on="${ this._subscribe === true }">
115
-
116
- <div class="exit">
117
- <div></div>
118
- <h3 id="or">${this._log ? html`ACCOUNT` : html`SUBSCRIBE` }</h3>
119
- <button id="close" class="sign-right">${close}</button>
120
- </div>
121
-
122
- <div class="spec" ?on="${ this._log === false }">
123
-
124
- <p><button id="googleSignIn" class="google">
125
- <span class="icon"></span>
126
- <span class="buttonText">Sign in with Google</span>
127
- </button></p>
128
-
129
- <p><button id="new">create a new account</button></p>
130
-
131
- </div>
132
- <!--
133
- <form id="logs" autocomplete="on" class="spec" \?on="\${ this._sign === true }">
134
- <ul>
135
- <li class="inpat">
136
- <label><input id="txtEmail" type="email" >Email</label>
137
- <label><input id="txtPassword" type="Password" >Password</label>
138
- </li>
139
- <li><button id="log" class="action-button">Sign in</button></li>
140
- </ul>
141
- </form>
142
- -->
143
-
144
- <!-- Sign UP
145
- <form id="signup" autocomplete="on" class="spec" \?on="\${ this._sign === false }">
146
- <ul>
147
- <li class="inpat">
148
- <label><input id="newEmail" type="email" >Email</label>
149
- <label><input id="newPassword" type="Password" >Password</label>
150
- <label><input id="verifyEmail" type="email" >Verify Email</label>
151
- <label><input id="veriftPassword" type="Password" >Verify Password</label>
152
- </li>
153
- <li><button id="newUser" class="action-button">Sign up</button></li>
154
- </ul>
155
- </form>
156
- -->
157
-
158
- <!-- Logged IN -->
159
- <div class="spec setLog" ?on="${ this._log === true }">
160
- <slot></slot>
161
- <p><a href="/settings">Settings</a></p>
162
- <p><a id="leave" aria-label="log out">log out</a></p>
163
- </div>
164
-
165
- </div>
166
- `;
167
- }
168
- }