-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
nav-bar-routes.vue
48 lines (44 loc) · 1.08 KB
/
nav-bar-routes.vue
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
<script>
// Allows stubbing BaseLink in unit tests
const BaseLink = 'BaseLink'
export default {
// Functional components are stateless, meaning they can't
// have data, computed properties, etc and they have no
// `this` context.
functional: true,
props: {
routes: {
type: Array,
required: true,
},
},
// Render functions are an alternative to templates
render(h, { props, $style = {} }) {
function getRouteTitle(route) {
return typeof route.title === 'function' ? route.title() : route.title
}
// Functional components are the only components allowed
// to return an array of children, rather than a single
// root node.
return props.routes.map((route) => (
<BaseLink
tag='li'
key={route.name}
to={route}
exact-active-class={$style.active}
>
<a>{getRouteTitle(route)}</a>
</BaseLink>
))
},
}
</script>
<style lang="scss" module>
@import '@design';
.active a {
font-weight: 600;
color: $color-link-text-active;
text-decoration: none;
cursor: default;
}
</style>