Skip to content

Commit

Permalink
refactor: optimized animate
Browse files Browse the repository at this point in the history
  • Loading branch information
valcosmos committed Oct 21, 2024
1 parent faf548b commit 367be83
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 28 deletions.
9 changes: 6 additions & 3 deletions app/blog/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Authors, Blog } from 'contentlayer/generated'
import type { Metadata } from 'next'

import { components } from '@/components/MDXComponents'
import Reveal from '@/components/Reveal'
import siteMetadata from '@/data/siteMetadata'
import PostBanner from '@/layouts/PostBanner'
import PostLayout from '@/layouts/PostLayout'
Expand Down Expand Up @@ -111,9 +112,11 @@ export default async function Page({ params }: { params: { slug: string[] } }) {
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
<Layout content={mainContent} authorDetails={authorDetails} next={next} prev={prev}>
<MDXLayoutRenderer code={post.body.code} components={components} toc={post.toc} />
</Layout>
<Reveal>
<Layout content={mainContent} authorDetails={authorDetails} next={next} prev={prev}>
<MDXLayoutRenderer code={post.body.code} components={components} toc={post.toc} />
</Layout>
</Reveal>
</>
)
}
2 changes: 1 addition & 1 deletion app/tags/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default async function Page() {
const sortedTags = tagKeys.sort((a, b) => tagCounts[b] - tagCounts[a])
return (
<Reveal>
<div className="flex flex-col items-start justify-start divide-y divide-gray-200 dark:divide-gray-700 md:mt-24 md:flex-row md:items-center md:justify-center md:space-x-6 md:divide-y-0">
<div className="flex flex-col items-start justify-start md:mt-24 md:flex-row md:items-center md:justify-center md:space-x-6 md:divide-y-0">
<div className="space-x-2 pb-8 pt-6 md:space-y-5">
<h1 className="text-3xl font-extrabold leading-9 tracking-tight text-gray-900 dark:text-gray-100 sm:text-4xl sm:leading-10 md:border-r-2 md:px-6 md:text-6xl md:leading-14">
标签
Expand Down
4 changes: 2 additions & 2 deletions components/Reveal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export default function Reveal({ children, width = '100%' }: RevealProps) {

<motion.div
variants={{
hidden: { opacity: 0, y: 75 },
hidden: { opacity: 0, y: 100 },
visible: { opacity: 1, y: 0 },
}}
initial="hidden"
animate={mainControls}
transition={{ duration: 0.5, delay: 0.25 }}
transition={{ duration: 0.8 }}
>
{children}
</motion.div>
Expand Down
2 changes: 1 addition & 1 deletion layouts/ListLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default function ListLayout({

return (
<>
<div className="divide-y divide-gray-200 dark:divide-gray-700">
<div>
<div className="space-y-2 pb-8 pt-6 md:space-y-5">
<h1 className="text-3xl font-extrabold leading-9 tracking-tight text-gray-900 dark:text-gray-100 sm:text-4xl sm:leading-10 md:text-6xl md:leading-14">
{title}
Expand Down
8 changes: 4 additions & 4 deletions layouts/PostLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function PostLayout({ content, authorDetails, next, prev, childre
return (
<SectionContainer>
<article>
<div className="xl:divide-y xl:divide-gray-200 xl:dark:divide-gray-700">
<div>
<header className="pt-6 xl:pb-6">
<div className="space-y-1 text-center">
<dl className="space-y-10">
Expand All @@ -54,8 +54,8 @@ export default function PostLayout({ content, authorDetails, next, prev, childre
</div>
</div>
</header>
<div className="grid-rows-[auto_1fr] divide-y divide-gray-200 pb-8 dark:divide-gray-700 xl:grid xl:grid-cols-4 xl:gap-x-6 xl:divide-y-0">
<dl className="pb-10 pt-6 xl:border-b xl:border-gray-200 xl:pt-11 xl:dark:border-gray-700">
<div className="grid-rows-[auto_1fr] pb-8 xl:grid xl:grid-cols-4 xl:gap-x-6">
<dl className="pb-10 pt-6 xl:pt-11">
<dt className="sr-only">Authors</dt>
<dd>
<ul className="flex flex-wrap justify-center gap-4 sm:space-x-12 xl:block xl:space-x-0 xl:space-y-8">
Expand Down Expand Up @@ -111,7 +111,7 @@ export default function PostLayout({ content, authorDetails, next, prev, childre
)}
</div>
<footer>
<div className="divide-gray-200 text-sm font-medium leading-5 dark:divide-gray-700 xl:col-start-1 xl:row-start-2 xl:divide-y">
<div className="text-sm font-medium leading-5 xl:col-start-1 xl:row-start-2">
{tags && (
<div className="py-4 xl:py-8">
<h2 className="text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400">
Expand Down
4 changes: 2 additions & 2 deletions layouts/PostSimple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export default function PostLayout({ content, next, prev, children }: LayoutProp
</div>
</div>
</header>
<div className="grid-rows-[auto_1fr] divide-y divide-gray-200 pb-8 dark:divide-gray-700 xl:divide-y-0">
<div className="divide-y divide-gray-200 dark:divide-gray-700 xl:col-span-3 xl:row-span-2 xl:pb-0">
<div className="grid-rows-[auto_1fr] pb-8">
<div className="xl:col-span-3 xl:row-span-2 xl:pb-0">
<div className="prose max-w-none pb-8 pt-10 dark:prose-invert">{children}</div>
</div>
{siteMetadata.comments && (
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@headlessui/react": "2.1.10",
"@next/bundle-analyzer": "14.2.15",
"@react-three/drei": "^9.114.5",
"@react-three/drei": "^9.114.6",
"@react-three/fiber": "^8.17.10",
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15",
Expand Down Expand Up @@ -64,7 +64,7 @@
"eslint-config-next": "14.2.15",
"eslint-plugin-format": "^0.1.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.12",
"eslint-plugin-react-refresh": "^0.4.13",
"eslint-plugin-tailwindcss": "^3.17.5",
"lint-staged": "^15.2.10",
"simple-git-hooks": "^2.11.1",
Expand Down
26 changes: 13 additions & 13 deletions pnpm-lock.yaml

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

0 comments on commit 367be83

Please sign in to comment.