Skip to content

Commit 27d9269

Browse files
authored
Merge pull request #13989 from Baystef/migrate/contributors
Migrate Contributors component to shadcn
2 parents 2e0e0ed + 4534a7d commit 27d9269

File tree

2 files changed

+70
-41
lines changed

2 files changed

+70
-41
lines changed

src/components/Contributors.tsx

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useEffect, useState } from "react"
22
import shuffle from "lodash/shuffle"
3-
import { Box, Flex, Image, LinkBox, LinkOverlay } from "@chakra-ui/react"
43

5-
import InlineLink from "@/components/Link"
6-
import Text from "@/components/OldText"
4+
import { Flex } from "@/components/ui/flex"
5+
import InlineLink from "@/components/ui/Link"
6+
import { LinkBox, LinkOverlay } from "@/components/ui/link-box"
77

88
import data from "!!raw-loader!@/../.all-contributorsrc"
99

@@ -31,52 +31,31 @@ const Contributors = () => {
3131
have contributed so far!
3232
</p>
3333

34-
<Flex flexWrap="wrap">
34+
<Flex className="flex-wrap">
3535
{contributorsList.map((contributor) => (
3636
<LinkBox
37-
key={contributor.login}
3837
as="div"
39-
maxWidth="132px"
40-
margin="2"
41-
boxShadow="0px 14px 66px rgba(0, 0, 0, 0.07), 0px 10px 17px rgba(0, 0, 0, 0.03), 0px 4px 7px rgba(0, 0, 0, 0.05)"
42-
_hover={{
43-
textDecoration: "none",
44-
borderRadius: "base",
45-
boxShadow: "0px 8px 17px rgba(0, 0, 0, 0.15)",
46-
background: "tableBackgroundHover",
47-
transition: "transform 0.1s",
48-
transform: "scale(1.02)",
49-
}}
50-
_focus={{
51-
textDecoration: "none",
52-
borderRadius: "base",
53-
boxShadow: "0px 8px 17px rgba(0, 0, 0, 0.15)",
54-
background: "tableBackgroundHover",
55-
transition: "transform 0.1s",
56-
transform: "scale(1.02)",
57-
}}
38+
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+
key={contributor.login}
5840
>
59-
<Image
60-
width="132px"
61-
height="132px"
41+
<img
42+
className="h-[132px] w-[132px]"
6243
src={contributor.avatar_url}
6344
alt={contributor.name}
6445
/>
65-
<Box padding="1rem">
66-
<Text as="h3" fontSize="md" marginTop="2" marginBottom="4">
67-
<LinkOverlay
68-
as={InlineLink}
69-
href={contributor.profile}
70-
hideArrow
71-
color="text"
72-
textDecoration="none"
73-
_hover={{ textDecoration: "none" }}
74-
isExternal
75-
>
76-
{contributor.name}
46+
<div className="p-4">
47+
<h3 className="mb-4 mt-2 text-md">
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>
7756
</LinkOverlay>
78-
</Text>
79-
</Box>
57+
</h3>
58+
</div>
8059
</LinkBox>
8160
))}
8261
</Flex>

src/components/ui/link-box.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 }

0 commit comments

Comments
 (0)