@@ -2,24 +2,19 @@ import React from "react"
2
2
import { useRouter } from "next/router"
3
3
import { useTranslation } from "next-i18next"
4
4
import { BsCalendar3 } from "react-icons/bs"
5
- import { Box , Flex , Heading , Icon } from "@chakra-ui/react"
6
5
7
6
import type { EventCardProps } from "@/lib/types"
8
7
9
- import { ButtonLink } from "./Buttons"
8
+ import { ButtonLink } from "@/components/ui/buttons/Button"
9
+ import { Card , CardContent , CardFooter , CardHeader } from "@/components/ui/card"
10
+
11
+ import { cn } from "@/lib/utils/cn"
12
+
10
13
import { TwImage } from "./Image"
11
- import Text from "./OldText"
12
14
13
15
import EventFallback from "@/public/images/events/event-placeholder.png"
14
16
15
- const clearStyles = {
16
- content : '""' ,
17
- display : "block" ,
18
- width : "100%" ,
19
- clear : "both" ,
20
- }
21
-
22
- const EventCard = ( {
17
+ const EventCard : React . FC < EventCardProps > = ( {
23
18
title,
24
19
href,
25
20
description,
@@ -28,97 +23,50 @@ const EventCard = ({
28
23
imageUrl,
29
24
endDate,
30
25
startDate,
31
- } : EventCardProps ) => {
26
+ } ) => {
32
27
const { locale } = useRouter ( )
33
28
const { t } = useTranslation ( "page-community" )
29
+
34
30
const formatedDate = new Intl . DateTimeFormat ( locale , {
35
31
day : "2-digit" ,
36
32
month : "short" ,
37
33
} ) . formatRange (
38
- // .replace(/-/g, "/") ==> Fixes Safari Invalid date
39
34
new Date ( startDate ?. replace ( / - / g, "/" ) ) ,
40
35
new Date ( endDate ?. replace ( / - / g, "/" ) )
41
36
)
42
37
43
38
return (
44
- < Box
45
- className = { className }
46
- position = "relative"
47
- mt = "0"
48
- _before = { clearStyles }
49
- _after = { clearStyles }
50
- w = "full"
51
- h = "full"
52
- >
53
- < Flex
54
- border = "1px solid"
55
- borderColor = "lightBorder"
56
- height = { "100%" }
57
- direction = { "column" }
58
- justifyContent = { "space-between" }
59
- rounded = "base"
60
- >
61
- < Box >
62
- < Flex
63
- alignItems = { "center" }
64
- justifyContent = { "center" }
65
- background = { "grayBackground" }
66
- padding = { 2 }
67
- gap = { 2 }
68
- borderBottom = "1px solid"
69
- borderColor = "primary.base"
70
- roundedTop = { "4px" }
71
- >
72
- < Icon as = { BsCalendar3 } boxSize = { 6 } color = "primary.base" />
73
-
74
- < Text color = "primary.base" marginBottom = { 0 } textAlign = "end" >
75
- { formatedDate }
76
- </ Text >
77
- </ Flex >
78
-
79
- { /* TODO : add image hostname to next config or add event image to public dir */ }
80
- < Flex
81
- alignItems = "center"
82
- justifyContent = "center"
83
- boxShadow = "rgb(0 0 0 / 10%) 0px -1px 0px inset;"
84
- >
85
- { imageUrl ? (
86
- // eslint-disable-next-line @next/next/no-img-element
87
- < img
88
- src = { imageUrl }
89
- alt = { title }
90
- className = "max-h-[224px] w-full object-cover xl:h-[124px]"
91
- />
92
- ) : (
93
- < TwImage src = { EventFallback } alt = "" />
94
- ) }
95
- </ Flex >
96
- < Box padding = { 4 } >
97
- < Box textAlign = { "center" } >
98
- < Heading
99
- as = "h3"
100
- fontSize = { { base : "md" , md : "2xl" } }
101
- marginTop = { 0 }
102
- lineHeight = { 1.4 }
103
- >
104
- { title }
105
- </ Heading >
106
- < Text as = "span" opacity = { 0.6 } >
107
- { location }
108
- </ Text >
109
- </ Box >
110
- < Box >
111
- < Text fontSize = "sm" > { description } </ Text >
112
- </ Box >
113
- </ Box >
114
- </ Box >
115
- < Box padding = { 4 } paddingTop = { 0 } width = { "100%" } >
116
- < ButtonLink href = { href } width = { "100%" } variant = "outline" >
117
- { t ( "page-community-upcoming-events-view-event" ) }
118
- </ ButtonLink >
119
- </ Box >
120
- </ Flex >
121
- </ Box >
39
+ < Card className = { cn ( "flex h-full flex-col rounded-md border" , className ) } >
40
+ < CardHeader className = "flex flex-row items-center justify-center rounded-t-md border-b border-primary bg-[#FCFCFC] p-2 dark:bg-[#272627]" >
41
+ < BsCalendar3 className = "mr-2 h-6 w-6 text-primary" />
42
+ < span className = "!mt-0 text-right text-sm text-primary" >
43
+ { formatedDate }
44
+ </ span >
45
+ </ CardHeader >
46
+ < div className = "flex items-center justify-center" >
47
+ { imageUrl ? (
48
+ < img
49
+ src = { imageUrl }
50
+ alt = { title }
51
+ className = "max-h-[224px] w-full object-cover xl:h-[124px]"
52
+ />
53
+ ) : (
54
+ < TwImage src = { EventFallback } alt = "" />
55
+ ) }
56
+ </ div >
57
+ < CardContent className = "flex-grow p-4" >
58
+ < div className = "text-center" >
59
+ < h3 className = "text-xl font-bold md:text-2xl" > { title } </ h3 >
60
+ < span className = "text-sm opacity-60" > { location } </ span >
61
+ </ div >
62
+ < p className = "md:text-sm md:leading-[1.6rem]" > { description } </ p >
63
+ </ CardContent >
64
+ < CardFooter className = "p-4 pt-0" >
65
+ < ButtonLink href = { href } variant = "outline" className = "w-full text-sm" >
66
+ { t ( "page-community-upcoming-events-view-event" ) }
67
+ </ ButtonLink >
68
+ </ CardFooter >
69
+ </ Card >
122
70
)
123
71
}
124
72
0 commit comments