File tree Expand file tree Collapse file tree 3 files changed +20
-28
lines changed Expand file tree Collapse file tree 3 files changed +20
-28
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ const Contributors = () => {
34
34
< Flex className = "flex-wrap" >
35
35
{ contributorsList . map ( ( contributor ) => (
36
36
< LinkBox
37
- as = "div"
38
37
className = "m-2 max-w-[132px] transform shadow transition-transform duration-100 hover:scale-[1.02] hover:rounded hover:bg-background-highlight focus:scale-[1.02] focus:rounded"
39
38
key = { contributor . login }
40
39
>
Original file line number Diff line number Diff line change @@ -151,25 +151,22 @@ const Avatar = React.forwardRef<
151
151
152
152
const _ref = ref as React . ForwardedRef < HTMLDivElement >
153
153
return (
154
- < LinkBox
155
- // !! Inconsistent strategy, using `as` prop instead of `asChild` bool
156
- as = { Center }
157
- ref = { _ref }
158
- className = { cn ( _direction , "gap-x-1 gap-y-0" ) }
159
- >
160
- < LinkOverlay
161
- asChild
162
- className = { cn (
163
- "peer z-overlay inline-flex items-center gap-1 p-1" ,
164
- size !== "md" ? "text-xs" : "text-sm"
165
- ) }
166
- >
167
- < BaseLink { ...commonLinkProps } > { label } </ BaseLink >
168
- </ LinkOverlay >
169
- < AvatarBase size = { size } >
170
- < AvatarImage src = { src } />
171
- < AvatarFallback > { fallbackInitials } </ AvatarFallback >
172
- </ AvatarBase >
154
+ < LinkBox ref = { _ref } className = { cn ( _direction , "gap-x-1 gap-y-0" ) } asChild >
155
+ < Center >
156
+ < LinkOverlay
157
+ asChild
158
+ className = { cn (
159
+ "peer z-overlay inline-flex items-center gap-1 p-1" ,
160
+ size !== "md" ? "text-xs" : "text-sm"
161
+ ) }
162
+ >
163
+ < BaseLink { ...commonLinkProps } > { label } </ BaseLink >
164
+ </ LinkOverlay >
165
+ < AvatarBase size = { size } >
166
+ < AvatarImage src = { src } />
167
+ < AvatarFallback > { fallbackInitials } </ AvatarFallback >
168
+ </ AvatarBase >
169
+ </ Center >
173
170
</ LinkBox >
174
171
)
175
172
}
Original file line number Diff line number Diff line change 1
- import {
2
- type BaseHTMLAttributes ,
3
- type ElementRef ,
4
- type ElementType ,
5
- forwardRef ,
6
- } from "react"
1
+ import { type BaseHTMLAttributes , type ElementRef , forwardRef } from "react"
7
2
import { Slot } from "@radix-ui/react-slot"
8
3
9
4
import { cn } from "@/lib/utils/cn"
10
5
11
6
type LinkBoxElement = ElementRef < "div" >
12
7
13
- type LinkBoxProps = BaseHTMLAttributes < HTMLDivElement > & { as ?: ElementType }
8
+ type LinkBoxProps = BaseHTMLAttributes < HTMLDivElement > & { asChild ?: boolean }
14
9
15
10
const LinkBox = forwardRef < LinkBoxElement , LinkBoxProps > (
16
- ( { as : Comp = "div" , className, ...props } , ref ) => {
11
+ ( { asChild, className, ...props } , ref ) => {
12
+ const Comp = asChild ? Slot : "div"
17
13
return (
18
14
< Comp ref = { ref } className = { cn ( "relative z-10" , className ) } { ...props } />
19
15
)
You can’t perform that action at this time.
0 commit comments