-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathapp-navi.riot
67 lines (62 loc) · 1.27 KB
/
app-navi.riot
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
<app-navi>
<route path="(.*)">
<a each={ link in state.links }
href="{ link.url }"
class={ isLinkSelected(link, route) ? 'selected' : '' }>
{ link.name }
</a>
</route>
<script>
export default {
state: {
links: [
{ name: "H", url: "#" },
{ name: "F", url: "#/first" },
{ name: "S", url: "#/second" }
]
},
isLinkSelected(link, route) {
const isHome = !route.hash || route.hash === '#'
if (link.url === '#') {
return isHome
}
return !isHome && route.hash.includes(link.url)
}
}
</script>
<style>
:host {
position: fixed;
top: 0;
left: 0;
height: 100%;
box-sizing: border-box;
font-family: sans-serif;
text-align: center;
color: #666;
background: #333;
width: 50px;
transition: width .2s;
}
:host:hover {
width: 60px;
}
a {
display: block;
box-sizing: border-box;
width: 100%;
height: 50px;
line-height: 50px;
padding: 0 .8em;
color: white;
text-decoration: none;
background: #444;
}
a:hover {
background: #666;
}
a.selected {
background: teal;
}
</style>
</app-navi>