feat: entry content animation

This commit is contained in:
DIYgod
2024-04-29 17:34:38 +08:00
parent c601cf4e78
commit 3ab38d2bcc
2 changed files with 23 additions and 8 deletions
@@ -1,6 +1,7 @@
import { parseHtml } from "@renderer/lib/parse-html"
import { ActivedEntry } from "@renderer/lib/types"
import { useEffect, useState } from "react"
import { m } from "framer-motion"
export function EntryContent({ entry }: { entry: ActivedEntry }) {
const [content, setContent] = useState<JSX.Element>()
@@ -14,7 +15,13 @@ export function EntryContent({ entry }: { entry: ActivedEntry }) {
}, [entry?.content])
return (
<div className="px-4 py-5 overflow-y-auto h-full">
<m.div
className="px-4 py-5 overflow-y-auto h-full"
initial={{ opacity: 0.01, y: 50 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0.01, y: -50 }}
key={entry?.id}
>
<div>
<a
href={entry?.url}
@@ -33,6 +40,6 @@ export function EntryContent({ entry }: { entry: ActivedEntry }) {
{content}
</div>
</div>
</div>
</m.div>
)
}
+14 -6
View File
@@ -1,9 +1,10 @@
import { FeedColumn } from "@renderer/components/feed-column"
import { EntryColumn } from "@renderer/components/entry-column"
import { useState } from "react"
import { useEffect, useState } from "react"
import { ActivedList, ActivedEntry } from "@renderer/lib/types"
import { cn } from "@renderer/lib/utils"
import { EntryContent } from "@renderer/components/entry-content"
import { AnimatePresence } from "framer-motion"
const wideMode = [1, 2, 3, 4]
@@ -16,6 +17,10 @@ export function Component() {
})
const [activedEntry, setActivedEntry] = useState<ActivedEntry>(null)
useEffect(() => {
setActivedEntry(null)
}, [activedList])
return (
<div className="flex h-full">
<div className="w-64 pt-10 border-r shrink-0 bg-[#E1E0DF]">
@@ -35,11 +40,14 @@ export function Component() {
setActivedEntry={setActivedEntry}
/>
</div>
{!(activedList && wideMode.includes(activedList.view)) && (
<div className="flex-1 pt-10">
<EntryContent entry={activedEntry} />
</div>
)}
<AnimatePresence>
{!(activedList && wideMode.includes(activedList.view)) &&
activedEntry && (
<div className="flex-1 pt-10">
<EntryContent entry={activedEntry} />
</div>
)}
</AnimatePresence>
</div>
)
}