1
- import { ReactNode } from "react"
1
+ import { BaseHTMLAttributes , ReactNode , useState } from "react"
2
2
import { useTranslation } from "next-i18next"
3
- import {
4
- AccordionButton ,
5
- AccordionItem ,
6
- AccordionPanel ,
7
- Box ,
8
- BoxProps ,
9
- Flex ,
10
- Heading ,
11
- Text ,
12
- } from "@chakra-ui/react"
13
3
14
4
import type { ChildOnlyProp } from "@/lib/types"
15
5
6
+ import { Flex } from "@/components/ui/flex"
7
+ import { Tag } from "@/components/ui/tag"
8
+
9
+ import {
10
+ AccordionContent ,
11
+ AccordionItem ,
12
+ AccordionTrigger ,
13
+ } from "../../../tailwind/ui/accordion"
16
14
import Emoji from "../Emoji"
17
- import Pill from "../Pill"
18
15
19
16
import { accordionButtonContent , CategoryNameType } from "./utils"
20
17
21
- export const LeftColumnPanel = ( props : ChildOnlyProp & Partial < BoxProps > ) => (
22
- < Box flex = "0 0 50%" maxW = { { lg : "75%" } } me = { { lg : 16 } } { ...props } />
18
+ type LeftColumnPanelElement = BaseHTMLAttributes < HTMLDivElement >
19
+
20
+ export const LeftColumnPanel = (
21
+ props : ChildOnlyProp & LeftColumnPanelElement
22
+ ) => (
23
+ < div
24
+ className = "flex-shrink-0 flex-grow-0 basis-1/2 lg:me-16 lg:max-w-[75%]"
25
+ { ...props }
26
+ />
23
27
)
24
28
25
29
export const RightColumnPanel = ( props : ChildOnlyProp ) => (
26
- < LeftColumnPanel me = { 0 } flex = "0 1 50%" mt = { { base : 12 , lg : 0 } } { ...props } />
30
+ < LeftColumnPanel
31
+ className = "me-0 mt-12 flex-shrink flex-grow-0 basis-1/2 lg:mt-0"
32
+ { ...props }
33
+ />
27
34
)
28
35
29
36
const MoreOrLessLink = ( { isOpen } : { isOpen : boolean } ) => {
30
37
const { t } = useTranslation ( "page-stablecoins" )
31
38
32
39
return (
33
- < Box me = { 6 } color = " primary.base ">
40
+ < div className = "me-6 text-md text- primary">
34
41
{ isOpen
35
42
? t ( "page-stablecoins-accordion-less" )
36
43
: t ( "page-stablecoins-accordion-more" ) }
37
- </ Box >
44
+ </ div >
38
45
)
39
46
}
40
47
@@ -49,74 +56,52 @@ interface AccordionCustomItemProps {
49
56
export const AccordionCustomItem = ( props : AccordionCustomItemProps ) => {
50
57
const { category, children } = props
51
58
const { t } = useTranslation ( "page-stablecoins" )
59
+ const [ open , setOpen ] = useState ( false )
60
+
61
+ const handleOpen = ( ) => setOpen ( ! open )
52
62
53
63
const contentObj = accordionButtonContent [ category ]
54
64
55
65
return (
56
- < AccordionItem border = "1px" borderColor = "border !important" >
57
- { ( { isExpanded } ) => (
58
- < >
59
- < AccordionButton
60
- justifyContent = "space-between"
61
- alignItems = "center"
62
- px = "0"
63
- py = "0"
64
- _expanded = { { background : "transparent" } }
65
- _hover = { { background : "ednBackground" } }
66
- >
67
- < Flex
68
- alignItems = { { base : "flex-start" , lg : "center" } }
69
- flexDirection = { { base : "column" , md : "row" } }
70
- m = { 6 }
71
- me = { 4 }
72
- { ...props }
73
- >
74
- < Emoji
75
- text = { contentObj . emoji }
76
- className = "mb-2 me-6 text-[3rem] md:mb-0 md:text-[4rem]"
77
- />
78
- < Box >
79
- < Flex alignItems = "center" mb = { 2 } >
80
- < Heading
81
- as = "h3"
82
- fontSize = { { base : "1.25rem" , md : "1.5rem" } }
83
- lineHeight = { 1.4 }
84
- >
85
- { t ( contentObj . title ) }
86
- </ Heading >
87
- { ! ! contentObj . pill && (
88
- < Pill ms = { 4 } background = { contentObj . pill . color } >
89
- { t ( contentObj . pill . name ) }
90
- </ Pill >
91
- ) }
92
- </ Flex >
93
- < Text color = "text200" textAlign = "start" >
94
- { t ( contentObj . textPreview ) }
95
- </ Text >
96
- </ Box >
97
- </ Flex >
98
- < MoreOrLessLink isOpen = { isExpanded } />
99
- </ AccordionButton >
100
- < AccordionPanel
101
- background = "ednBackground"
102
- border = "1px"
103
- borderColor = "border"
104
- mb = "-1px"
105
- mx = "-1px"
106
- mt = "0"
107
- p = "0"
108
- fontSize = "md"
109
- >
110
- < Flex
111
- p = { 8 }
112
- justifyContent = "space-between"
113
- flexDirection = { { base : "column" , lg : "row" } }
114
- >
115
- { children }
66
+ < AccordionItem value = { contentObj . title } className = "border" >
67
+ < AccordionTrigger
68
+ hideIcon
69
+ className = "items-center justify-between px-0 py-0 text-body-medium hover:text-body-medium md:px-0"
70
+ onClick = { handleOpen }
71
+ >
72
+ < Flex
73
+ className = "lg:center m-6 me-4 flex-col items-start md:flex-row"
74
+ { ...props }
75
+ >
76
+ < Emoji
77
+ text = { contentObj . emoji }
78
+ className = "mb-2 me-6 text-5xl md:mb-0 md:text-6xl"
79
+ />
80
+ < div >
81
+ < Flex className = "mb-2 items-center" >
82
+ < h3 className = "text-xl text-body hover:text-body md:text-2xl" >
83
+ { t ( contentObj . title ) }
84
+ </ h3 >
85
+ { ! ! contentObj . pill && (
86
+ < Tag
87
+ className = "ms-4"
88
+ variant = "solid"
89
+ status = { contentObj . pill . color }
90
+ >
91
+ { t ( contentObj . pill . name ) }
92
+ </ Tag >
93
+ ) }
116
94
</ Flex >
117
- </ AccordionPanel >
118
- </ >
119
- ) }
95
+ < p className = "text-start text-md" > { t ( contentObj . textPreview ) } </ p >
96
+ </ div >
97
+ </ Flex >
98
+ < MoreOrLessLink isOpen = { open } />
99
+ </ AccordionTrigger >
100
+ < AccordionContent className = "-mx-px -mb-px mt-0 border border-border bg-background p-0 text-md md:p-0" >
101
+ < Flex className = "flex-col justify-between p-8 lg:flex-row" >
102
+ { children }
103
+ </ Flex >
104
+ </ AccordionContent >
120
105
</ AccordionItem >
121
106
)
122
107
}
0 commit comments