miracle/components/Header.vue

192 lines
4.6 KiB
Vue
Raw Normal View History

<template>
2020-12-26 09:50:33 +00:00
<div>
2020-12-26 10:06:05 +00:00
<div :class="{ 'site-header': true, 'enabled': menu_shown, 'detached': detached }">
2020-12-26 09:50:33 +00:00
<div :class="{ 'site-background': true, 'enabled': menu_shown }"></div>
2020-06-23 21:37:09 +00:00
<div class="site-header-inner">
<header>
2020-11-10 19:16:35 +00:00
<div class="header-top">
<a @click="menu_shown = !menu_shown" id="menushow">
2020-11-11 11:06:04 +00:00
<span class="h-12 w-12 px-2 py-3 text-white material-icons" alt="menu">menu</span>
2020-11-10 19:16:35 +00:00
</a>
2020-12-26 09:50:33 +00:00
<div class="header-title" @click="menu_shown = menu_shown ? !menu_shown : menu_shown" >
2020-11-10 19:16:35 +00:00
<nuxt-link to="/"><h1 class="text-lg text-white">Damillora</h1></nuxt-link>
2020-06-23 21:37:09 +00:00
</div>
2020-11-10 19:16:35 +00:00
</div>
<div class="header-menu">
2020-12-26 09:50:33 +00:00
<div :class="{ 'nav-menu': true, 'enabled': menu_shown }">
2020-11-09 10:46:10 +00:00
<NavItem
link="/about"
icon="person"
text="About"
2020-11-10 19:16:35 +00:00
@click="menu_shown = !menu_shown"
2020-11-09 10:46:10 +00:00
/>
<NavItem
link="/projects"
icon="work"
text="Projects"
2020-11-10 19:16:35 +00:00
@click="menu_shown = !menu_shown"
2020-11-09 10:46:10 +00:00
/>
<NavItem
link="/games"
icon="videogame_asset"
text="Game Profile"
2020-11-10 19:16:35 +00:00
@click="menu_shown = !menu_shown"
2020-11-09 10:46:10 +00:00
/>
<NavItem
link="/links"
icon="share"
2020-11-09 10:46:10 +00:00
text="Links"
2020-11-10 19:16:35 +00:00
@click="menu_shown = !menu_shown"
2020-11-09 10:46:10 +00:00
/>
<NavItem
link="/contact"
icon="contacts"
text="Contact"
@click="menu_shown = !menu_shown"
/>
2020-11-09 10:46:10 +00:00
<NavItem
link="//blog.nanao.moe"
icon="rss_feed"
text="Blog"
external="true"
2020-11-10 19:16:35 +00:00
@click="menu_shown = !menu_shown"
2020-11-09 10:46:10 +00:00
/>
2020-06-23 21:37:09 +00:00
</div>
</div>
</header>
</div>
</div>
</div>
</template>
<script>
2020-06-23 21:37:09 +00:00
import NavItem from './NavItem';
export default {
2020-06-23 21:37:09 +00:00
components: {
NavItem
},
2020-11-10 19:16:35 +00:00
data() {
return {
menu_shown: false,
2020-12-26 10:06:05 +00:00
scrollY: 0,
originTop: 0,
detached: false,
2020-11-10 19:16:35 +00:00
};
2020-02-01 20:26:13 +00:00
},
2020-12-26 10:06:05 +00:00
mounted() {
window.addEventListener('scroll', (e) => {
this.scrollY = Math.round(window.scrollY);
})
this.originTop = this.$el.getBoundingClientRect().top;
},
watch: {
scrollY(newValue) {
const rect = this.$el.getBoundingClientRect();
const newTop = this.scrollY;
this.detached = newTop > 64;
}
},
}
</script>
<style>
2020-06-23 21:37:09 +00:00
.site-header {
2021-01-13 14:34:10 +00:00
z-index: 10;
2020-11-10 19:16:35 +00:00
height: 4rem;
width: 100vw;
overflow: hidden;
@apply fixed transition-all duration-300 ease-in-out;
}
.site-background {
z-index: -1;
width: 100vw;
height: 100vh;
position: absolute;
background-image: url('~assets/images/bg/283-yuika/bg-sm.jpg');
2020-06-23 21:37:09 +00:00
background-size: cover;
2020-11-10 19:16:35 +00:00
background-position: right 25% top 20%;
@apply transition-all duration-300 ease-in-out;
}
.site-background {
2020-12-26 09:50:33 +00:00
opacity: 0%;
2020-11-10 19:16:35 +00:00
top: -23vh;
}
.site-background.enabled {
2020-12-26 09:50:33 +00:00
opacity: 100%;
2020-11-10 19:16:35 +00:00
top: 0;
}
.site-header.enabled {
height: 100vh;
width: 100vw;
2020-06-23 21:37:09 +00:00
}
@screen sm {
2020-11-10 19:16:35 +00:00
.site-background {
background-image: url('~assets/images/bg/283-yuika/bg-md.jpg');
2020-06-23 21:37:09 +00:00
}
}
@screen md {
2020-11-10 19:16:35 +00:00
.site-background {
background-image: url('~assets/images/bg/283-yuika/bg-lg.jpg');
2020-06-23 21:37:09 +00:00
}
}
@screen lg {
2020-11-10 19:16:35 +00:00
.site-background {
background-image: url('~assets/images/bg/283-yuika/bg-xl.jpg');
2020-06-23 21:37:09 +00:00
}
}
@screen xl {
2020-11-10 19:16:35 +00:00
.site-background {
background-image: url('~assets/images/bg/283-yuika/bg-xxl.jpg');
2020-06-23 21:37:09 +00:00
}
}
.site-header-inner {
2020-11-10 19:16:35 +00:00
z-index: 1;
2020-12-26 09:50:33 +00:00
@apply w-full h-full transition duration-300 ease-in-out;
}
.site-header.enabled .site-header-inner {
background: rgba(0,0,0,0.5);
2020-06-23 21:37:09 +00:00
}
2020-12-26 10:06:05 +00:00
.site-header.detached .site-header-inner {
background: rgba(0,0,0,0.5);
}
header {
2020-11-10 19:16:35 +00:00
@apply flex flex-col transition duration-300 ease-in-out;
2020-06-23 21:37:09 +00:00
}
2020-11-10 19:16:35 +00:00
.header-top {
@apply flex flex-row;
2020-06-23 21:37:09 +00:00
}
.header-title {
@apply flex-grow transition duration-300 ease-in-out;
}
.header-title a {
2020-11-10 19:16:35 +00:00
@apply flex flex-row items-center py-4 pl-4 w-full h-full;
2020-06-23 21:37:09 +00:00
}
.header-title:hover {
@apply bg-yuika-blue-500;
}
2020-11-10 19:16:35 +00:00
#menushow {
2021-01-08 20:18:16 +00:00
@apply w-16 h-16 cursor-pointer relative p-2 text-center whitespace-nowrap transition duration-300 ease-in-out;
}
2020-11-10 19:16:35 +00:00
#menushow:hover {
2020-06-23 21:37:09 +00:00
@apply bg-yuika-blue-500;
}
2020-11-10 19:16:35 +00:00
.header-menu .nav-menu {
max-height: 0px;
@apply block transition-all duration-300 ease-in-out overflow-hidden;
}
2020-11-10 19:16:35 +00:00
.header-menu .nav-menu.enabled {
max-height: 100vh;
}
2020-06-23 21:37:09 +00:00
@screen md {
2020-11-10 19:16:35 +00:00
.header-menu .nav-menu {
max-height: 100vh;
2020-11-11 11:06:04 +00:00
margin-left: 4rem;
2020-11-10 19:16:35 +00:00
max-width: 0px;
2020-06-23 21:37:09 +00:00
}
2020-11-10 19:16:35 +00:00
.header-menu .nav-menu.enabled {
max-width: 100vw;
2020-06-23 21:37:09 +00:00
}
}
</style>