-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
246 lines (199 loc) · 6.9 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><juicy-popover></title>
<link rel="stylesheet" href="http://juicy.github.io/github-markdown-css/github-markdown.css">
<!-- Importing Web Component's Polyfill -->
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<!-- Importing Custom Elements -->
<link rel="import" href="src/juicy-popover.html">
<style>
html {
min-height: 100%;
}
body {
padding: 2em;
font-family: sans-serif;
}
h3 {
margin-bottom: 0.2em;
font-weight: normal;
}
code {
font-family: Consolas, monospace;
}
/*#combo example*/
#color-container {
white-space: nowrap;
}
#color {
margin-right: 0;
height: 17px;
width: 300px;
}
#combo {
display: inline-block;
margin-left: -28px;
}
#combo button[slot="handle"] {
color: #fff;
text-shadow: -2px 2px rgba(0, 0, 0, .2);
background-color: #6496c8;
box-shadow: inset 0 0 0 1px #27496d;
border: none;
border-radius: 2px;
padding: 1px 4px;
}
#combo button[slot="handle"]:hover {
box-shadow: inset 0 0 0 1px #27496d, 0 0 5px #193047;
}
#combo button[slot="handle"]:active,
#combo[expanded] button[slot="handle"] {
box-shadow: inset 0 0 0 1px #27496d, inset 0 5px 30px #193047;
}
#combo div[slot="expandable"] {
display: none;
background: #fff;
border: 1px solid rgba(0, 0, 0, .2);
box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
padding: 5px;
}
#combo[expanded] div[slot="expandable"] {
display: block;
}
/*#rightexpand example*/
#rightexpand {
margin-left: 200px;
}
#rightexpand div[slot="handle"] {
display: inline-block;
cursor: default;
color: #fff;
text-shadow: -2px 2px rgba(0, 0, 0, .2);
background-color: #6496c8;
box-shadow: inset 0 0 0 1px #27496d;
border: none;
border-radius: 2px;
font-size: 14px;
padding: 2px;
}
#rightexpand div[slot="expandable"] {
display: none;
background: #fff;
border: 1px solid rgba(0, 0, 0, .2);
box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
padding: 5px;
width: 200px;
}
#rightexpand[expanded] div[slot="expandable"] {
display: block;
}
</style>
</head>
<body>
<h1><juicy-popover></h1>
<p><juicy-popover>is a (vanilla) Custom Element that expands an area when clicked on a handle.</p>
<p>It is flexible enough to be used to create dropdowns, combo boxes, tooltips, etc.</p>
<p>See <a href="https://github.com/Juicy/juicy-popover">README.md</a> for docs</p>
<h2>Sample combo box (automatic position)</h2>
<div>Choose your favorite color:
<span id="color-container">
<input type="text" id="color" placeholder="<color>">
<juicy-popover id="combo">
<button slot="handle">▼</button>
<div slot="expandable">
<button onclick="document.querySelector('#color').value = 'red'">Red</button>
<br>
<button onclick="document.querySelector('#color').value = 'green'">Green</button>
<br>
<button onclick="document.querySelector('#color').value = 'black'">Black</button>
<br>
<button onclick="document.querySelector('#color').value = 'blue'">Blue</button>
</div>
</juicy-popover>
</span>
</div>
<h2>Sample expandable menu</h2>
Expand on:
<label><input type="radio" name="expand-on" value="click" checked>Mouse click</label>
<label><input type="radio" name="expand-on" value="hover">Mouse hover</label>
<h3><code>position="bottom left, bottom beforeright"</code> (fallback positions separated by a comma)</h3>
<juicy-popover id="rightexpand" position="bottom left, bottom beforeright">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="middle center"</code></h3>
<juicy-popover id="rightexpand" position="middle center">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="top beforeleft"</code></h3>
<juicy-popover id="rightexpand" position="top beforeleft">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="beforetop center"</code></h3>
<juicy-popover id="rightexpand" position="beforetop center">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="top left"</code></h3>
<juicy-popover id="rightexpand" position="top left">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="top right"</code></h3>
<juicy-popover id="rightexpand" position="top right">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="beforetop beforeleft"</code></h3>
<juicy-popover id="rightexpand" position="beforetop beforeleft">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="beforetop left"</code></h3>
<juicy-popover id="rightexpand" position="beforetop left">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="beforetop right"</code></h3>
<juicy-popover id="rightexpand" position="beforetop right">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="bottom beforeleft"</code></h3>
<juicy-popover id="rightexpand" position="bottom beforeleft">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="bottom left"</code></h3>
<juicy-popover id="rightexpand" position="bottom left">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="bottom center"</code></h3>
<juicy-popover id="rightexpand" position="bottom center">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<h3><code>position="bottom right"</code></h3>
<juicy-popover id="rightexpand" position="bottom right">
<div slot="handle">Expand ▶</div>
<div slot="expandable">Expanded content</div>
</juicy-popover>
<script>
(function () {
var popoverRadios = document.querySelectorAll('input[name="expand-on"]');
popoverRadios.forEach(radio => {
radio.addEventListener('change', event => {
document.querySelectorAll('juicy-popover').forEach(popover => {
popover.setAttribute('expand-on', radio.value);
});
});
});
})();
</script>
</body>
</html>