Skip to content

Commit a0810d3

Browse files
committed
New ContributorFooter component for displaying
authors, reviewers and contributors.
1 parent a44641a commit a0810d3

File tree

4 files changed

+111
-39
lines changed

4 files changed

+111
-39
lines changed

components/mdx/Author.tsx

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,47 @@
1-
import { Box, Text, Link, HStack, Avatar } from '@chakra-ui/react'
1+
import { Box, Text, Link, HStack, Avatar, Center } from '@chakra-ui/react'
22
import NextLink from 'next/link'
33
import { contributors } from '@data/contributors'
44

55
interface AuthorProps {
66
handle: string
7+
avatarSize?: string
78
}
89

9-
export function Author({ handle }: AuthorProps) {
10+
export function Author({ handle, avatarSize }: AuthorProps) {
1011
const author = contributors[handle]
1112
if (!author) {
1213
return null
1314
}
1415

1516
return (
16-
<Box
17-
marginY={12}
18-
paddingY={4}
19-
paddingBottom={8}
20-
borderTopWidth="thin"
21-
borderColor="gray"
22-
>
23-
<Text fontSize={25} marginBottom={4}>
24-
Written by
25-
</Text>
26-
<HStack paddingX={2} columnGap={4}>
27-
<Box>
28-
<Avatar size="2xl" name={author.displayName} src={author.avatarUrl} />
29-
</Box>
30-
<Box>
31-
{author.moreInfoUrl && (
32-
<Link
33-
as={NextLink}
34-
href={author.moreInfoUrl}
35-
passHref
36-
isExternal
37-
textDecoration="underline"
38-
>
39-
{author.displayName}
40-
</Link>
41-
)}
42-
{!author.moreInfoUrl && <Text>{author.displayName}</Text>}
17+
<HStack paddingX={2} columnGap={4}>
18+
<Center width={40}>
19+
<Avatar
20+
size={avatarSize}
21+
name={author.displayName}
22+
src={author.avatarUrl}
23+
/>
24+
</Center>
25+
<Box>
26+
{author.moreInfoUrl && (
27+
<Link
28+
as={NextLink}
29+
href={author.moreInfoUrl}
30+
passHref
31+
isExternal
32+
textDecoration="underline"
33+
>
34+
<Text fontSize={18}>{author.displayName}</Text>
35+
</Link>
36+
)}
37+
{!author.moreInfoUrl && <Text>{author.displayName}</Text>}
4338

44-
{author.about && (
45-
<Box mt={2} maxWidth="xl">
46-
{author.about}
47-
</Box>
48-
)}
49-
</Box>
50-
</HStack>
51-
</Box>
39+
{author.about && (
40+
<Box mt={2} maxWidth="xl">
41+
<Text fontSize={14}>{author.about}</Text>
42+
</Box>
43+
)}
44+
</Box>
45+
</HStack>
5246
)
5347
}

components/mdx/ContributorFooter.tsx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { Box, Text, VStack } from '@chakra-ui/react'
2+
import { Author } from '@components/mdx/Author'
3+
4+
interface ContributorFooterProps {
5+
authors: string[]
6+
reviewers: string[]
7+
contributors: string[]
8+
}
9+
10+
export function ContributorFooter({
11+
authors,
12+
reviewers,
13+
contributors,
14+
}: ContributorFooterProps) {
15+
return (
16+
<Box
17+
marginY={12}
18+
paddingY={4}
19+
paddingBottom={8}
20+
borderTopWidth="thin"
21+
borderColor="gray"
22+
>
23+
{authors && authors.length > 0 && (
24+
<Box>
25+
<Text fontSize={26} marginTop={8} marginBottom={4}>
26+
{authors.length > 1 ? 'Authors' : 'Author'}
27+
</Text>
28+
<VStack spacing={4} alignItems="left">
29+
{authors.map((contrib) => {
30+
return <Author handle={contrib} avatarSize="2xl" />
31+
})}
32+
</VStack>
33+
</Box>
34+
)}
35+
36+
{reviewers && reviewers.length > 0 && (
37+
<Box>
38+
<Text fontSize={20} marginTop={8} marginBottom={4}>
39+
{reviewers.length > 1 ? 'Reviewers' : 'Reviewer'}
40+
</Text>
41+
<VStack spacing={4} alignItems="left">
42+
{reviewers.map((contrib) => {
43+
return <Author handle={contrib} avatarSize="lg" />
44+
})}
45+
</VStack>
46+
</Box>
47+
)}
48+
49+
{contributors && contributors.length > 0 && (
50+
<Box>
51+
<Text fontSize={20} marginTop={8} marginBottom={4}>
52+
{contributors.length > 1
53+
? 'Additional Contributors'
54+
: 'Additional Contributor'}
55+
</Text>
56+
<VStack spacing={4} alignItems="left">
57+
{contributors.map((contrib) => {
58+
return <Author handle={contrib} avatarSize="lg" />
59+
})}
60+
</VStack>
61+
</Box>
62+
)}
63+
</Box>
64+
)
65+
}

data/contributors.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@ export const contributors: ContributorLookup = {
1717
about:
1818
'Brian has been a member of the DeveloperDAO since November 2021, and enjoys building Web3 user experiences and smart contracts. Also active with Next.js, React and Serverless.',
1919
},
20+
piablo: {
21+
displayName: 'piablo',
22+
},
23+
georgemac510: {
24+
displayName: 'georgemac510',
25+
},
26+
lorem: {
27+
displayName: 'Lorem Ipsum',
28+
},
2029
}

pages/lessons/projects/4.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ icons: ['solidity', 'hardhat', 'openzeppelin']
66
---
77

88
import { LessonHeader } from '../../../components/mdx/LessonHeader'
9-
import { Author } from '../../../components/mdx/Author'
9+
import { ContributorFooter } from '../../../components/mdx/ContributorFooter'
1010

1111
<LessonHeader
1212
title="Lesson 4: Testing your TierNFT"
@@ -893,4 +893,8 @@ With TDD:
893893
Go forth, test, and prosper knowing you have confidence in the code you're
894894
deploying into the world.
895895

896-
<Author handle="brianfive" />
896+
<ContributorFooter
897+
authors={['brianfive']}
898+
reviewers={['piablo', 'georgemac510']}
899+
contributors={['lorem', 'lorem']}
900+
/>

0 commit comments

Comments
 (0)