Skip to content

Commit

Permalink
Impr header animation for blog website
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-mansi-d committed Oct 24, 2024
1 parent 89bc6ea commit 37f2c51
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 13 deletions.
24 changes: 24 additions & 0 deletions nuxt-frontend/assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,27 @@
font-weight: 600;
src: url(~/assets/fonts/Comme-SemiBold-Subset.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Helvetica-Light;
font-style: normal;
font-weight: 300;
src: url(~/assets/fonts/Helvetica-Light.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Helvetica-Regular;
font-style: normal;
font-weight: 400;
src: url(~/assets/fonts/Helvetica-Regular.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Helvetica-Bold;
font-style: normal;
font-weight: 700;
src: url(~/assets/fonts/Helvetica-Bold.woff2) format("woff2");
}
Binary file added nuxt-frontend/assets/fonts/Helvetica-Bold.woff2
Binary file not shown.
Binary file added nuxt-frontend/assets/fonts/Helvetica-Light.woff2
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion nuxt-frontend/components/Blog.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div :class="count == 0 || status == config.NOT_FOUND ? 'h-screen' : ''">
<Header />
<Header :animateOnScroll="false" />
<div
v-if="count == 0 || status == config.NOT_FOUND"
class="h-1/2 flex text-[1.4rem] text-black-900 items-center justify-center"
Expand Down
29 changes: 18 additions & 11 deletions nuxt-frontend/components/partials/NewHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@

<script type="module">
export default {
props: {
animateOnScroll: {
type: Boolean,
default: true, // Default to true if not provided
},
},
data() {
return {
id: this.$route.params.id,
Expand Down Expand Up @@ -309,27 +315,28 @@ export default {
},
mounted() {
this.navContainerHeight = this.$refs.mainHeader.clientHeight;
if (
this.currentRoutePath.includes("portfolio/") &&
window.innerWidth > 992 &&
!["/portfolio", "/portfolio/"].includes(this.currentRoutePath)
) {
this.podcastRef = document.getElementById("response");
this.podcastRef.style.marginTop = -this.navContainerHeight + "px";
this.podcastRef.addEventListener("scroll", this.handleScroll);
// Only add the scroll event listener if animation is enabled
if (this.animateOnScroll) {
window.addEventListener("scroll", this.handleScroll);
}
window.addEventListener("scroll", this.handleScroll);
this.width = window.innerWidth;
},
unmounted() {
if (this.podcastRef) {
if (this.animateOnScroll && this.podcastRef) {
this.podcastRef.removeEventListener("scroll", this.handleScroll);
}
window.removeEventListener("scroll", this.handleScroll);
},
inject: ["mixpanel"],
methods: {
handleScroll() {
// Only animate the navbar if the prop allows it
if (!this.animateOnScroll) {
this.showNavbar = true;
this.animateNavbar = true;
return;
}
let scrollY = this.podcastRef
? this.podcastRef.scrollTop
: window.scrollY;
Expand Down
2 changes: 1 addition & 1 deletion nuxt-frontend/pages/[slug].vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div v-if="!assets">
<Header />
<Header :animateOnScroll="false" />
<div :class="post.is_resource ? '' : 'container pl-0'">
<BlogDetail
:mixpanel="$mixpanel"
Expand Down
3 changes: 3 additions & 0 deletions nuxt-frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ module.exports = {
"comme-regular": ["Comme-Regular"],
"comme-medium": ["Comme-Medium"],
"comme-semibold": ["Comme-SemiBold"],
"helvetica-light": ["Helvetica-Light"],
"helvetica-regular": ["Helvetica-Regular"],
"helvetica-Bold": ["Helvetica-Bold"],
},
letterSpacing: {
"extra-wider": "0.0625em",
Expand Down

0 comments on commit 37f2c51

Please sign in to comment.