-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update KnowledgeBase Panel with Tags Component #55
- Loading branch information
1 parent
4717bda
commit e98e274
Showing
7 changed files
with
157 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
apps/mdreader/app/components/knowledge-group/knowledge-card.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { | ||
Separator, | ||
AvatarFallback, | ||
AvatarImage, | ||
Avatar, | ||
} from '@mdreader/interface'; | ||
import { Link } from '@remix-run/react'; | ||
import { Link as LinkIcon, Flag as FlagIcon } from 'lucide-react'; | ||
|
||
import BlurhashFallback from '../blurhash-fallback'; | ||
import { getInitials } from '~/utils'; | ||
import { Profile } from '~/types'; | ||
|
||
type KnowledgeCardProps = { | ||
blurhash?: string; | ||
description: string; | ||
image?: string; | ||
owner: Profile; | ||
tags: string[]; | ||
url: string; | ||
}; | ||
|
||
const KnowledgeCard: React.FC<KnowledgeCardProps> = ({ | ||
blurhash, | ||
description, | ||
image, | ||
owner, | ||
tags, | ||
url, | ||
}) => ( | ||
<div className="max-w-xs rounded overflow-hidden shadow-lg flex flex-col justify-between border p-4"> | ||
{image && ( | ||
<BlurhashFallback | ||
blurhash={blurhash} | ||
description={description} | ||
src={image} | ||
/> | ||
)} | ||
|
||
<div className="py-4"> | ||
<p className="dark:text-gray-300 text-gray-800 text-base mb-2"> | ||
{description} | ||
</p> | ||
|
||
<a | ||
className="text-sm text-blue-500" | ||
href={url} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
{url} | ||
</a> | ||
</div> | ||
|
||
{tags?.length && ( | ||
<div className="pt-4 pb-2"> | ||
{tags.map((tag, index) => ( | ||
<Link | ||
to={`?tag=${tag}`} | ||
className="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2" | ||
key={index} | ||
> | ||
#{tag} | ||
</Link> | ||
))} | ||
</div> | ||
)} | ||
|
||
<div> | ||
<Separator /> | ||
|
||
<div className="flex items-center gap-2 mt-2"> | ||
<Avatar> | ||
<AvatarFallback>{getInitials(owner.name)}</AvatarFallback> | ||
<AvatarImage src={owner.photo} /> | ||
</Avatar> | ||
|
||
<Link className="w-full" to={`/profile/${owner.login}`}> | ||
{owner.name} | ||
</Link> | ||
|
||
<div className="flex gap-2 cursor-pointer"> | ||
<LinkIcon size={16} /> | ||
<FlagIcon size={16} /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default KnowledgeCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.