feat: feed summary component

This commit is contained in:
DIYgod
2024-05-09 21:05:21 +08:00
parent a2ad0fc183
commit e16ca31446
3 changed files with 44 additions and 75 deletions
@@ -0,0 +1,39 @@
import { FeedResponse } from "@renderer/lib/types"
import { SiteIcon } from "@renderer/components/site-icon"
import { Image } from "@renderer/components/ui/image"
export function FollowSummary({
feed,
docs,
}: {
feed: Partial<FeedResponse>
docs?: string
}) {
return (
<div className="select-text text-sm space-y-1">
<a href={feed.siteUrl} target="_blank" className="flex items-center">
{(() => {
if (feed.image) {
return <Image src={feed.image} className="w-8 h-8 mr-2" />
} else if (feed.siteUrl) {
return <SiteIcon url={feed.siteUrl} className="w-8 h-8" />
} else if (docs) {
return <SiteIcon url="https://rsshub.app" className="w-8 h-8" />
} else {
return null
}
})()}
<div className="leading-tight font-semibold text-base">
{feed.title}
<div className="font-normal truncate text-xs text-zinc-500">
{feed.description}
</div>
</div>
</a>
<div className="text-zinc-500 flex items-center gap-1">
<i className="i-mingcute-right-line" />
{feed.url || docs}
</div>
</div>
)
}
+3 -26
View File
@@ -20,8 +20,6 @@ import {
} from "@renderer/components/ui/dialog"
import { Button } from "@renderer/components/ui/button"
import { FeedResponse } from "@renderer/lib/types"
import { SiteIcon } from "@renderer/components/site-icon"
import { Image } from "@renderer/components/ui/image"
import {
Select,
SelectContent,
@@ -32,6 +30,7 @@ import {
import { views } from "@renderer/lib/constants"
import { cn } from "@renderer/lib/utils"
import { Switch } from "@renderer/components/ui/switch"
import { FollowSummary } from "../feed-summary"
const formSchema = z.object({
view: z.enum(["0", "1", "2", "3", "4", "5"]),
@@ -77,29 +76,7 @@ export function FollowDialog({ feed }: { feed: Partial<FeedResponse> }) {
<DialogHeader>
<DialogTitle>Follow</DialogTitle>
</DialogHeader>
<div className="text-sm">
<div className="flex items-center mb-1">
{(() => {
if (feed.image) {
return <Image src={feed.image} className="w-8 h-8 mr-2" />
} else if (feed.siteUrl) {
return <SiteIcon url={feed.siteUrl} className="w-8 h-8" />
} else {
return null
}
})()}
<div className="leading-tight font-semibold text-base">
{feed.title}
<div className="font-normal truncate text-xs text-zinc-500">
{feed.description}
</div>
</div>
</div>
<div className="text-zinc-500 flex items-center gap-1">
<i className="i-mingcute-right-line" />
{feed.url}
</div>
</div>
<FollowSummary feed={feed} />
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
<FormField
@@ -142,7 +119,7 @@ export function FollowDialog({ feed }: { feed: Partial<FeedResponse> }) {
<div>
<FormLabel>Category</FormLabel>
<FormDescription>
By default, follows will be grouped by website.
By default, your follows will be grouped by website.
</FormDescription>
</div>
<FormControl>
+2 -49
View File
@@ -14,18 +14,16 @@ import { Input } from "@renderer/components/ui/input"
import { useEffect } from "react"
import { useMutation } from "@tanstack/react-query"
import { getCsrfToken } from "@hono/auth-js/react"
import { SiteIcon } from "@renderer/components/site-icon"
import { Image } from "@renderer/components/ui/image"
import { FeedResponse, EntriesResponse } from "@renderer/lib/types"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@renderer/components/ui/card"
import { FollowButton } from "./button"
import { FollowSummary } from "../feed-summary"
const formSchema = z.object({
keyword: z.string().min(1),
@@ -141,52 +139,7 @@ export function FollowForm({ type }: { type: string }) {
{mutation.data?.map((item) => (
<Card key={item.feed.url || item.docs} className="select-text">
<CardHeader>
<CardTitle>
<a
href={item.feed.siteUrl}
target="_blank"
className="flex items-center"
>
{(() => {
if (item.feed.image) {
return (
<Image
src={item.feed.image}
className="w-8 h-8 mr-2"
/>
)
} else if (item.feed.siteUrl) {
return (
<SiteIcon
url={item.feed.siteUrl}
className="w-8 h-8"
/>
)
} else if (item.docs) {
return (
<SiteIcon
url="https://rsshub.app"
className="w-8 h-8"
/>
)
} else {
return null
}
})()}
<div className="leading-tight font-semibold text-base">
{item.feed.title}
<div className="font-normal truncate text-xs text-zinc-500">
{item.feed.description}
</div>
</div>
</a>
</CardTitle>
<CardDescription>
<div className="text-zinc-500 flex items-center gap-1">
<i className="i-mingcute-right-line" />
{item.feed.url || item.docs}
</div>
</CardDescription>
<FollowSummary feed={item.feed} docs={item.docs} />
</CardHeader>
{item.docs ? (
<CardFooter>