|
1 |
| -import { type ReactNode, useState } from "react" |
| 1 | +import React, { type ReactNode, useState } from "react" |
2 | 2 | import { useTranslation } from "next-i18next"
|
3 |
| -import { |
4 |
| - Accordion, |
5 |
| - AccordionButton, |
6 |
| - AccordionItem, |
7 |
| - AccordionPanel, |
8 |
| - Box, |
9 |
| - Heading, |
10 |
| - type Icon as ChakraIcon, |
11 |
| -} from "@chakra-ui/react" |
12 | 3 |
|
13 |
| -import Text from "@/components/OldText" |
| 4 | +import { Flex, HStack, VStack } from "@/components/ui/flex" |
14 | 5 |
|
15 | 6 | import { trackCustomEvent } from "@/lib/utils/matomo"
|
16 | 7 |
|
| 8 | +import { |
| 9 | + Accordion, |
| 10 | + AccordionContent, |
| 11 | + AccordionItem, |
| 12 | + AccordionTrigger, |
| 13 | +} from "../../tailwind/ui/accordion" |
| 14 | + |
17 | 15 | export type ExpandableCardProps = {
|
18 | 16 | children?: ReactNode
|
19 | 17 | contentPreview?: ReactNode
|
20 | 18 | title: ReactNode
|
21 |
| - svg?: typeof ChakraIcon |
| 19 | + svg?: React.ElementType |
22 | 20 | eventAction?: string
|
23 | 21 | eventCategory?: string
|
24 | 22 | eventName?: string
|
@@ -54,96 +52,38 @@ const ExpandableCard = ({
|
54 | 52 | }
|
55 | 53 |
|
56 | 54 | return (
|
57 |
| - <Accordion |
58 |
| - border="1px" |
59 |
| - borderColor="border" |
60 |
| - borderRadius="sm" |
61 |
| - display="flex" |
62 |
| - flexDirection="column" |
63 |
| - marginBottom="4" |
64 |
| - cursor="pointer" |
65 |
| - _hover={{ |
66 |
| - backgroundColor: "ednBackground", |
67 |
| - }} |
68 |
| - index={isVisible ? [0] : []} |
69 |
| - > |
70 |
| - <AccordionItem borderTopWidth="0" flex="1"> |
71 |
| - <Heading as="h3" m={0}> |
72 |
| - <AccordionButton |
73 |
| - width="100%" |
74 |
| - px="6" |
75 |
| - py="6" |
76 |
| - flex="1" |
| 55 | + <> |
| 56 | + <Accordion type="single" collapsible className="mb-4"> |
| 57 | + <AccordionItem |
| 58 | + value="item-1" |
| 59 | + className="rounded-sm border hover:bg-background-highlight" |
| 60 | + > |
| 61 | + <AccordionTrigger |
| 62 | + hideIcon |
77 | 63 | onClick={onClick}
|
78 |
| - _hover={{ |
79 |
| - backgroundColor: "ednBackground", |
80 |
| - }} |
81 |
| - _expanded={{ |
82 |
| - backgroundColor: "transparent", |
83 |
| - }} |
| 64 | + className="w-full p-6 transition-colors hover:bg-background-highlight hover:text-black md:p-6 dark:hover:text-white [&[data-state=open]]:bg-transparent [&[data-state=open]]:text-black dark:[&[data-state=open]]:text-white" |
84 | 65 | >
|
85 |
| - <Box |
86 |
| - display="flex" |
87 |
| - width="100%" |
88 |
| - alignItems="center" |
89 |
| - flexDir={{ base: "column", sm: "row" }} |
90 |
| - textAlign="start" |
91 |
| - > |
92 |
| - <Box marginBottom={{ base: 2, sm: 0 }} me={{ base: 0, sm: 4 }}> |
93 |
| - <Box |
94 |
| - display="flex" |
95 |
| - alignItems="center" |
96 |
| - sx={{ |
97 |
| - svg: { me: "1.5rem" }, |
98 |
| - }} |
99 |
| - my="4" |
100 |
| - > |
101 |
| - {!!Svg && <Svg />} |
102 |
| - <Text fontSize="xl" fontWeight="semibold" flex="1" m="0"> |
103 |
| - {title} |
104 |
| - </Text> |
105 |
| - </Box> |
106 |
| - <Text |
107 |
| - fontSize="sm" |
108 |
| - color="text200" |
109 |
| - marginBottom="0" |
110 |
| - width="fit-content" |
111 |
| - > |
| 66 | + <Flex className="w-full flex-col items-center text-left sm:flex-row"> |
| 67 | + <VStack className="items-center md:items-start"> |
| 68 | + <HStack className="mb-2 mt-4"> |
| 69 | + {Svg && <Svg className="mr-6" />} |
| 70 | + <h3 className="text-xl font-semibold">{title}</h3> |
| 71 | + </HStack> |
| 72 | + <p className="w-fit text-sm text-body-medium"> |
112 | 73 | {contentPreview}
|
113 |
| - </Text> |
114 |
| - </Box> |
115 |
| - <Text |
116 |
| - fontSize="md" |
117 |
| - color="primary.base" |
118 |
| - ms={{ base: undefined, sm: "auto" }} |
119 |
| - mt="auto" |
120 |
| - mb="auto" |
121 |
| - > |
| 74 | + </p> |
| 75 | + </VStack> |
| 76 | + <span className="my-auto text-md text-primary sm:ml-auto"> |
122 | 77 | {t(isVisible ? "less" : "more")}
|
123 |
| - </Text> |
124 |
| - </Box> |
125 |
| - </AccordionButton> |
126 |
| - </Heading> |
127 |
| - <AccordionPanel |
128 |
| - p="0" |
129 |
| - mt="0" |
130 |
| - paddingX="6" |
131 |
| - paddingBottom="6" |
132 |
| - paddingTop="0" |
133 |
| - onClick={onClick} |
134 |
| - > |
135 |
| - <Box |
136 |
| - fontSize="md" |
137 |
| - color="text" |
138 |
| - paddingTop="6" |
139 |
| - borderTop="1px solid" |
140 |
| - borderColor="border" |
141 |
| - > |
142 |
| - {children} |
143 |
| - </Box> |
144 |
| - </AccordionPanel> |
145 |
| - </AccordionItem> |
146 |
| - </Accordion> |
| 78 | + </span> |
| 79 | + </Flex> |
| 80 | + </AccordionTrigger> |
| 81 | + <AccordionContent className="p-6 pt-0 md:p-6 md:pt-0"> |
| 82 | + <div className="border-t pt-6 text-md text-body">{children}</div> |
| 83 | + </AccordionContent> |
| 84 | + </AccordionItem> |
| 85 | + </Accordion> |
| 86 | + </> |
147 | 87 | )
|
148 | 88 | }
|
149 | 89 |
|
|
0 commit comments