Skip to content

Commit

Permalink
feat: site icon component
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Apr 16, 2024
1 parent 5448994 commit bbdc15a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/renderer/src/components/entry-column/article-item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dayjs from '@renderer/lib/dayjs'
import { SiteIcon } from '../site-icon'

export function ArticleItem({
entry,
Expand All @@ -7,10 +8,7 @@ export function ArticleItem({
}) {
return (
<div className='flex my-5 px-2 py-3'>
<img
src={`https://icons.duckduckgo.com/ip3/${new URL(entry.feed.site_url).host}.ico`}
className="w-5 h-5 mr-2 rounded-sm shrink-0"
/>
<SiteIcon url={entry.feed.site_url} />
<div className="line-clamp-5 text-sm flex-1 -mt-0.5 leading-tight">
<div className="text-zinc-500 text-[13px]">
{dayjs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dayjs from '@renderer/lib/dayjs'
import { SiteIcon } from '@renderer/components/site-icon'

export function SocialMediaItem({
entry,
Expand All @@ -7,10 +8,7 @@ export function SocialMediaItem({
}) {
return (
<div className='flex my-5 px-2 py-3'>
<img
src={`https://icons.duckduckgo.com/ip3/${new URL(entry.feed.site_url).host}.ico`}
className="w-5 h-5 mr-2 rounded-sm shrink-0"
/>
<SiteIcon url={entry.feed.site_url} />
<div>
<div className="line-clamp-5 text-sm flex-1 -mt-0.5">
<div className='space-x-1'>
Expand Down
6 changes: 2 additions & 4 deletions src/renderer/src/components/feed-column/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useState } from 'react'
import { levels } from '@renderer/lib/constants'
import { ActivedList } from '@renderer/lib/types'
import { cn } from '@renderer/lib/utils'
import { SiteIcon } from '../site-icon'

export function FeedList({
type,
Expand Down Expand Up @@ -120,10 +121,7 @@ function FeedCategory({
}}
>
<div className='flex items-center min-w-0'>
<img
src={`https://icons.duckduckgo.com/ip3/${new URL(feed.site_url).host}.ico`}
className="w-4 h-4 mr-2 rounded-sm"
/>
<SiteIcon url={feed.site_url} className="w-4 h-4" />
<div className='truncate'>{feed.title}</div>
</div>
{!!feed.unread && <div className='text-xs text-zinc-500 ml-2'>{feed.unread}</div>}
Expand Down
16 changes: 16 additions & 0 deletions src/renderer/src/components/site-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { cn } from "@renderer/lib/utils";

export function SiteIcon({
url,
className,
}: {
url: string,
className?: string,
}) {
return (
<img
src={`https://icons.duckduckgo.com/ip3/${new URL(url).host}.ico`}
className={cn("w-5 h-5 mr-2 rounded-sm shrink-0", className)}
/>
)
}

0 comments on commit bbdc15a

Please sign in to comment.