Skip to content

Commit cb7b110

Browse files
committed
Add forum message to LessonHeader, remove author.
Beef up Author component.
1 parent 770fcd2 commit cb7b110

File tree

3 files changed

+99
-14
lines changed

3 files changed

+99
-14
lines changed

components/mdx/Author.tsx

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,73 @@
1-
import { Box, Text } from '@chakra-ui/react'
1+
import { Box, Text, Link, HStack, Avatar } from '@chakra-ui/react'
2+
import NextLink from 'next/link'
23

34
interface AuthorProps {
4-
author: string
5+
handle: string
56
}
67

7-
export function Author({ author }: AuthorProps) {
8+
interface AuthorDetails {
9+
displayName: string
10+
moreInfoUrl?: string
11+
avatarUrl?: string
12+
about?: string
13+
}
14+
15+
interface AuthorLookup {
16+
[key: string]: AuthorDetails
17+
}
18+
19+
const authors: AuthorLookup = {
20+
brianfive: {
21+
displayName: 'Brian Gershon',
22+
moreInfoUrl: 'https://brianfive.xyz',
23+
avatarUrl: 'https://brianfive.xyz/profile.png',
24+
about:
25+
'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.',
26+
},
27+
}
28+
29+
export function Author({ handle }: AuthorProps) {
30+
const author = authors[handle]
31+
if (!author) {
32+
return null
33+
}
34+
835
return (
9-
<Box mt="8" py="5">
10-
<Text>[Author Bio Goes Here]</Text>
11-
<Text>{author}</Text>
36+
<Box
37+
marginY={12}
38+
paddingY={4}
39+
paddingBottom={8}
40+
borderTopWidth="thin"
41+
borderColor="gray"
42+
>
43+
<Text fontSize={25} marginBottom={4}>
44+
Written by
45+
</Text>
46+
<HStack paddingX={2} columnGap={4}>
47+
<Box>
48+
<Avatar size="2xl" name={author.displayName} src={author.avatarUrl} />
49+
</Box>
50+
<Box>
51+
{author.moreInfoUrl && (
52+
<Link
53+
as={NextLink}
54+
href={author.moreInfoUrl}
55+
passHref
56+
isExternal
57+
textDecoration="underline"
58+
>
59+
{author.displayName}
60+
</Link>
61+
)}
62+
{!author.moreInfoUrl && <Text>{author.displayName}</Text>}
63+
64+
{author.about && (
65+
<Box mt={2} maxWidth="xl">
66+
{author.about}
67+
</Box>
68+
)}
69+
</Box>
70+
</HStack>
1271
</Box>
1372
)
1473
}

components/mdx/LessonHeader.tsx

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
1-
import { Box, useStyleConfig, Text } from '@chakra-ui/react'
1+
import { Box, useStyleConfig, Text, Link, HStack } from '@chakra-ui/react'
2+
import NextLink from 'next/link'
3+
import { QuestionIcon } from '@chakra-ui/icons'
24

35
interface LessonHeaderProps {
46
title: string
5-
author: string
7+
discussionUrl: string
68
}
79

8-
export function LessonHeader({ title, author }: LessonHeaderProps) {
10+
export function LessonHeader({ title, discussionUrl }: LessonHeaderProps) {
911
const headerStyle = useStyleConfig('LessonHeader')
1012

1113
return (
1214
<Box>
1315
<Box __css={headerStyle}>
1416
<Text>{title}</Text>
1517
</Box>
16-
<div>Author: {author}</div>
18+
<HStack
19+
borderWidth="thin"
20+
borderColor="gray"
21+
padding="4"
22+
marginY="8"
23+
columnGap={2}
24+
maxWidth="xl"
25+
>
26+
<Box>
27+
<QuestionIcon w={12} h={12} />
28+
</Box>
29+
<Box>
30+
Please visit our{' '}
31+
<Link
32+
as={NextLink}
33+
href={discussionUrl}
34+
passHref
35+
isExternal
36+
textDecoration="underline"
37+
>
38+
forum
39+
</Link>{' '}
40+
for questions or more discussion.
41+
</Box>
42+
</HStack>
1743
</Box>
1844
)
1945
}

pages/lessons/projects/4.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ description:
55
icons: ['solidity', 'hardhat', 'openzeppelin']
66
---
77

8-
import { LessonHeader } from '../../../components/mdx/LessonHeader';
9-
import { Author } from '../../../components/mdx/Author';
8+
import { LessonHeader } from '../../../components/mdx/LessonHeader'
9+
import { Author } from '../../../components/mdx/Author'
1010

11-
<LessonHeader title="Lesson 4: Testing your TierNFT" author="brianfive" />
11+
<LessonHeader title="Lesson 4: Testing your TierNFT" discussionUrl="https://developerdao.peeranha.io/discussions/1372/testing-solidity-contracts" />
1212

1313
In this lesson, we'll be adding automated tests for our smart contract created
1414
in Lesson 3.
@@ -890,4 +890,4 @@ With TDD:
890890
Go forth, test, and prosper knowing you have confidence in the code you're
891891
deploying into the world.
892892

893-
<Author author="brianfive" />
893+
<Author handle="brianfive" />

0 commit comments

Comments
 (0)