Fixed navbar

This commit is contained in:
Damillora 2019-11-13 18:50:52 +07:00
parent 98a2e9fe13
commit 8f2affea9d
9 changed files with 14 additions and 16 deletions

View File

@ -7,10 +7,13 @@
html { html {
@apply font-sans; @apply font-sans;
} }
/* 2. Site Header */
header { header {
@apply py-4 px-4 bg-yuika-blue-700; @apply py-4 px-4;
}
/* 2. Site Header */
.index-navbar {
z-index: 10;
@apply transition-bg;
} }
.index-navbar header { .index-navbar header {
background-color: transparent; background-color: transparent;
@ -161,7 +164,6 @@ footer {
} }
.nav-fixed { .nav-fixed {
z-index: 10;
@apply bg-yuika-blue-700; @apply bg-yuika-blue-700;
} }

View File

@ -31,14 +31,10 @@
var progressMax = lastDocumentHeight - lastWindowHeight; var progressMax = lastDocumentHeight - lastWindowHeight;
// show/hide nav // show/hide nav
if (lastScrollY >= trigger - 20) { if (lastScrollY >= nav.getBoundingClientRect().bottom) {
nav.classList.add('fixed');
nav.classList.add('nav-fixed'); nav.classList.add('nav-fixed');
nav.classList.remove('absolute');
} else { } else {
nav.classList.remove('fixed');
nav.classList.remove('nav-fixed'); nav.classList.remove('nav-fixed');
nav.classList.add('absolute');
} }
ticking = false; ticking = false;

View File

@ -1,5 +1,6 @@
{{!< default}} {{!< default}}
{{#author}} {{#author}}
{{> "site-header"}}
<div class="relative group index-header"> <div class="relative group index-header">
{{> header-background background=cover_image}} {{!--Special header-image.hbs partial to generate the background image--}} {{> header-background background=cover_image}} {{!--Special header-image.hbs partial to generate the background image--}}
<div class="h-full opacity-50 bg-black group-hover:opacity-75 transition-opacity"> <div class="h-full opacity-50 bg-black group-hover:opacity-75 transition-opacity">
@ -45,7 +46,6 @@
</div> </div>
</div> </div>
</div> </div>
{{> "site-header"}}
</div> </div>
{{/author}} {{/author}}

View File

@ -1,10 +1,10 @@
{{!< default}} {{!< default}}
{{> "site-header"}}
<div class="h-64 relative group index-header"> <div class="h-64 relative group index-header">
{{> header-background background=@site.cover_image}} {{!--Special header-image.hbs partial to generate the background image--}} {{> header-background background=@site.cover_image}} {{!--Special header-image.hbs partial to generate the background image--}}
<div class="w-full h-full opacity-50 bg-black group-hover:opacity-75 transition-opacity"> <div class="w-full h-full opacity-50 bg-black group-hover:opacity-75 transition-opacity">
</div> </div>
</div> </div>
{{> "site-header"}}
</div> </div>
<div class="flex flex-wrap justify-start post-feed content w-full px-4"> <div class="flex flex-wrap justify-start post-feed content w-full px-4">
{{#foreach posts}} {{#foreach posts}}

View File

@ -1,7 +1,7 @@
{ {
"name": "yuika", "name": "yuika",
"description": "nanao.moe's blog theme", "description": "nanao.moe's blog theme",
"version": "0.5.0", "version": "0.6.0",
"engines": { "engines": {
"ghost-api": "v3" "ghost-api": "v3"
}, },

View File

@ -1,6 +1,7 @@
{{!< default}} {{!< default}}
{{#post}} {{#post}}
{{> "site-header"}}
<div class="relative group index-header"> <div class="relative group index-header">
{{> header-background background=feature_image}} {{!--Special header-image.hbs partial to generate the background image--}} {{> header-background background=feature_image}} {{!--Special header-image.hbs partial to generate the background image--}}
<div class="h-full opacity-50 bg-black group-hover:opacity-75 transition-opacity"> <div class="h-full opacity-50 bg-black group-hover:opacity-75 transition-opacity">
@ -13,7 +14,6 @@
</div> </div>
</div> </div>
</div> </div>
{{> "site-header"}}
</div> </div>
<article class="post-article"> <article class="post-article">

View File

@ -1,4 +1,4 @@
<div class="w-full flex flex-row justify-begin items-center absolute top-0 index-navbar"> <div class="w-full flex flex-row justify-begin items-center fixed index-navbar">
<header class="flex flex-row py-2 flex-wrap w-full"> <header class="flex flex-row py-2 flex-wrap w-full">
{{#if @site.logo}} {{#if @site.logo}}
<div class="w-12 h-12"> <div class="w-12 h-12">

View File

@ -1,6 +1,7 @@
{{!< default}} {{!< default}}
{{#post}} {{#post}}
{{> "site-header"}}
<div class="relative group index-header"> <div class="relative group index-header">
{{> header-background background=feature_image}} {{!--Special header-image.hbs partial to generate the background image--}} {{> header-background background=feature_image}} {{!--Special header-image.hbs partial to generate the background image--}}
<div class="h-full opacity-50 bg-black group-hover:opacity-75 transition-opacity"> <div class="h-full opacity-50 bg-black group-hover:opacity-75 transition-opacity">
@ -39,7 +40,6 @@
</div> </div>
</div> </div>
</div> </div>
{{> "site-header"}}
</div> </div>
<article class="post-article"> <article class="post-article">

View File

@ -1,6 +1,7 @@
{{!< default}} {{!< default}}
{{#tag}} {{#tag}}
{{> "site-header"}}
<div class="relative group index-header"> <div class="relative group index-header">
{{> header-background background=feature_image}} {{!--Special header-image.hbs partial to generate the background image--}} {{> header-background background=feature_image}} {{!--Special header-image.hbs partial to generate the background image--}}
<div class="h-full opacity-50 bg-black group-hover:opacity-75 transition-opacity"> <div class="h-full opacity-50 bg-black group-hover:opacity-75 transition-opacity">
@ -23,7 +24,6 @@
</div> </div>
</div> </div>
</div> </div>
{{> "site-header"}}
</div> </div>
{{/tag}} {{/tag}}