-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added avatar and article info to the article page
- Loading branch information
1 parent
e44785e
commit 1e4a814
Showing
9 changed files
with
113 additions
and
4 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Image from 'next/image'; | ||
|
||
import { Avatar, AvatarFallback } from '@/components/ui/Avatar'; | ||
|
||
type AvatarIconProps = { | ||
className?: string; | ||
photoUrl: string; | ||
name: string; | ||
initials: string; | ||
}; | ||
|
||
function AvatarIcon({ className, photoUrl, name, initials }: AvatarIconProps) { | ||
return ( | ||
<Avatar className={className}> | ||
{photoUrl && ( | ||
<Image | ||
className='aspect-square h-full w-full' | ||
src={photoUrl} | ||
alt={name} | ||
sizes='(max-width: 768px) 100%, 100%' | ||
fill | ||
/> | ||
)} | ||
{!photoUrl && <AvatarFallback>{initials}</AvatarFallback>} | ||
</Avatar> | ||
); | ||
} | ||
|
||
export { AvatarIcon }; |
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,38 @@ | ||
'use client'; | ||
|
||
import * as AvatarPrimitive from '@radix-ui/react-avatar'; | ||
import * as React from 'react'; | ||
|
||
import { cx } from '@/lib/utils'; | ||
|
||
const Avatar = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Root | ||
ref={ref} | ||
className={cx( | ||
'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
Avatar.displayName = AvatarPrimitive.Root.displayName; | ||
|
||
const AvatarFallback = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Fallback>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Fallback | ||
ref={ref} | ||
className={cx( | ||
'flex h-full w-full items-center justify-center rounded-full bg-muted', | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; | ||
|
||
export { Avatar, AvatarFallback }; |
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