Skip to content

Commit

Permalink
chore: some more animations
Browse files Browse the repository at this point in the history
  • Loading branch information
KrustyC committed Feb 5, 2024
1 parent ee76861 commit f54e79f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 221 deletions.
181 changes: 0 additions & 181 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@contentful/rich-text-react-renderer": "^15.19.4",
"@next/third-parties": "^14.1.0",
"@prisma/client": "^5.9.1",
"@react-spring/web": "^9.7.3",
"@vercel/analytics": "^1.1.2",
"@vercel/speed-insights": "^1.0.9",
"classnames": "^2.5.1",
Expand Down
35 changes: 29 additions & 6 deletions src/components/Project/Block/GridBlock/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"use client";

import classnames from "classnames";
import { motion, Variants } from "framer-motion";
import Image from "next/image";

import { GridBlock as IGridBlock, GridBlockSpacing } from "@/types/global";
Expand All @@ -7,9 +10,25 @@ interface FullScreenBlockProps {
block: IGridBlock;
}

const variants: Variants = {
offscreen: {
y: 100,
opacity: 0,
},
onscreen: {
y: 0,
opacity: 1,
transition: {
type: "tween",
bounce: 0.2,
duration: 0.4,
},
},
};

export const GridBlock: React.FC<FullScreenBlockProps> = ({ block }) => (
<div
className={classnames("flex flex-col px-4 lg:px-24 mb-24", {
className={classnames("flex flex-col items-center px-4 py-24", {
"gap-y-0.5": block.spacing === GridBlockSpacing.EXTRA_SMALL,
"gap-y-1": block.spacing === GridBlockSpacing.SMALL,
"gap-y-2": block.spacing === GridBlockSpacing.MEDIUM,
Expand All @@ -19,9 +38,13 @@ export const GridBlock: React.FC<FullScreenBlockProps> = ({ block }) => (
})}
>
{block.gridImages.map((gridImage, index) => (
<div
<motion.div
key={index}
className={classnames("flex flex-col lg:flex-row", {
initial="offscreen"
whileInView="onscreen"
viewport={{ once: true, amount: 0.5 }}
transition={{ staggerChildren: 0.3 }}
className={classnames("flex flex-col lg:flex-row justify-around", {
"gap-0.5": block.spacing === GridBlockSpacing.EXTRA_SMALL,
"gap-1": block.spacing === GridBlockSpacing.SMALL,
"gap-2": block.spacing === GridBlockSpacing.MEDIUM,
Expand All @@ -31,7 +54,7 @@ export const GridBlock: React.FC<FullScreenBlockProps> = ({ block }) => (
})}
>
{gridImage.images.map((image, index) => (
<div key={index} className="relative w-full flex-1">
<motion.div key={index} className="relative" variants={variants}>
<Image
alt={image.description || ""}
src={image.url || ""}
Expand All @@ -42,9 +65,9 @@ export const GridBlock: React.FC<FullScreenBlockProps> = ({ block }) => (
objectFit: "cover",
}}
/>
</div>
</motion.div>
))}
</div>
</motion.div>
))}
</div>
);
2 changes: 1 addition & 1 deletion src/components/Project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Project: React.FC<ProjectProps> = ({ project }) => {
return (
<div>
<div className="px-6 md:px-16 lg:px-24">
<div className="relative w-full aspect-square md:aspect-video rounded-xl bg-slate-300">
<div className="relative w-full aspect-square md:aspect-video rounded-3xl bg-slate-300">
<Image
fill
className="z-1 rounded-3xl"
Expand Down
32 changes: 0 additions & 32 deletions src/components/animations/SlideFromLeftOnMount.tsx

This file was deleted.

0 comments on commit f54e79f

Please sign in to comment.