feat(bolg) add animation

This commit is contained in:
lumither committed 2024-06-06 19:13:25 +08:00
1 parent 56d673a9ec
commit c62fe7d1ef
6 files changed
+28 -14

No files matched your search

+2 -5
View File
@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Card, CardBody, CardFooter } from '@nextui-org/card'; import { Card, CardBody, CardFooter } from '@nextui-org/card';
import { Chip, Image } from '@nextui-org/react'; import { Chip } from '@nextui-org/react';
import NextImage from 'next/image'; import Image from 'next/image';
import Link from 'next/link'; import Link from 'next/link';
import { MdCalendarMonth, MdNorthEast } from 'react-icons/md'; import { MdCalendarMonth, MdNorthEast } from 'react-icons/md';
@@ -29,10 +29,8 @@ function BlogPostCard({ post }: Props) {
isHoverable isHoverable
> >
{ header_img !== '' && <div className={ `w-full overflow h-80 relative` }> { header_img !== '' && <div className={ `w-full overflow h-80 relative` }>
<Image <Image
as={ NextImage }
alt={ 'cover picture' } alt={ 'cover picture' }
src={ header_img } src={ header_img }
className={ `w-full object-cover rounded-b-none` } className={ `w-full object-cover rounded-b-none` }
@@ -41,7 +39,6 @@ function BlogPostCard({ post }: Props) {
'backdropFilter': 'blur(20px)' 'backdropFilter': 'blur(20px)'
} } } }
fill fill
removeWrapper
></Image> ></Image>
</div> } </div> }
+8 -1
View File
@@ -2,6 +2,7 @@ import React from 'react';
import fetch_posts_list from '@/app/blog/fetch_posts_list'; import fetch_posts_list from '@/app/blog/fetch_posts_list';
import BlogPostCard from '@/app/blog/BlogPostCard'; import BlogPostCard from '@/app/blog/BlogPostCard';
import { Card, CardBody } from '@nextui-org/card'; import { Card, CardBody } from '@nextui-org/card';
import { MotionDiv } from '@/app/public/MotionDiv';
async function Blog() { async function Blog() {
@@ -11,9 +12,15 @@ async function Blog() {
return ( return (
// blog list // blog list
<ul className={ 'flex flex-col items-center w-full space-y-7' }> <ul className={ 'flex flex-col items-center w-full space-y-7' }>
{ posts.map((post: JSON, key: React.Key | null | undefined) => ( { posts.map((post: JSON, key: number) => (
<li key={ key } className={ 'w-full' }> <li key={ key } className={ 'w-full' }>
<MotionDiv
initial={ { y: 20, opacity: 0 } }
animate={ { y: 0, opacity: 1 } }
transition={ { ease: 'easeInOut', duration: 0.5, delay: key * .2 + .25 } }
>
<BlogPostCard post={ post } /> <BlogPostCard post={ post } />
</MotionDiv>
</li>) </li>)
) } ) }
</ul> </ul>
+7
View File
@@ -1,12 +1,19 @@
import React from 'react'; import React from 'react';
import Generate from '@/app/blog/post/[id]/generate'; import Generate from '@/app/blog/post/[id]/generate';
import { MotionDiv } from '@/app/public/MotionDiv';
function BlogReader({ params }: { params: { id: string } }) { function BlogReader({ params }: { params: { id: string } }) {
return ( return (
<MotionDiv
initial={ { y: 20, opacity: 0 } }
animate={ { y: 0, opacity: 1 } }
transition={ { ease: 'easeInOut', duration: 0.5 } }
>
<div className={ `w-full` }> <div className={ `w-full` }>
<Generate id={ params.id } /> <Generate id={ params.id } />
</div> </div>
</MotionDiv>
); );
} }
+5
View File
@@ -0,0 +1,5 @@
'use client';
import { motion } from 'framer-motion';
export const MotionDiv = motion.div;
+4 -6
View File
@@ -1,7 +1,7 @@
'use client'; 'use client';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Button, Image } from '@nextui-org/react'; import { Button } from '@nextui-org/react';
import NextImage from 'next/image'; import NextImage from 'next/image';
import { import {
IoFileTrayFull, IoFileTrayFull,
@@ -115,16 +115,14 @@ function Navbar() {
<div className={ `fixed min-h-screen h-full` }> <div className={ `fixed min-h-screen h-full` }>
<div className={ `hidden md:block` }> <div className={ `hidden md:block` }>
<div className={ `flex justify-center items-center my-7` }> <div className={ `flex justify-center items-center my-7` }>
<Image <NextImage
as={ NextImage }
src={ 'https://oss.lumither.com/blog/pictures/compr/1717153492846703409_avatar.webp' } src={ 'https://oss.lumither.com/blog/pictures/compr/1717153492846703409_avatar.webp' }
alt={ 'avatar' } alt={ 'avatar' }
width={ 200 } width={ 200 }
height={ 200 } height={ 200 }
className={ 'rounded-full justify-self-center' } className={ 'rounded-full justify-self-center' }
fetchPriority={ 'high' } priority={ true }
removeWrapper ></NextImage>
></Image>
</div> </div>
<div> <div>
+2 -2
View File
@@ -11,9 +11,9 @@
"dependencies": { "dependencies": {
"@nextui-org/react": "^2.3.5", "@nextui-org/react": "^2.3.5",
"axios": "^1.6.8", "axios": "^1.6.8",
"framer-motion": "^11.1.7", "framer-motion": "^11.2.10",
"lxgw-wenkai-webfont": "^1.7.0", "lxgw-wenkai-webfont": "^1.7.0",
"next": "14.2.2", "next": "14.2.3",
"next-themes": "^0.3.0", "next-themes": "^0.3.0",
"react": "^18", "react": "^18",
"react-dom": "^18", "react-dom": "^18",