File tree Expand file tree Collapse file tree 2 files changed +64
-10
lines changed Expand file tree Collapse file tree 2 files changed +64
-10
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import shuffle from "lodash/shuffle"
3
3
4
4
import { Flex } from "@/components/ui/flex"
5
5
import InlineLink from "@/components/ui/Link"
6
+ import { LinkBox , LinkOverlay } from "@/components/ui/link-box"
6
7
7
8
import data from "!!raw-loader!@/../.all-contributorsrc"
8
9
@@ -32,8 +33,9 @@ const Contributors = () => {
32
33
33
34
< Flex className = "flex-wrap" >
34
35
{ contributorsList . map ( ( contributor ) => (
35
- < Flex
36
- className = "relative z-10 m-2 max-w-[132px] transform flex-col shadow-table transition-transform duration-100 hover:scale-[1.02] hover:rounded hover:bg-background-table-hover hover:no-underline hover:shadow-table-box-hover focus:scale-[1.02] focus:rounded focus:no-underline focus:shadow-table-box-hover"
36
+ < LinkBox
37
+ as = "div"
38
+ className = "m-2 max-w-[132px] transform shadow-table transition-transform duration-100 hover:scale-[1.02] hover:rounded hover:bg-background-table-hover hover:no-underline hover:shadow-table-box-hover focus:scale-[1.02] focus:rounded focus:no-underline focus:shadow-table-box-hover"
37
39
key = { contributor . login }
38
40
>
39
41
< img
@@ -43,16 +45,18 @@ const Contributors = () => {
43
45
/>
44
46
< div className = "p-4" >
45
47
< h3 className = "mb-4 mt-2 text-md" >
46
- < InlineLink
47
- className = "static flex-grow text-body no-underline before:absolute before:left-0 before:top-0 before:z-0 before:block before:h-full before:w-full before:cursor-pointer before:content-[''] hover:no-underline"
48
- href = { contributor . profile }
49
- hideArrow
50
- >
51
- { contributor . name }
52
- </ InlineLink >
48
+ < LinkOverlay asChild >
49
+ < InlineLink
50
+ className = "text-body no-underline hover:no-underline"
51
+ href = { contributor . profile }
52
+ hideArrow
53
+ >
54
+ { contributor . name }
55
+ </ InlineLink >
56
+ </ LinkOverlay >
53
57
</ h3 >
54
58
</ div >
55
- </ Flex >
59
+ </ LinkBox >
56
60
) ) }
57
61
</ Flex >
58
62
</ >
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"
7
+ import { Slot } from "@radix-ui/react-slot"
8
+
9
+ import { cn } from "@/lib/utils/cn"
10
+
11
+ type LinkBoxElement = ElementRef < "div" >
12
+
13
+ type LinkBoxProps = BaseHTMLAttributes < HTMLDivElement > & { as ?: ElementType }
14
+
15
+ const LinkBox = forwardRef < LinkBoxElement , LinkBoxProps > (
16
+ ( { as : Comp = "div" , className, ...props } , ref ) => {
17
+ return (
18
+ < Comp ref = { ref } className = { cn ( "relative z-10" , className ) } { ...props } />
19
+ )
20
+ }
21
+ )
22
+
23
+ LinkBox . displayName = "LinkBox"
24
+
25
+ type LinkOverlayElement = ElementRef < "a" >
26
+
27
+ type LinkOverlayProps = BaseHTMLAttributes < HTMLAnchorElement > & {
28
+ asChild ?: boolean
29
+ }
30
+
31
+ const LinkOverlay = forwardRef < LinkOverlayElement , LinkOverlayProps > (
32
+ ( { asChild, className, ...props } , ref ) => {
33
+ const Comp = asChild ? Slot : "a"
34
+
35
+ return (
36
+ < Comp
37
+ ref = { ref }
38
+ className = { cn (
39
+ "before:absolute before:left-0 before:top-0 before:z-0 before:block before:h-full before:w-full before:cursor-pointer before:content-['']" ,
40
+ className
41
+ ) }
42
+ { ...props }
43
+ />
44
+ )
45
+ }
46
+ )
47
+
48
+ LinkOverlay . displayName = "LinkOverlay"
49
+
50
+ export { LinkBox , LinkOverlay }
You can’t perform that action at this time.
0 commit comments