-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
473 lines (395 loc) · 15.1 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<link rel="stylesheet" type="text/css" href="dist/css/default.css">
<style type="text/css">
[type="color"] {
height: 1.5em;
width: 3em;
padding: 0.0625em 0.125em;
}
.layout {
background-color: #e5e5e5;
font-size: 0.8125em;
margin-bottom: 0.25em;
padding: 0 1em;
}
#demo {
background-color: #e5e5e5;
border: 1px solid #808080;
border-radius: 0.1875em;
color: inherit;
display: inline-block;
padding: 0.5em 1em;
text-decoration: none;
}
#demo:active,
#demo:hover {
background-color: #cccccc;
filter: brightness(1);
}
textarea {
min-height: 50vh;
}
[readonly] {
font-family: Menlo, Monaco, "Courier New", monospace;
}
</style>
</head>
<body>
<div class="container">
<h1>Demo</h1>
<details class="margin-bottom-small" open>
<summary><strong>1. Pick your layout</strong></summary>
<p>This controls the layout of the header, navigation, main content, and footer.</p>
<label>
<input type="radio" name="theme" value="default" checked>
Default
<div aria-hidden="true">
<div class="layout text-right">User Nav</div>
<div class="row margin-bottom">
<div class="layout grid-fourth">Logo</div>
<div class="layout grid-three-fourths">Main Nav</div>
</div>
</div>
</label>
<label>
<input type="radio" name="theme" value="combo">
Combo Nav
<div aria-hidden="true">
<div class="row margin-bottom">
<div class="layout grid-fourth">Logo</div>
<div class="layout grid-half">Main Nav</div>
<div class="layout grid-fourth text-right">User Nav</div>
</div>
</div>
</label>
<label>
<input type="radio" name="theme" value="big">
Big Nav
<div aria-hidden="true">
<div class="row">
<div class="layout grid-fourth">Logo</div>
<div class="layout grid-three-fourths text-right">User Nav</div>
</div>
<div class="margin-bottom"><div class="layout">Main Nav</div></div>
</div>
</label>
<label>
<input type="radio" name="theme" value="simple">
Simple
<div class="padding-bottom" aria-hidden="true">
<div class="margin-bottom text-center">
<div class="layout">User Nav</div>
<div class="layout">Logo</div>
<div class="layout">Main Nav</div>
</div>
</div>
</label>
</details>
<details class="margin-bottom-small" open>
<summary><strong>2. Set your colors</strong></summary>
<p class="margin-bottom-small padding-top"><strong>Core Colors</strong></p>
<div class="row">
<div class="grid-fifth">
<label class="input-inline" for="color-black">Body Text</label>
<input type="color" data-var="colors" id="color-black" value="#272727">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-primary">Primary Color</label>
<input type="color" data-var="colors" id="color-primary" value="#0088cc">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-primary-shade">Primary Color (Shade)</label>
<input type="color" data-var="colors" id="color-primary-shade" value="#09567f">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-secondary">Secondary Color</label>
<input type="color" data-var="colors" id="color-secondary" value="#377f31">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-secondary-shade">Secondary Color (Shade)</label>
<input type="color" data-var="colors" id="color-secondary-shade" value="#2e652a">
</div>
</div>
<div class="row">
<div class="grid-fifth">
<label class="input-inline" for="color-accent-1">Accent Color 1</label>
<input type="color" data-var="colors" id="color-accent-1" value="#dba909">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-accent-2">Accent Color 2</label>
<input type="color" data-var="colors" id="color-accent-2" value="#880e14">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-accent-3">Accent Color 3</label>
<input type="color" data-var="colors" id="color-accent-3" value="#860d8e">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-accent-4">Accent Color 4</label>
<input type="color" data-var="colors" id="color-accent-4" value="#cc7100">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-accent-5">Accent Color 5</label>
<input type="color" data-var="colors" id="color-accent-5" value="#00557f">
</div>
</div>
<p class="margin-bottom-small padding-top"><strong>Grayscale</strong></p>
<div class="row">
<div class="grid-fifth">
<label class="input-inline" for="color-gray-darker">Gray (Darker)</label>
<input type="color" data-var="colors" id="color-gray-darker" value="#555555">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-gray-dark">Gray (Dark)</label>
<input type="color" data-var="colors" id="color-gray-dark" value="#808080">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-gray-medium">Gray (Medium)</label>
<input type="color" data-var="colors" id="color-gray-medium" value="#b2b2b2">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-gray-light">Gray (Light)</label>
<input type="color" data-var="colors" id="color-gray-light" value="#e5e5e5">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-gray-lighter">Gray (Lighter)</label>
<input type="color" data-var="colors" id="color-gray-lighter" value="#f7f7f7">
</div>
</div>
<p class="margin-bottom-small padding-top"><strong>HTTP Methods & Code Samples</strong></p>
<div class="row">
<div class="grid-fifth">
<label class="input-inline" for="color-get">GET</label>
<input type="color" data-var="colors" id="color-get" value="#0088cc">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-get-bg">GET Background</label>
<input type="color" data-var="colors" id="color-get-bg" value="#e7f3fa">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-post">POST</label>
<input type="color" data-var="colors" id="color-post" value="#377f31">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-post-bg">POST Background</label>
<input type="color" data-var="colors" id="color-post-bg" value="#ebf2ea">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-put">PUT</label>
<input type="color" data-var="colors" id="color-put" value="#dba909">
</div>
</div>
<div class="row">
<div class="grid-fifth">
<label class="input-inline" for="color-put-bg">PUT Background</label>
<input type="color" data-var="colors" id="color-put-bg" value="#fbf6e7">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-delete">DELETE</label>
<input type="color" data-var="colors" id="color-delete" value="#880e14">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-delete-bg">DELETE Background</label>
<input type="color" data-var="colors" id="color-delete-bg" value="#fdf2f3">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-patch">PATCH</label>
<input type="color" data-var="colors" id="color-patch" value="#860d8e">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-patch-bg">PATCH Background</label>
<input type="color" data-var="colors" id="color-patch-bg" value="#fcf3fc">
</div>
</div>
<div class="row margin-bottom">
<div class="grid-fifth">
<label class="input-inline" for="color-options">OPTIONS</label>
<input type="color" data-var="colors" id="color-options" value="#cc7100">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-options-bg">OPTIONS Background</label>
<input type="color" data-var="colors" id="color-options-bg" value="#fff7ec">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-head">HEAD</label>
<input type="color" data-var="colors" id="color-head" value="#00557f">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-head-bg">HEAD Background</label>
<input type="color" data-var="colors" id="color-head-bg" value="#f1f9ff">
</div>
<div class="grid-fifth">
<label class="input-inline" for="color-code">Inline Code</label>
<input type="color" data-var="colors" id="color-code" value="#dd1144">
</div>
</div>
</details>
<details class="margin-bottom-small">
<summary><strong>3. Add a logo (<em>optional</em>)</strong></summary>
<p>This can be hosted externally or uploaded to the File Manager in the API Control Center. By default, your portal name is displayed as text.</p>
<label for="logo">Logo Image URL</label>
<input class="margin-bottom" type="input" id="logo">
</details>
<details class="margin-bottom-small">
<summary><strong>4. Customize your fonts (<em>optional</em>)</strong></summary>
<label class="padding-top" for="font-primary">Primary Font Stack (<em>comma-separated</em>)</label>
<input type="input" data-var="fonts" id="font-primary" value='"Helvetica Neue", Arial, sans-serif'>
<label for="font-monospace">Monospace Font Stack (<em>for code snippets</em>)</label>
<input type="input" data-var="fonts" id="font-monospace" value='Menlo, Monaco, "Courier New", monospace'>
<label for="font-size">Font Size</label>
<input type="input" data-var="fonts" class="margin-bottom" id="font-size" value="100%">
</details>
<details class="margin-bottom-small">
<summary><strong>5. Adjust size and spacing (<em>optional</em>)</strong></summary>
<p>Control how wide the page is and how much space is shown between various elements.</p>
<label for="spacing">Spacing (<em>between paragraphs and other elements</em>)</label>
<input type="input" data-var="spacing" id="spacing" value="1.5625em">
<label for="container-width">Container Width</label>
<input type="input" data-var="spacing" id="container-width" value="88%">
<label for="container-max-width">Max Container Size</label>
<input type="input" data-var="spacing" id="container-max-width" value="80em">
<label for="container-max-width-small">Max Container Size on Small Viewports</label>
<input type="input" data-var="spacing" class="margin-bottom" id="container-max-width-small" value="50em">
</details>
<details class="margin-bottom-small" open>
<summary><strong>6. Load your theme</strong></summary>
<p>In the API Control Center under Manage > Portal > Portal Setup, add the following files and configurations.</p>
<label for="js-url"><strong>Head JavaScript File URL</strong></label>
<input type="text" id="js-url" value="https://cdn.jsdelivr.net/gh/mashery/keel@0/dist/js/keel.min.js" readonly>
<label for="css-url"><strong>Screen Stylesheet URL</strong></label>
<input type="text" id="css-url" value="https://cdn.jsdelivr.net/gh/mashery/keel@0/dist/css/default.css" readonly>
<label for="js-inline"><strong>Inline JavaScript > Head JavaScript</strong></label>
<textarea id="js-inline" readonly>// Default Layout
keel.header('navUser', 'logo', 'navMain');
keel.ready(function () {
let dom = keel.getDOM();
let wrap = keel.wrap(dom.logo, dom.navMain);
wrap.className = 'logo-nav-wrapper';
});</textarea>
<label for="css-inline"><strong>Inline CSS > "Last Minute" CSS Overrides</strong></label>
<textarea id="css-inline" readonly></textarea>
<p><a id="demo" target="_blank" href="https://stagingcs17.mashery.com">Live Preview</a></p>
</details>
</div>
<script>
//
// Variables
//
// DOM Nodes
let cssURL = document.querySelector('#css-url');
let jsInline = document.querySelector('#js-inline');
let cssInline = document.querySelector('#css-inline');
let logo = document.querySelector('#logo');
let demo = document.querySelector('#demo');
// Data
let cdn = 'https://cdn.jsdelivr.net/gh/mashery/keel@0/dist';
let settings = {
colors: {},
fonts: {},
spacing: {}
};
//
// Methods
//
function setDemoURL () {
// The settings details
let details = {};
// Create details for colors, fonts, and spacing
for (let [key, obj] of Object.entries(settings)) {
if (!Object.keys(obj).length) continue;
details[key] = Object.entries(obj).map(function (entries) {
let [name, val] = entries;
return `${name}:${val}`;
});
}
// Set the theme and logo
details.theme = document.querySelector('[name="theme"]:checked').value;
if (logo.value.length) { details.logo = logo.value; }
demo.href = `http://stagingcs17.mashery.com?${new URLSearchParams(details).toString()}`;
}
function getThemeJS () {
let theme = document.querySelector('[name="theme"]:checked').value;
if (theme === 'default') {
return `// Default Layout
keel.header('navUser', 'logo', 'navMain');
keel.ready(function () {
let dom = keel.getDOM();
let wrap = keel.wrap(dom.logo, dom.navMain);
wrap.className = 'logo-nav-wrapper';
});`;
}
if (theme === 'combo') {
return `// Combo Nav Layout
keel.header('logo', 'navMain', 'navUser');`;
}
if (theme === 'big') {
return `// Big Nav Layout
keel.header('logo', 'navUser', 'navMain');
keel.ready(function () {
let dom = keel.getDOM();
let wrap = keel.wrap(dom.logo, dom.navUser);
wrap.className = 'logo-nav-wrapper';
});`;
}
if (theme === 'simple') {
return `// Simple Layout - User, Logo, Main
keel.header('navUser', 'logo', 'navMain');`;
}
}
function getLogoJS () {
if (logo.value.length) {
return `
// Logo
keel.logo('${logo.value}');`;
}
return '';
}
function getThemeCSS () {
// Setup items
let css = {
colors: [],
fonts: [],
spacing: []
};
// Create CSS variables
for (let [key, obj] of Object.entries(settings)) {
for (let [prop, value] of Object.entries(obj)) {
css[key].push(` --${prop}: ${value};`);
}
}
// If there are no vars to set, return an empty string
if (!css.colors.length && !css.fonts.length && !css.spacing.length) return '';
return `:root {${css.colors.length ? `\n\n /* Colors */\n${css.colors.join("\n")}` : ''}${css.fonts.length ? `\n\n /* Fonts */\n${css.fonts.join("\n")}` : ''}${css.spacing.length ? `\n\n /* Width & Spacing */\n${css.spacing.join("\n")}` : ''}
}`;
}
function handleTheme (input) {
if (input.name !== 'theme') return;
cssURL.value = `${cdn}/css/${input.value}.css`;
jsInline.value = getThemeJS() + getLogoJS();
}
function handleVars (input) {
let type = input.getAttribute('data-var');
if (!type) return;
settings[type][input.id] = input.value;
cssInline.value = getThemeCSS();
}
function handleLogo (input) {
if (input.id !== 'logo') return;
jsInline.value = getThemeJS() + getLogoJS();
}
//
// Inits & Event Listeners
//
setDemoURL();
document.addEventListener('input', function (event) {
if (event.target.hasAttribute('readonly')) return;
handleTheme(event.target);
handleVars(event.target);
handleLogo(event.target);
setDemoURL();
});
</script>
</body>
</html>