refactor: refactor nav bar component

pull/144/head
Kia King Ishii 4 years ago
parent 0993c7e80f
commit ed8ea3e5d5

@ -1,12 +0,0 @@
import { withBase } from '../utils'
import NavBarLinks from './NavBarLinks.vue'
export default {
components: {
NavBarLinks
},
setup() {
return { withBase }
}
}

@ -1,48 +1,40 @@
<template>
<a
class="title"
:aria-label="$site.title + ', back to home'"
:href="$site.base"
>
<img
class="logo"
v-if="$theme.logo"
:src="withBase($theme.logo)"
alt="logo"
/>
<span>{{ $site.title }}</span>
</a>
<div class="flex-grow"></div>
<NavBarLinks class="hide-mobile" />
<NavBarTitle />
<div class="flex-grow" />
<div class="nav">
<NavBarLinks />
</div>
<slot name="search" />
</template>
<script src="./NavBar"></script>
<script lang="ts">
import { defineComponent } from 'vue'
import NavBarTitle from './NavBarTitle.vue'
import NavBarLinks from './NavBarLinks.vue'
<style>
.title {
font-size: 1.3rem;
font-weight: 600;
color: var(--c-text);
}
.title:hover {
text-decoration: none;
}
export default defineComponent({
components: {
NavBarTitle,
NavBarLinks
}
})
</script>
<style scoped>
.flex-grow {
flex-grow: 1;
}
.logo {
margin-right: 0.75rem;
height: 1.3rem;
vertical-align: bottom;
.nav {
display: none;
}
@media screen and (max-width: 719px) {
.hide-mobile {
display: none !important;
@media (min-width: 720px) {
.nav {
display: block;
}
}
</style>

@ -0,0 +1,44 @@
<template>
<a
class="nav-bar-title"
:href="$site.base"
:aria-label="`${$site.title}, back to home`"
>
<img
v-if="$theme.logo"
class="logo"
:src="withBase($theme.logo)"
alt="Logo"
/>
{{ $site.title }}
</a>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { withBase } from '../utils'
export default defineComponent({
setup() {
return { withBase }
}
})
</script>
<style scoped>
.nav-bar-title {
font-size: 1.3rem;
font-weight: 600;
color: var(--c-text);
}
.nav-bar-title:hover {
text-decoration: none;
}
.logo {
margin-right: .75rem;
height: 1.3rem;
vertical-align: bottom;
}
</style>
Loading…
Cancel
Save