Skip to content

Commit 6552f4e

Browse files
authored
Merge pull request #14335 from bhushanpardeshii/migrate_tutorialmetadata
migrated `TutorialMetadata.tsx` to shadcn/tailwind
2 parents d042f4a + 0e138a2 commit 6552f4e

File tree

1 file changed

+36
-74
lines changed

1 file changed

+36
-74
lines changed

src/components/TutorialMetadata.tsx

Lines changed: 36 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useRouter } from "next/router"
22
import { useTranslation } from "next-i18next"
3-
import { Badge, Box, Flex, HStack, Text } from "@chakra-ui/react"
3+
import { Badge } from "@chakra-ui/react"
44

55
import type { Lang, TranslationKey } from "@/lib/types"
66
import { TutorialFrontmatter } from "@/lib/interfaces"
@@ -13,6 +13,8 @@ import TutorialTags from "@/components/TutorialTags"
1313

1414
import { getLocaleTimestamp } from "@/lib/utils/time"
1515

16+
import { Flex } from "./ui/flex"
17+
1618
export type TutorialMetadataProps = {
1719
frontmatter: TutorialFrontmatter
1820
timeToRead: number
@@ -42,101 +44,61 @@ const TutorialMetadata = ({
4244
const address = frontmatter.address
4345

4446
return (
45-
<Flex
46-
flexDirection="column"
47-
justifyContent="space-between"
48-
borderBottomWidth={{ base: 0, lg: "1px" }}
49-
borderBottomColor="border"
50-
>
51-
<Flex justifyContent="space-between" alignItems="center" w="full" mb={8}>
52-
<Flex flexWrap="wrap" w="full">
47+
<Flex className="flex-col justify-between border-b-0 border-border pb-2 lg:border-b">
48+
<Flex className="mb-8 w-full items-center justify-between">
49+
<Flex className="w-full flex-wrap">
5350
<TutorialTags tags={frontmatter.tags} />
5451
</Flex>
55-
<Flex
56-
as={Badge}
52+
<Badge
5753
variant="secondary"
58-
alignSelf="flex-start"
59-
mb={2}
60-
whiteSpace="nowrap"
54+
className="mb-2 self-start whitespace-nowrap"
6155
>
6256
{t(getSkillTranslationId(frontmatter.skill as Skill))}
63-
</Flex>
57+
</Badge>
6458
</Flex>
65-
<HStack
66-
mb={6}
67-
flexWrap="wrap"
68-
mt={-4}
69-
fontSize="sm"
70-
color="text300"
71-
justifyContent="flex-start"
72-
alignItems="flex-start"
73-
spacing={4}
74-
>
59+
<Flex className="text-text300 mb-6 mt-[-1rem] flex-wrap gap-4 text-sm">
7560
{author && (
76-
<Box>
61+
<div>
7762
<Emoji className="me-2 text-sm" text=":writing_hand:" />
7863
{author}
79-
</Box>
64+
</div>
8065
)}
8166
{hasSource && (
82-
<Box>
67+
<div>
8368
<Emoji className="me-2 text-sm" text=":books:" />
8469
<InlineLink href={frontmatter.sourceUrl}>
8570
{frontmatter.source}
8671
</InlineLink>
87-
</Box>
72+
</div>
8873
)}
8974
{published && (
90-
<Box>
75+
<div>
9176
<Emoji className="me-2 text-sm" text=":calendar:" />{" "}
9277
{getLocaleTimestamp(locale! as Lang, published)}
93-
</Box>
78+
</div>
9479
)}
95-
<Box>
80+
<div>
9681
<Emoji className="me-2 text-sm" text=":stopwatch:" />
9782
{timeToRead} {t("comp-tutorial-metadata-minute-read")} minute read
98-
</Box>
99-
</HStack>
100-
<HStack
101-
mb={6}
102-
flexWrap="wrap"
103-
mt={-4}
104-
fontSize="sm"
105-
color="text300"
106-
justifyContent="flex-start"
107-
>
108-
{address && (
109-
<Flex flexWrap="wrap" w="full" me={4}>
110-
<CopyToClipboard text={address}>
111-
{(isCopied) => (
112-
<Box
113-
color="primary.base"
114-
cursor="pointer"
115-
overflow="hidden"
116-
textOverflow="ellipsis"
117-
fontFamily="monospace"
118-
bg="ednBackground"
119-
px={1}
120-
fontSize="sm"
121-
_hover={{
122-
bg: "primary100",
123-
}}
124-
>
125-
<Text
126-
as={Translation}
127-
textTransform="uppercase"
128-
id="comp-tutorial-metadata-tip-author"
129-
/>{" "}
130-
{address} {isCopied && <Translation id="copied" />}
131-
{isCopied && (
132-
<Emoji className="me-2 text-sm" text=":white_check_mark:" />
133-
)}
134-
</Box>
135-
)}
136-
</CopyToClipboard>
137-
</Flex>
138-
)}
139-
</HStack>
83+
</div>
84+
</Flex>
85+
{address && (
86+
<Flex className="text-text300 -mt-4 mb-6 flex-wrap text-sm">
87+
<CopyToClipboard text={address}>
88+
{(isCopied) => (
89+
<div className="cursor-pointer overflow-hidden text-ellipsis bg-background-highlight px-1 font-mono text-sm text-primary hover:bg-primary-hover hover:text-body-inverse">
90+
<span className="uppercase">
91+
<Translation id="page-developers-tutorials:comp-tutorial-metadata-tip-author" />
92+
</span>{" "}
93+
{address} {isCopied && <Translation id="copied" />}{" "}
94+
{isCopied && (
95+
<Emoji className="text-sm" text=":white_check_mark:" />
96+
)}
97+
</div>
98+
)}
99+
</CopyToClipboard>
100+
</Flex>
101+
)}
140102
</Flex>
141103
)
142104
}

0 commit comments

Comments
 (0)