animations file
All checks were successful
/ image_build (push) Successful in 1m50s

This commit is contained in:
tymur999
2026-03-17 14:01:41 -04:00
parent e61d3525a0
commit cbb6b997e2
6 changed files with 51 additions and 28 deletions

View File

@@ -34,18 +34,15 @@ $min-width: 400px
padding: nav.$padding padding: nav.$padding
max-width: $max-width max-width: $max-width
font-size: $paragraph font-size: $paragraph
h1,h2,h3
h1
font-size: $paragraph * 2
padding: nav.$padding padding: nav.$padding
font-size: $paragraph * 2
h2 h2
font-size: $paragraph * 1.5 font-size: $paragraph * 1.5
padding: nav.$padding
h3 h3
font-size: $paragraph * 1.1 font-size: $paragraph * 1.1
font-weight: bold
.edge .edge
background: #27213C background: #27213C

27
src/animations.ts Normal file
View File

@@ -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<AnimateTemplate> = { 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<AnimateTemplate, "animate"> {
return {
animate : { rotate: 360 },
};
}

View File

@@ -1,18 +1,11 @@
import {useArticle} from "./ArticleContext"; import {useArticle} from "./ArticleContext";
import {motion} from "framer-motion"; import {motion} from "framer-motion";
import {useAnimate, animate as animateClass} from "motion/react"; import {useAnimate, animate as animateClass} from "motion/react";
import {TargetAndTransition} from "motion";
import {useEffect} from "react"; import {useEffect} from "react";
import {AnimateDirection, AnimateFade, AnimateTemplate} from "../animations";
type Transition = "open" | "closed"; const READER : AnimateTemplate = AnimateFade();
const READER : Record<Transition, TargetAndTransition> = { const ARTICLE : AnimateTemplate = AnimateDirection("top", "50%");
closed : { opacity: 0 },
open : { opacity: 1 }
};
const ARTICLE : Record<Transition, TargetAndTransition> = {
closed : { top: "-100%" },
open : { top: "50%" }
};
export function Reader() { export function Reader() {
@@ -21,8 +14,8 @@ export function Reader() {
useEffect(() => { useEffect(() => {
if(post && scope.current) { if(post && scope.current) {
animate(scope.current, READER.open); animate(scope.current, READER.animate);
animateClass(".read-box", ARTICLE.open); animateClass(".read-box", ARTICLE.animate!);
} }
}, [post, scope]); }, [post, scope]);
@@ -37,8 +30,8 @@ export function Reader() {
function handleClose() { function handleClose() {
Promise.all([ Promise.all([
animate(scope.current, READER.closed), animate(scope.current, READER.initial),
animateClass(".read-box", ARTICLE.closed) animateClass(".read-box", ARTICLE.initial!)
]).then(() => setPost(undefined)); ]).then(() => setPost(undefined));
} }
@@ -47,11 +40,11 @@ export function Reader() {
<motion.article <motion.article
key="reader" key="reader"
ref={scope} ref={scope}
initial={READER.closed} initial={READER.initial}
animate={READER.open} animate={READER.animate}
onClick={handleClose} onClick={handleClose}
className="reader link"> className="reader link">
<motion.section className="read-box" initial={{top: "-100%"}} animate={{top: "50%"}} onClick={e => e.stopPropagation()}> <motion.section className="read-box" initial={{top: "-100%"}} animate={{top: "50%"}} onClick={e => e.stopPropagation()}>
<post.article/> <post.article/>
</motion.section> </motion.section>
</motion.article> </motion.article>

View File

@@ -62,6 +62,7 @@ $entry-width: 400px
left: 50% left: 50%
transform: translate(-50%, -50%) transform: translate(-50%, -50%)
overflow: scroll
z-index: 9999 z-index: 9999
width: 100vw width: 100vw
min-height: 100vh min-height: 100vh
@@ -70,5 +71,8 @@ $entry-width: 400px
margin-top: nav.$padding margin-top: nav.$padding
background: white background: white
color: black color: black
width: 50vw min-width: 50vw
max-width: 800px
min-height: 75vh min-height: 75vh
h1
font-size: xxx-large

View File

@@ -4,6 +4,7 @@ import {Canvas as ThreeCanvas, useFrame} from "@react-three/fiber";
import {Vector3} from "three"; import {Vector3} from "three";
import {Moon} from "./Moon"; import {Moon} from "./Moon";
import {Stars} from "./Stars"; import {Stars} from "./Stars";
import {AnimateSpin} from "../animations";
export default function Canvas() { export default function Canvas() {
@@ -19,7 +20,7 @@ export default function Canvas() {
<directionalLight color="#E3A857" args={[1,10]} position={[100,10,100]} /> <directionalLight color="#E3A857" args={[1,10]} position={[100,10,100]} />
</ThreeCanvas> </ThreeCanvas>
</section> </section>
<motion.h1 className="welcome" animate={{ rotate: 360 }}> <motion.h1 className="welcome" animate={AnimateSpin().animate}>
Welcome to my blog Welcome to my blog
</motion.h1> </motion.h1>
</main> </main>

View File

@@ -27,8 +27,9 @@ nav
justify-content: center justify-content: center
.name .name
margin: auto position: absolute
flex-grow: 1 left: 50%
transform: translateX(-50%)
h1 h1
margin: auto 0 margin: auto 0
font-size: 40px font-size: 40px
@@ -37,7 +38,7 @@ nav
.links .links
flex-grow: 1 flex-grow: 1
justify-content: center justify-content: flex-end
align-items: center align-items: center
display: flex display: flex
flex-wrap: wrap flex-wrap: wrap