Skip to content

Commit

Permalink
add gsap for animations, improve fade out transition
Browse files Browse the repository at this point in the history
  • Loading branch information
ashharrison90 committed Nov 18, 2023
1 parent e6f1768 commit f6b34ba
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
4 changes: 3 additions & 1 deletion components/Layout/Layout.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
height: 100%;
transform-origin: bottom right;
transform: translateZ(0);
transition: background-color 0.5s linear;
transition:
backdrop-filter 200ms linear,
background-color 200ms linear;
width: 100%;
}

Expand Down
7 changes: 6 additions & 1 deletion components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ export default function Layout({
[styles.blur]: blurBackground,
})}
style={{
backgroundColor: `rgba(var(--hero-background-rgb), ${backgroundContentFade})`,
backgroundColor: `rgba(var(--hero-background-rgb), ${
Math.max(0, backgroundContentFade - 0.2) * 0.5
})`,
backdropFilter: `blur(${
Math.max(0, backgroundContentFade - 0.2) * 20
}px)`,
}}
>
<div
Expand Down
4 changes: 2 additions & 2 deletions components/PostLayout/PostLayout.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}

:global(.hljs) {
@media screen and (min-width: 768px) {
@media screen and (width >= 768px) {
margin: 1em;
}
}
Expand Down Expand Up @@ -75,5 +75,5 @@

.padder {
box-shadow: inset 0 0 60px 0 black;
height: 50vh;
height: 100%;
}
8 changes: 8 additions & 0 deletions components/PostLayout/PostLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { gsap } from 'gsap'
import hljs from 'highlight.js/lib/core'
import bash from 'highlight.js/lib/languages/bash'
import javascript from 'highlight.js/lib/languages/javascript'
Expand All @@ -10,6 +11,7 @@ import { ReactNode, useContext, useEffect, useRef } from 'react'
import { ThemeContext } from '../../context/ThemeContext/ThemeContext'
import { PostMetadata } from '../../lib/postsApi'
import Layout from '../Layout/Layout'
import layoutStyles from '../Layout/Layout.module.scss'
import PostTitle from '../PostTitle/PostTitle'

import styles from './PostLayout.module.scss'
Expand All @@ -31,6 +33,12 @@ export default function PostLayout({ children, metadata }: Props) {

useEffect(() => {
hljs.highlightAll()
gsap.from(`.${layoutStyles.foregroundContentRef}`, {
duration: 0.5,
minHeight: '100%',
ease: 'back',
delay: 0.1,
})
}, [])

useEffect(() => {
Expand Down
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-storybook": "^0.6.11",
"gsap": "^3.12.2",
"highlight.js": "^11.6.0",
"husky": "^8.0.1",
"identity-obj-proxy": "^3.0.0",
Expand Down

0 comments on commit f6b34ba

Please sign in to comment.