-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
166 lines (149 loc) · 3.96 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
padding: 0;
margin: 0;
background: #ccc;
font-family: Arial, Helvetica, sans-serif;
}
.demo-content {
padding: 0 36px;
}
.demo-item {
height: 48px;
display: flex;
justify-content: start;
align-content: center;
align-items: flex-end;
flex-direction: row;
}
.demo-item .column {
display: flex;
flex-direction: column;
}
.demo-item label {
font-size: 14px;
margin-bottom: 4px;
}
.demo-item input {
height: 36px;
border-radius: 5px;
margin-right: 8px;
font-size: 14px;
border: none;
}
.demo-item button {
min-width: 48px;
min-height: 24px;
padding: 8px 8px;
font-size: 14px;
overflow-y: hidden;
border-radius: 5px;
transition: background 0.15s ease-in-out;
}
.demo-item button:hover {
background: #ebebeb;
cursor: pointer;
}
</style>
<!-- App bar with profile button -->
<myuw-app-bar
theme-name="MyUW"
app-name="Profile Demo"
app-url=""
background="rgb(197, 5, 12)"
color="white"
>
<myuw-profile
slot="myuw-profile"
login-url="https://wisc.edu/"
logout-url="https://wisc.edu/"
>
<a href="#" slot="nav-item">UW Madison Home</a>
<a href="#" slot="nav-item">STAR</a>
</myuw-profile>
</myuw-app-bar>
<!-- Demo content -->
<div class="demo-content">
<h1>Demo</h1>
<div class="demo-item">
<input id="newColor" type="color" onchange="controller.setColor(this.value)">
<label for="newColor">Profile Color</label>
</div>
<div class="demo-item">
<button aria-label="set no session" onclick="controller.logout()">No session</button>
</div>
<div class="demo-item">
<button aria-label="restore demo session" onclick="controller.setPortalSession()">Set portal session</button>
</div>
<div class="demo-item">
<button aria-label="set a session without user info" onclick="controller.setNonstandardSession()">Set session without person info</button>
</div>
<div class="demo-item">
<button aria-label="log in with other data" onclick="controller.customLogin()">Set custom session</button>
</div>
</div>
<script src="https://unpkg.com/css-vars-ponyfill@1"></script>
<script type="module">
import "https://unpkg.com/@myuw-web-components/myuw-app-styles@latest/dist/myuw-app-styles.min.mjs";
import "https://unpkg.com/@myuw-web-components/[email protected]/dist/myuw-app-bar.min.mjs";
import './dist/myuw-profile.mjs';
cssVars({shadowDOM: true,watch: true});
class Controller {
customLogin(event) {
document.dispatchEvent(new CustomEvent('myuw-login', {
bubbles: true,
detail: {
person: { "firstName": "Shibboleth" }
}
}));
}
logout() {
document.dispatchEvent(new CustomEvent('myuw-login', {
bubbles: true,
detail: {
person: null
}
}));
}
setNonstandardSession() {
document.dispatchEvent(new CustomEvent('myuw-login', {
bubbles: true,
detail: {
person: { "someOtherAttribute": "What is this" }
}
}));
}
async setPortalSession() {
try {
const res = await fetch('./test/session.json');
if (res.status !== 200) {
document.dispatchEvent(new CustomEvent('myuw-login', {
bubbles: true,
detail: { person: null }
}));
return;
}
const data = await res.json()
if(!data.person) {
return;
}
document.dispatchEvent(new CustomEvent('myuw-login', {
bubbles: true,
detail: { person: data.person }
}));
}
catch(e) {
document.dispatchEvent(new CustomEvent('myuw-login', {
bubbles: true,
detail: { person: null }
}));
}
}
setColor(newColor) {
document.getElementsByTagName('myuw-profile')[0].setAttribute('background-color', newColor);
}
}
window.controller = new Controller();
</script>