forked from SolidOS/solid-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
96 lines (86 loc) · 3.08 KB
/
Copy pathindex.html
File metadata and controls
96 lines (86 loc) · 3.08 KB
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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset='UTF-8'>
<title>solid-ui UI.widgets.header examples page</title>
<script type="text/javascript" src="../../lib/webpack-bundle.js"></script>
<script type="text/javascript" src="../../lib/index.js"></script> <script>
const $ = document.querySelector.bind(document)
function showSource(widgetName) {
$(`#viewSource-${widgetName}`).innerHTML = $(`#script-${widgetName}`).innerText
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'")
}
</script>
</head>
<body>
<h2 id="header"><a href="#header">Header</a>
<div id="webId"></div>
<div id="loginBanner"></div>
<script>
loginBanner.appendChild(UI.login.loginStatusBox(document, null, {}));
async function finishLogin() {
await UI.authSession.handleIncomingRedirect();
const session = UI.authSession;
if (session.info.isLoggedIn) {
// Update the page with the status.
webId.innerHTML = "Logged in as: " + authn.currentUser().uri;
} else {
webId.innerHTML = "";
}
}
finishLogin();
</script>
</h2>
<p>This example demonstrates how to use the header component. The header has a different view depending
on whether or not you are logged in. </p>
<p>Unless you are already logged into your pod identity provider you
should see the logged out view. To see the logged in view click the login button above. </p>
<p>The header is customizable through the options parameter.</p>
<p>The logo can be a url of your personalized logo, otherwise it will default to Solid. </p>
<p>The menu list is an array of either links or buttons. </p>
<p>The details are below. </p>
<p><strong>options:</strong>
<code>
type HeaderOptions {
logo?: string,
menuList?: MenuItems[]
}</code></p>
<p><strong>MenuItems</strong> can be either a MenuItemLink or a MenuItemButton:
<code>
<p>type MenuItemLink = {
label: string,
url: string
}
</p>
<p>type MenuItemButton = {
label: string,
onclick: () => {}
}
</p>
</code>
</p>
<div id='PageHeader'></div>
<p>In the code below you can see that you can have a mixture of buttons and links. When you pass in an onclick
initHeader will create a
button, however if you pass in a url it will create a link. Either way, as you can see, they appear the same in the
menu.
</p>
<script id="script-header">
window.addEventListener('DOMContentLoaded', async () => {
try {
options = { menuList: [{ label: "Testing Button", onclick: () => { alert('hello') } }, { label: "Testing Link", url: 'https://reflectechblog.wordpress.com/' }] }
await UI.initHeader(UI.store, options)
} catch (error) {
window.alert(`Error loading header. You need to have a div with id = PageHeader on your page.`)
}
});
</script>
<pre id="viewSource-header"></pre>
<script>showSource('header')</script>
<div id="div-header"></div>
</body>
</html>