-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
199 lines (186 loc) · 5.6 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
padding: 0;
margin: 0;
background: #ccc;
}
</style>
<!-- Polyfill loader -->
<script src="https://unpkg.com/@webcomponents/[email protected]/webcomponents-bundle.js"></script>
<script type="module">
import "https://unpkg.com/css-vars-ponyfill@1";
import "https://unpkg.com/@myuw-web-components/myuw-app-styles/dist/myuw-app-styles.min.mjs";
import "https://unpkg.com/@myuw-web-components/myuw-app-bar/dist/myuw-app-bar.min.mjs";
import "https://unpkg.com/@myuw-web-components/myuw-drawer/dist/myuw-drawer.min.mjs";
import "https://unpkg.com/@myuw-web-components/myuw-notifications/dist/myuw-notifications.min.mjs";
import "https://unpkg.com/@myuw-web-components/myuw-profile/dist/myuw-profile.min.mjs";
import "https://unpkg.com/@myuw-web-components/myuw-help/dist/myuw-help.min.mjs";
import "https://unpkg.com/@myuw-web-components/myuw-feedback/dist/myuw-feedback.min.mjs";
import "./dist/myuw-search.mjs";
cssVars({shadowDOM: true,watch: true});
document.addEventListener('WebComponentsReady', function() {
var customEvent = new CustomEvent('myuw-login', {
bubbles: true, // optional
detail: { // required always
person: { // required for generic session display
"firstName": "User" // required for full session display
}
}
});
// Dispatch the event
document.dispatchEvent(customEvent);
});
// Add a callback to the serach component
document.body.addEventListener('myuw-search', function(event) {
var value = event.detail.value;
var label = document.getElementById('searchLabel');
var searchValue = document.getElementById('searchValue');
label.innerText = 'You searched for: ';
searchValue.innerText = '"' + value + '"';
}, false);
function updateSearchBar() {
// Get all elements
var searchBar = document.getElementsByTagName('myuw-search')[0];
var ariaLabel = document.getElementById('searchAriaLabel');
var placeholder = document.getElementById('searchPlaceholder');
var icon = document.getElementById('searchIcon');
// Update populated fields
if (ariaLabel.value) {
searchBar.setAttribute('button-label', ariaLabel.value);
}
if (placeholder.value) {
searchBar.setAttribute('input-label', placeholder.value);
}
if (icon.value) {
searchBar.setAttribute('icon', icon.value);
}
}
</script>
<!-- Styles for demo purposes only -->
<style>
.test-content {
text-align: center;
max-width: 80%;
margin: 0 auto;
font-family: var(--myuw-font, 'Red Hat Text' 'Arial', sans-serif);
font-size: 16px;
}
.test-content button {
min-width: 48px;
min-height: 24px;
max-height: 36px;
padding: 8px 8px;
font-size: 14px;
overflow-y: hidden;
border-radius: 5px;
transition: background 0.15s ease-in-out;
background: var(--myuw-accent-bg);
color: var(--myuw-accent-color);
outline: none;
}
.test-content button:hover {
background: #046085;
cursor: pointer;
}
#searchValue {
font-size: 30px;
}
.test-content form {
display: flex;
flex-direction: column;
margin: 0 auto;
max-width: 500px;
align-items: flex-start;
}
.test-content form .form-control {
margin: 8px 0;
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
}
.test-content label {
font-size: 16px;
margin-right: 12px;
display: flex;
align-items: center;
align-content: center;
line-height: 24px;
}
.test-content input {
height: 36px;
border-radius: 5px;
margin-right: 8px;
font-size: 16px;
border: 1px rgb(196, 196, 196) solid;
padding: 0 12px;
flex: auto;
}
</style>
<myuw-app-bar
role="toolbar"
theme-name="MyUW"
theme-url="https://my.wisc.edu"
app-name="Search Demo"
>
<myuw-drawer slot="myuw-navigation">
<myuw-drawer-link
slot="myuw-drawer-links"
name="MyUW home"
icon="mail"
href="http://google.com"
></myuw-drawer-link>
<myuw-drawer-link
slot="myuw-drawer-links"
name="Browse apps"
icon="explore"
href="http://google.com"
></myuw-drawer-link>
</myuw-drawer>
<myuw-search
id="search"
slot="myuw-search"
icon="search"
input-label="Search the demo"
button-label="Submit the search"
></myuw-search>
<myuw-help
slot="myuw-help"
myuw-help-title="Get help"
show-button
show-default-content
></myuw-help>
<myuw-notifications slot="myuw-notifications"></myuw-notifications>
<myuw-profile
slot="myuw-profile"
login-url="/"
logout-url="/"
background-color=""
></myuw-profile>
</myuw-app-bar>
<div class="demo__container">
<div class="test-content">
<div role="status">
<h1 id="searchLabel">Try using the search bar!</h1>
<p id="searchValue"></p>
</div>
<form name="searchDemo" onsubmit="event.preventDefault();updateSearchBar();">
<div class="form-control">
<label for="searchPlaceholder">Search box placeholder:</label>
<input id="searchPlaceholder" type="text" placeholder="Search MyUW">
</div>
<div class="form-control">
<label for="searchAriaLabel">Search button aria-label:</label>
<input id="searchAriaLabel" type="text" placeholder="Submit MyUW search">
</div>
<div class="form-control">
<label for="searchIcon">Material icon:</label>
<input id="searchIcon" type="text" placeholder="search">
</div>
<button>Update search component</button>
</form>
</div>
</div>