forked from riot/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app-navi.tag
66 lines (57 loc) · 1.25 KB
/
app-navi.tag
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
<app-navi>
<a each={ links } href="/{ url }" class={ selected: parent.selectedId === url }>
{ name }
</a>
<script>
var self = this
this.links = [
{ name: "H", url: "" },
{ name: "F", url: "first" },
{ name: "S", url: "second" }
]
var r = riot.route.create()
r(highlightCurrent)
var plunkrRandomUrl = location.pathname.replace(new RegExp('/', 'g'), '')
function highlightCurrent(id) {
// Plunker confuses routing initially
if ( plunkrRandomUrl == id ) { id = '' }
self.selectedId = id
self.update()
}
</script>
<style scoped>
:scope {
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;
}
:scope: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>