1
1
import { useRouter } from "next/router"
2
2
import { useTranslation } from "next-i18next"
3
- import { Badge , Box , Flex , HStack , Text } from "@chakra-ui/react"
3
+ import { Badge } from "@chakra-ui/react"
4
4
5
5
import type { Lang , TranslationKey } from "@/lib/types"
6
6
import { TutorialFrontmatter } from "@/lib/interfaces"
@@ -13,6 +13,8 @@ import TutorialTags from "@/components/TutorialTags"
13
13
14
14
import { getLocaleTimestamp } from "@/lib/utils/time"
15
15
16
+ import { Flex } from "./ui/flex"
17
+
16
18
export type TutorialMetadataProps = {
17
19
frontmatter : TutorialFrontmatter
18
20
timeToRead : number
@@ -42,101 +44,61 @@ const TutorialMetadata = ({
42
44
const address = frontmatter . address
43
45
44
46
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" >
53
50
< TutorialTags tags = { frontmatter . tags } />
54
51
</ Flex >
55
- < Flex
56
- as = { Badge }
52
+ < Badge
57
53
variant = "secondary"
58
- alignSelf = "flex-start"
59
- mb = { 2 }
60
- whiteSpace = "nowrap"
54
+ className = "mb-2 self-start whitespace-nowrap"
61
55
>
62
56
{ t ( getSkillTranslationId ( frontmatter . skill as Skill ) ) }
63
- </ Flex >
57
+ </ Badge >
64
58
</ 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" >
75
60
{ author && (
76
- < Box >
61
+ < div >
77
62
< Emoji className = "me-2 text-sm" text = ":writing_hand:" />
78
63
{ author }
79
- </ Box >
64
+ </ div >
80
65
) }
81
66
{ hasSource && (
82
- < Box >
67
+ < div >
83
68
< Emoji className = "me-2 text-sm" text = ":books:" />
84
69
< InlineLink href = { frontmatter . sourceUrl } >
85
70
{ frontmatter . source }
86
71
</ InlineLink >
87
- </ Box >
72
+ </ div >
88
73
) }
89
74
{ published && (
90
- < Box >
75
+ < div >
91
76
< Emoji className = "me-2 text-sm" text = ":calendar:" /> { " " }
92
77
{ getLocaleTimestamp ( locale ! as Lang , published ) }
93
- </ Box >
78
+ </ div >
94
79
) }
95
- < Box >
80
+ < div >
96
81
< Emoji className = "me-2 text-sm" text = ":stopwatch:" />
97
82
{ 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
+ ) }
140
102
</ Flex >
141
103
)
142
104
}
0 commit comments