Skip to content

Commit 84f09eb

Browse files
build: initialize ShadCN Avatar
1 parent e2fa609 commit 84f09eb

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@hookform/resolvers": "^3.8.0",
3737
"@next/bundle-analyzer": "^14.2.5",
3838
"@radix-ui/react-accordion": "^1.2.0",
39+
"@radix-ui/react-avatar": "^1.1.2",
3940
"@radix-ui/react-checkbox": "^1.1.1",
4041
"@radix-ui/react-compose-refs": "^1.1.0",
4142
"@radix-ui/react-dialog": "^1.1.1",

src/components/ui/avatar.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import * as React from "react"
2+
import * as AvatarPrimitive from "@radix-ui/react-avatar"
3+
4+
import { cn } from "@/lib/utils"
5+
6+
const Avatar = React.forwardRef<
7+
React.ElementRef<typeof AvatarPrimitive.Root>,
8+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
9+
>(({ className, ...props }, ref) => (
10+
<AvatarPrimitive.Root
11+
ref={ref}
12+
className={cn(
13+
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
14+
className
15+
)}
16+
{...props}
17+
/>
18+
))
19+
Avatar.displayName = AvatarPrimitive.Root.displayName
20+
21+
const AvatarImage = React.forwardRef<
22+
React.ElementRef<typeof AvatarPrimitive.Image>,
23+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
24+
>(({ className, ...props }, ref) => (
25+
<AvatarPrimitive.Image
26+
ref={ref}
27+
className={cn("aspect-square h-full w-full", className)}
28+
{...props}
29+
/>
30+
))
31+
AvatarImage.displayName = AvatarPrimitive.Image.displayName
32+
33+
const AvatarFallback = React.forwardRef<
34+
React.ElementRef<typeof AvatarPrimitive.Fallback>,
35+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
36+
>(({ className, ...props }, ref) => (
37+
<AvatarPrimitive.Fallback
38+
ref={ref}
39+
className={cn(
40+
"bg-muted flex h-full w-full items-center justify-center rounded-full",
41+
className
42+
)}
43+
{...props}
44+
/>
45+
))
46+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
47+
48+
export { Avatar, AvatarFallback, AvatarImage }

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3811,6 +3811,16 @@
38113811
dependencies:
38123812
"@radix-ui/react-primitive" "2.0.0"
38133813

3814+
"@radix-ui/react-avatar@^1.1.2":
3815+
version "1.1.2"
3816+
resolved "https://registry.yarnpkg.com/@radix-ui/react-avatar/-/react-avatar-1.1.2.tgz#24af4c66bb5271460a4a6b74c4f4f9d4789d3d90"
3817+
integrity sha512-GaC7bXQZ5VgZvVvsJ5mu/AEbjYLnhhkoidOboC50Z6FFlLA03wG2ianUoH+zgDQ31/9gCF59bE4+2bBgTyMiig==
3818+
dependencies:
3819+
"@radix-ui/react-context" "1.1.1"
3820+
"@radix-ui/react-primitive" "2.0.1"
3821+
"@radix-ui/react-use-callback-ref" "1.1.0"
3822+
"@radix-ui/react-use-layout-effect" "1.1.0"
3823+
38143824
"@radix-ui/react-checkbox@^1.1.1":
38153825
version "1.1.1"
38163826
resolved "https://registry.yarnpkg.com/@radix-ui/react-checkbox/-/react-checkbox-1.1.1.tgz#a559c4303957d797acee99914480b755aa1f27d6"

0 commit comments

Comments
 (0)