1
1
import React , { useState } from "react"
2
- import { Box , Flex , GridItem , SimpleGrid } from "@chakra-ui/react"
3
2
4
3
import { cn } from "@/lib/utils/cn"
5
4
import { MatomoEventOptions , trackCustomEvent } from "@/lib/utils/matomo"
6
5
6
+ import { Flex } from "./ui/flex"
7
7
import Emoji from "./Emoji"
8
- import OldHeading from "./OldHeading"
9
- import Text from "./OldText"
10
8
11
9
export interface BoxItem {
12
10
emoji : string
@@ -32,54 +30,33 @@ const hashCode = (stringPhrase: string): number => {
32
30
33
31
// Theme variables from Theme.js
34
32
const colors = [
35
- "gridYellow " ,
36
- "gridRed " ,
37
- "gridBlue " ,
38
- "gridGreen " ,
39
- "warning " ,
40
- "gridPink " ,
41
- "gridPurple " ,
33
+ "bg-[#ffe78e] " ,
34
+ "bg-[#ef7d7d] " ,
35
+ "bg-[#a7d0f4] " ,
36
+ "bg-[#6fc4a0] " ,
37
+ "bg-[#ffe3d3] " ,
38
+ "bg-[#ffa1c3] " ,
39
+ "bg-[#a4a4ff] " ,
42
40
]
43
41
44
42
const BoxGrid = ( { items } : BoxGridProps ) => {
45
43
const [ indexOpen , setOpenIndex ] = useState ( 0 )
46
44
47
45
return (
48
- < SimpleGrid columns = { { base : 1 , lg : 4 } } my = { 16 } borderRadius = "sm ">
46
+ < div className = "my-16 grid grid-cols-1 rounded-sm lg:grid-cols-4 ">
49
47
{ items . map ( ( item , idx : number ) => {
50
- let columnNumber = idx + 1
51
- if ( columnNumber > 4 ) {
52
- columnNumber = columnNumber - 3
53
- }
54
48
const colorIdx = hashCode ( item . emoji ) % colors . length
55
49
const color = colors [ colorIdx ]
56
50
const isOpen = idx === indexOpen
57
51
58
52
return (
59
- < GridItem
60
- as = { Flex }
61
- rowStart = { { ...( isOpen && { lg : 1 } ) } }
62
- rowEnd = { { ...( isOpen && { lg : 3 } ) } }
63
- colStart = { { ...( isOpen && { lg : columnNumber } ) } }
64
- color = { isOpen ? "black300" : "text" }
65
- cursor = "pointer"
66
- bg = { isOpen ? color : "background.base" }
67
- direction = { {
68
- base : isOpen ? "column" : "column-reverse" ,
69
- sm : isOpen ? "column" : "row-reverse" ,
70
- lg : isOpen ? "column" : "column-reverse" ,
71
- } }
72
- align = { { base : "center" , lg : "stretch" } }
73
- justify = "space-between"
74
- border = "1px solid"
75
- borderColor = "text"
76
- p = { 6 }
77
- _hover = { {
78
- bg : isOpen ? color : "ednBackground" ,
79
- transition : "transform 0.5s" ,
80
- transform : "skewX(-5deg)" ,
81
- boxShadow : "tableBoxShadow" ,
82
- } }
53
+ < Flex
54
+ className = { cn (
55
+ "cursor-pointer items-center justify-between border border-body p-6 transition-transform duration-500 hover:-skew-x-6 hover:shadow-table-box-hover lg:items-stretch" ,
56
+ isOpen
57
+ ? `flex-col text-gray-600 sm:flex-col lg:row-start-1 lg:row-end-3 lg:flex-col ${ color } `
58
+ : "flex-col-reverse bg-background text-body hover:bg-background-highlight sm:flex-row-reverse lg:flex-col-reverse"
59
+ ) }
83
60
onClick = { ( ) => {
84
61
setOpenIndex ( idx )
85
62
trackCustomEvent ( {
@@ -99,26 +76,20 @@ const BoxGrid = ({ items }: BoxGridProps) => {
99
76
) }
100
77
text = { item . emoji }
101
78
/>
102
- < Box >
103
- < OldHeading
104
- as = "h3"
105
- fontSize = "2.5rem"
106
- fontWeight = "normal"
107
- mt = { 0 }
108
- lineHeight = { 1.4 }
109
- >
79
+ < div >
80
+ < h3 className = "mb-8 mt-0 text-[2.5rem] font-normal leading-xs" >
110
81
{ item . title }
111
- </ OldHeading >
82
+ </ h3 >
112
83
{ isOpen && (
113
- < Text fontSize = "xl" lineHeight = { 1.4 } color = "black300 ">
84
+ < p className = "mb-6 text-xl leading-xs text-gray-600 ">
114
85
{ item . description }
115
- </ Text >
86
+ </ p >
116
87
) }
117
- </ Box >
118
- </ GridItem >
88
+ </ div >
89
+ </ Flex >
119
90
)
120
91
} ) }
121
- </ SimpleGrid >
92
+ </ div >
122
93
)
123
94
}
124
95
0 commit comments