From cbb6b997e258037b944263628164beced2264a3d Mon Sep 17 00:00:00 2001 From: tymur999 Date: Tue, 17 Mar 2026 14:01:41 -0400 Subject: [PATCH] animations file --- src/about/about.sass | 7 ++----- src/animations.ts | 27 +++++++++++++++++++++++++++ src/articles/Reader.tsx | 27 ++++++++++----------------- src/articles/list.sass | 8 ++++++-- src/index/Canvas.tsx | 3 ++- src/nav/nav.sass | 7 ++++--- 6 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 src/animations.ts diff --git a/src/about/about.sass b/src/about/about.sass index 071022a..4e48e13 100644 --- a/src/about/about.sass +++ b/src/about/about.sass @@ -34,18 +34,15 @@ $min-width: 400px padding: nav.$padding max-width: $max-width font-size: $paragraph - - h1 - font-size: $paragraph * 2 + h1,h2,h3 padding: nav.$padding + font-size: $paragraph * 2 h2 font-size: $paragraph * 1.5 - padding: nav.$padding h3 font-size: $paragraph * 1.1 - font-weight: bold .edge background: #27213C diff --git a/src/animations.ts b/src/animations.ts new file mode 100644 index 0000000..f0ee338 --- /dev/null +++ b/src/animations.ts @@ -0,0 +1,27 @@ +import {Target} from "motion"; + +export type AnimateTemplate = { + initial: Target, + animate: Target, +}; + +export function AnimateDirection(dir: "top" | "left" | "right" | "bottom", top: string | number = 0) : AnimateTemplate { + const animation: Required = { animate: {}, initial: {} }; + animation.animate[dir] = top; + animation.initial[dir] = "-100%"; + + return animation; +} + +export function AnimateFade() : AnimateTemplate { + return { + initial: { opacity: 0 }, + animate: { opacity: 1 }, + }; +} + +export function AnimateSpin() : Pick { + return { + animate : { rotate: 360 }, + }; +} \ No newline at end of file diff --git a/src/articles/Reader.tsx b/src/articles/Reader.tsx index df8f02d..b99e6aa 100644 --- a/src/articles/Reader.tsx +++ b/src/articles/Reader.tsx @@ -1,18 +1,11 @@ import {useArticle} from "./ArticleContext"; import {motion} from "framer-motion"; import {useAnimate, animate as animateClass} from "motion/react"; -import {TargetAndTransition} from "motion"; import {useEffect} from "react"; +import {AnimateDirection, AnimateFade, AnimateTemplate} from "../animations"; -type Transition = "open" | "closed"; -const READER : Record = { - closed : { opacity: 0 }, - open : { opacity: 1 } -}; -const ARTICLE : Record = { - closed : { top: "-100%" }, - open : { top: "50%" } -}; +const READER : AnimateTemplate = AnimateFade(); +const ARTICLE : AnimateTemplate = AnimateDirection("top", "50%"); export function Reader() { @@ -21,8 +14,8 @@ export function Reader() { useEffect(() => { if(post && scope.current) { - animate(scope.current, READER.open); - animateClass(".read-box", ARTICLE.open); + animate(scope.current, READER.animate); + animateClass(".read-box", ARTICLE.animate!); } }, [post, scope]); @@ -37,8 +30,8 @@ export function Reader() { function handleClose() { Promise.all([ - animate(scope.current, READER.closed), - animateClass(".read-box", ARTICLE.closed) + animate(scope.current, READER.initial), + animateClass(".read-box", ARTICLE.initial!) ]).then(() => setPost(undefined)); } @@ -47,11 +40,11 @@ export function Reader() { - e.stopPropagation()}> + e.stopPropagation()}> diff --git a/src/articles/list.sass b/src/articles/list.sass index fe0ffcf..8a6825c 100644 --- a/src/articles/list.sass +++ b/src/articles/list.sass @@ -62,6 +62,7 @@ $entry-width: 400px left: 50% transform: translate(-50%, -50%) + overflow: scroll z-index: 9999 width: 100vw min-height: 100vh @@ -70,5 +71,8 @@ $entry-width: 400px margin-top: nav.$padding background: white color: black - width: 50vw - min-height: 75vh \ No newline at end of file + min-width: 50vw + max-width: 800px + min-height: 75vh + h1 + font-size: xxx-large \ No newline at end of file diff --git a/src/index/Canvas.tsx b/src/index/Canvas.tsx index bf04363..1604a3a 100644 --- a/src/index/Canvas.tsx +++ b/src/index/Canvas.tsx @@ -4,6 +4,7 @@ import {Canvas as ThreeCanvas, useFrame} from "@react-three/fiber"; import {Vector3} from "three"; import {Moon} from "./Moon"; import {Stars} from "./Stars"; +import {AnimateSpin} from "../animations"; export default function Canvas() { @@ -19,7 +20,7 @@ export default function Canvas() { - + Welcome to my blog diff --git a/src/nav/nav.sass b/src/nav/nav.sass index cc329c3..49b038e 100644 --- a/src/nav/nav.sass +++ b/src/nav/nav.sass @@ -27,8 +27,9 @@ nav justify-content: center .name - margin: auto - flex-grow: 1 + position: absolute + left: 50% + transform: translateX(-50%) h1 margin: auto 0 font-size: 40px @@ -37,7 +38,7 @@ nav .links flex-grow: 1 - justify-content: center + justify-content: flex-end align-items: center display: flex flex-wrap: wrap