Skip to content

Commit 026636e

Browse files
authored
Merge pull request #14814 from TylerAPfledderer/feat/shadCN-avatar-implement
[ShadCN]: Implement ShadCN Avatar to Production
2 parents d769486 + 1c14c28 commit 026636e

File tree

4 files changed

+31
-28
lines changed

4 files changed

+31
-28
lines changed

src/components/FileContributors.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { BaseHTMLAttributes, useState } from "react"
2-
import { Avatar } from "@chakra-ui/react"
32

43
import type { ChildOnlyProp, FileContributor } from "@/lib/types"
54

@@ -12,6 +11,7 @@ import { ScrollArea } from "@/components/ui/scroll-area"
1211

1312
import { trackCustomEvent } from "@/lib/utils/matomo"
1413

14+
import { Avatar } from "./ui/avatar"
1515
import Modal from "./ui/dialog-modal"
1616

1717
import { useBreakpointValue } from "@/hooks/useBreakpointValue"
@@ -22,19 +22,27 @@ const ContributorList = ({ children }: Required<ChildOnlyProp>) => (
2222
</ScrollArea>
2323
)
2424

25+
const ContributorAvatar = ({
26+
contributor,
27+
label,
28+
}: ContributorProps & { label?: string }) => (
29+
<Avatar
30+
src={contributor.avatar_url}
31+
name={contributor.login}
32+
href={`https://github.com/${contributor.login}`}
33+
// `size-10` is not part of the "size" variants
34+
className="me-2 size-10"
35+
label={label}
36+
/>
37+
)
38+
2539
type ContributorProps = { contributor: FileContributor }
2640
const Contributor = ({ contributor }: ContributorProps) => (
2741
<ListItem className="flex items-center p-2">
28-
<Avatar
29-
height="40px"
30-
width="40px"
31-
src={contributor.avatar_url}
32-
name={contributor.login}
33-
me={2}
42+
<ContributorAvatar
43+
contributor={contributor}
44+
label={"@" + contributor.login}
3445
/>
35-
<InlineLink href={"https://github.com/" + contributor.login}>
36-
@{contributor.login}
37-
</InlineLink>
3846
</ListItem>
3947
)
4048

@@ -84,13 +92,7 @@ const FileContributors = ({
8492

8593
<Flex className="flex-col p-0 md:flex-row md:p-2" {...props}>
8694
<Flex className="invisible me-4 flex-1 items-center md:visible md:flex">
87-
<Avatar
88-
height="40px"
89-
width="40px"
90-
src={lastContributor.avatar_url}
91-
name={lastContributor.login}
92-
me={2}
93-
/>
95+
<ContributorAvatar contributor={lastContributor} />
9496

9597
<p className="m-0 text-body-medium">
9698
<Translation id="last-edit" />:{" "}

src/components/IssuesList/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Emoji from "react-emoji-render"
22
import {
3-
Avatar,
43
Flex,
54
HStack,
65
SimpleGrid,
@@ -13,6 +12,7 @@ import type { GHIssue } from "@/lib/types"
1312

1413
import InlineLink from "../Link"
1514
import Tag from "../Tag"
15+
import { Avatar } from "../ui/avatar"
1616

1717
type IssuesListProps = SimpleGridProps & {
1818
issues: GHIssue[]
@@ -35,8 +35,8 @@ const IssuesList = ({ issues, ...props }: IssuesListProps) => {
3535
<Avatar
3636
name={issue.user.login}
3737
src={issue.user.avatar_url}
38-
w="32px"
39-
h="32px"
38+
size="sm"
39+
href={`https://github.com/${issue.user.login}`}
4040
/>
4141
<Text size="sm">by {issue.user.login}</Text>
4242
</HStack>

src/components/Leaderboard.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useTranslation } from "next-i18next"
22
import {
3-
Avatar,
43
Box,
54
Flex,
65
LinkBox,
@@ -16,6 +15,8 @@ import { BaseLink } from "@/components/Link"
1615

1716
import { GITHUB_URL } from "@/lib/constants"
1817

18+
import { Avatar } from "./ui/avatar"
19+
1920
import { useRtlFlip } from "@/hooks/useRtlFlip"
2021

2122
type Person = {
@@ -95,10 +96,10 @@ const Leaderboard = ({ content, limit = 100 }: LeaderboardProps) => {
9596
<Avatar
9697
src={avatarImg}
9798
name={avatarAlt}
98-
me={4}
99-
h={10}
100-
w={10}
101-
display={{ base: "none", xs: "block" }}
99+
// This meets the Design System requirement, despite the leaderboard item itself being a link
100+
href={hasGitHub ? `${GITHUB_URL}${username}` : "#"}
101+
// `size-10` is not part of a "size" variant
102+
className="me-4 size-10"
102103
/>
103104
<Flex flex="1 1 75%" direction="column" me={8}>
104105
<LinkOverlay

src/components/ui/avatar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { LinkBox, LinkOverlay } from "./link-box"
1212
const avatarStyles = tv({
1313
slots: {
1414
container:
15-
"relative shrink-0 flex overflow-hidden rounded-full focus:outline-4 focus:-outline-offset-1 focus:rounded-full active:shadow-none [&_img]:hover:opacity-70 border border-transparent active:border-primary-hover justify-center items-center",
16-
fallback: "bg-body text-body-inverse",
15+
"relative shrink-0 overflow-hidden rounded-full focus:outline-4 focus:-outline-offset-1 focus:rounded-full active:shadow-none [&_img]:hover:opacity-70 border border-transparent active:border-primary-hover ",
16+
fallback: "bg-body text-body-inverse flex justify-center items-center",
1717
},
1818
variants: {
1919
size: {
@@ -126,7 +126,7 @@ const Avatar = React.forwardRef<
126126
href,
127127
src,
128128
name,
129-
size,
129+
size = "md",
130130
label,
131131
className,
132132
direction = "row",

0 commit comments

Comments
 (0)