-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
95 lines (83 loc) · 2.56 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sign in with Matrix demo</title>
</head>
<body>
<h1 id="status"></h1>
<pre id="profile"></pre>
<matrix-signin id="signin"></matrix-signin>
<div>
<matrix-signin-button target="signin">
Sign in with Matrix
</matrix-signin-button>
<a id="signout_button" href="#" onclick="signOut()">Sign out</a>
</div>
<!-- <script type="module" src="/src/main.ts"></script> -->
<script type="module" src="https://unpkg.com/signin-with-matrix@latest/dist/index.es.js"></script>
<script>
const signIn = document.querySelector('matrix-signin')
const signInButton = document.querySelector('matrix-signin-button')
const status = document.getElementById('status')
const pre = document.getElementById('profile')
const signOutButton = document.getElementById('signout_button')
signIn.addEventListener('success', ({ detail }) => {
pre.style.display = 'block'
pre.innerText = JSON.stringify(detail)
signInButton.style.display = 'none'
signOutButton.style.display = 'inline-block'
status.innerText = 'Success 😎'
})
signIn.addEventListener('cancel', () => {
status.innerText = 'Cancelled 🙁'
})
const signOut = () => {
signIn.signOut()
.then(() => {
pre.style.display = 'none'
signOutButton.style.display = 'none'
signInButton.style.display = 'block'
status.innerText = 'Signed out 👋'
})
}
</script>
<style>
body, html {
height: 100%;
}
body {
margin: 0;
padding: 24px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
display: flex;
flex-direction: column;
margin: auto;
max-width: 800px;
align-items: center;
justify-content: center;
}
h1 {
font-size: 38px;
font-weight: 800;
text-align: center;
}
pre {
display: none;
overflow: hidden;
white-space: normal;
word-break: break-all;
padding: 20px;
border-radius: 4px;
background: rgba(0,0,0,.05);
}
#signout_button {
display: none;
margin-left: 6px;
color: black;
}
</style>
</body>
</html>