Skip to content

Instantly share code, notes, and snippets.

@VitorLuizC
Created January 31, 2018 19:50
Show Gist options
  • Select an option

  • Save VitorLuizC/f57a25a128dc4722848547734122ec6b to your computer and use it in GitHub Desktop.

Select an option

Save VitorLuizC/f57a25a128dc4722848547734122ec6b to your computer and use it in GitHub Desktop.
<template>
<nav class="c-navigation">
<component
v-for="(link, index) in links"
exact
active-class="-active"
exact-active-class="-active"
:is="link.route ? 'router-link' : 'a'"
:to="link.route"
:key="index"
:class="getClasses(link)"
>
{{ link.text }}
</component>
</nav>
</template>
<script>
export default {
props: {
links: {
type: Array,
default: () => []
}
},
methods: {
getClasses (link) {
const classes = [
'link',
...link.classes || [], {
'-active': link.active
}
]
return classes
}
}
}
</script>
<style lang="scss">
@import '~@style/reference.scss';
$border-color: red;
$border-color-hover: darken(red, 10%);
$border-color-active: darken(red, 20%);
$background-color: #fff;
.c-navigation {
& {
display: flex;
align-items: center;
background-color: $background-color;
}
& > .link {
display: block;
border-bottom: 2px solid $border-color;
transition: border-bottom-color .8s ease;
}
& > .link:hover { border-bottom-color: $border-color-hover; }
& > .link.-active,
& > .link:active { border-bottom-color: $border-color-active; }
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment