Skip to content

Commit

Permalink
feat(ui): add glitch effect on header title
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 committed Jun 12, 2023
1 parent f5e988c commit c206c40
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/(blog)/components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React, { useEffect, useState } from 'react'
import Link from 'next/link'
import { useGlitch } from 'react-powerglitch'

import { ToggleTheme } from './toggle-theme'
import { Search } from './search'
Expand All @@ -11,6 +12,11 @@ export function Header() {
const [scrollPosition, setScrollPosition] = useState(0)
const [maxScrollValue, setMaxScrollValue] = useState(0)

const glitch = useGlitch({
timing: { duration: 5000, easing: 'ease-in' },
glitchTimeSpan: { start: 0.2, end: 0.8 }
})

function handleScroll() {
if (window) {
setScrollPosition(window.scrollY)
Expand Down Expand Up @@ -64,6 +70,7 @@ export function Header() {
<div className="blog-content-w m-auto flex flex-col flex-wrap items-center justify-between md:flex-row">
<Link href="/">
<h1
ref={glitch.ref}
className={`text-blue-700 dark:text-blue-500 ${
isNotOnTop ? 'font-medium' : 'font-base'
} font-chivo-mono hover:cursor-pointer`}
Expand Down

0 comments on commit c206c40

Please sign in to comment.