1
- import { useRouter } from "next/router"
2
- import { useTranslation } from "next-i18next"
3
- import { Badge , Box , Flex , HStack , Text } from "@chakra-ui/react"
1
+ import { useRouter } from "next/router" ;
2
+ import { useTranslation } from "next-i18next" ;
3
+ import { Badge } from "@chakra-ui/react" ;
4
4
5
- import type { Lang , TranslationKey } from "@/lib/types"
6
- import { TutorialFrontmatter } from "@/lib/interfaces"
5
+ import type { Lang , TranslationKey } from "@/lib/types" ;
6
+ import { TutorialFrontmatter } from "@/lib/interfaces" ;
7
7
8
- import CopyToClipboard from "@/components/CopyToClipboard"
9
- import Emoji from "@/components/Emoji"
10
- import InlineLink from "@/components/Link"
11
- import Translation from "@/components/Translation"
12
- import TutorialTags from "@/components/TutorialTags"
8
+ import CopyToClipboard from "@/components/CopyToClipboard" ;
9
+ import Emoji from "@/components/Emoji" ;
10
+ import InlineLink from "@/components/Link" ;
11
+ import Translation from "@/components/Translation" ;
12
+ import TutorialTags from "@/components/TutorialTags" ;
13
13
14
- import { getLocaleTimestamp } from "@/lib/utils/time"
14
+ import { getLocaleTimestamp } from "@/lib/utils/time" ;
15
+ import { Flex } from "./ui/flex" ;
15
16
16
17
export type TutorialMetadataProps = {
17
- frontmatter : TutorialFrontmatter
18
- timeToRead : number
19
- }
18
+ frontmatter : TutorialFrontmatter ;
19
+ timeToRead : number ;
20
+ } ;
20
21
21
22
export enum Skill {
22
23
BEGINNER = "beginner" ,
@@ -25,120 +26,80 @@ export enum Skill {
25
26
}
26
27
27
28
export const getSkillTranslationId = ( skill : Skill ) : TranslationKey =>
28
- `page-developers-tutorials:page-tutorial-${
29
- Skill [ skill . toUpperCase ( ) as keyof typeof Skill ]
30
- } `
29
+ `page-developers-tutorials:page-tutorial-${ Skill [ skill . toUpperCase ( ) as keyof typeof Skill ]
30
+ } `;
31
31
32
32
const TutorialMetadata = ( {
33
33
frontmatter,
34
34
timeToRead,
35
35
} : TutorialMetadataProps ) => {
36
- const { locale } = useRouter ( )
37
- const { t } = useTranslation ( "page-developers-tutorials" )
36
+ const { locale } = useRouter ( ) ;
37
+ const { t } = useTranslation ( "page-developers-tutorials" ) ;
38
38
39
- const hasSource = frontmatter . source && frontmatter . sourceUrl
40
- const published = frontmatter . published
41
- const author = frontmatter . author
42
- const address = frontmatter . address
39
+ const hasSource = frontmatter . source && frontmatter . sourceUrl ;
40
+ const published = frontmatter . published ;
41
+ const author = frontmatter . author ;
42
+ const address = frontmatter . address ;
43
43
44
44
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" >
45
+ < Flex className = " flex-col justify-between pb-2 border-b-0 lg:border-b border-border" >
46
+ < Flex className = " justify-between items-center w-full mb-8" >
47
+ < div className = "flex flex-wrap w-full" >
53
48
< TutorialTags tags = { frontmatter . tags } />
54
- </ Flex >
55
- < Flex
56
- as = { Badge }
57
- variant = "secondary"
58
- alignSelf = "flex-start"
59
- mb = { 2 }
60
- whiteSpace = "nowrap"
61
- >
49
+ </ div >
50
+ < Badge variant = "secondary" className = "self-start mb-2 whitespace-nowrap" >
62
51
{ t ( getSkillTranslationId ( frontmatter . skill as Skill ) ) }
63
- </ Flex >
52
+ </ Badge >
64
53
</ 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
- >
54
+ < div className = "flex flex-wrap gap-4 mt-[-1rem] text-sm text-text300 mb-6" >
75
55
{ author && (
76
- < Box >
56
+ < div >
77
57
< Emoji className = "me-2 text-sm" text = ":writing_hand:" />
78
58
{ author }
79
- </ Box >
59
+ </ div >
80
60
) }
81
61
{ hasSource && (
82
- < Box >
62
+ < div >
83
63
< Emoji className = "me-2 text-sm" text = ":books:" />
84
64
< InlineLink href = { frontmatter . sourceUrl } >
85
65
{ frontmatter . source }
86
66
</ InlineLink >
87
- </ Box >
67
+ </ div >
88
68
) }
89
69
{ published && (
90
- < Box >
70
+ < div >
91
71
< Emoji className = "me-2 text-sm" text = ":calendar:" /> { " " }
92
72
{ getLocaleTimestamp ( locale ! as Lang , published ) }
93
- </ Box >
73
+ </ div >
94
74
) }
95
- < Box >
96
- < Emoji className = "me-2 text-sm" text = ":stopwatch:" />
75
+ < div >
76
+ < Emoji className = "me-2 text-sm" text = ":stopwatch:" />
97
77
{ 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"
78
+ </ div >
79
+ </ div >
80
+ { address && (
81
+ < div className = "flex flex-wrap mt-[-1rem] text-sm text-text300 mb-6" >
82
+ < CopyToClipboard text = { address } >
83
+ { ( isCopied ) => (
84
+ < div
85
+ className = "text-primary cursor-pointer overflow-hidden text-ellipsis font-mono bg-ednBackground px-1 text-sm hover:bg-primary100"
86
+ >
87
+ < div className = "uppercase" >
88
+ < Translation
128
89
id = "comp-tutorial-metadata-tip-author"
129
90
/> { " " }
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 >
91
+ </ div >
92
+ { address } { isCopied && < Translation id = "copied" /> }
93
+ { isCopied && (
94
+ < Emoji className = "mr-2 text-sm" text = ":white_check_mark:" />
95
+ ) }
96
+ </ div >
97
+ ) }
98
+ </ CopyToClipboard >
99
+ </ div >
100
+ ) }
140
101
</ Flex >
141
- )
142
- }
102
+ ) ;
103
+ } ;
143
104
144
- export default TutorialMetadata
105
+ export default TutorialMetadata ;
0 commit comments