Skip to content

Commit 63d8c4f

Browse files
committed
refactor grid media queries
1 parent a54f883 commit 63d8c4f

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

src/components/BannerGrid/index.tsx

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Flex, Grid } from "@chakra-ui/react"
1+
import { Box, Flex, Grid, useToken } from "@chakra-ui/react"
22
import React from "react"
33

44
export type Props = {
@@ -63,56 +63,52 @@ export const BannerGrid: React.FC<Props> = ({ children }) => {
6363
}
6464

6565
export const BannerGridCell: React.FC<Props> = ({ children }) => {
66+
const [medBp, lgBp] = useToken("breakpoints", ["md", "lg"])
67+
6668
return (
6769
<Flex
6870
px={12}
6971
py={8}
7072
direction="column"
7173
borderTop="1px solid"
7274
borderTopColor="searchBackground"
73-
borderLeft={{ base: "none", md: "1px solid" }}
75+
borderLeft={{ base: 0, md: "1px solid" }}
7476
borderLeftColor={{ md: "searchBackground" }}
7577
sx={{
7678
"&:first-child": {
77-
borderTop: "none",
78-
lg: {
79-
paddingLeft: 0,
80-
borderLeft: "none",
79+
borderTop: 0,
80+
},
81+
[`@media (min-width: ${medBp})`]: {
82+
"&:nth-child(-n + 2)": {
83+
borderTop: 0,
84+
},
85+
"&:nth-child(2n + 1)": {
86+
borderLeft: 0,
8187
},
8288
},
83-
"&:nth-child(-n + 2)": {
84-
md: {
85-
borderTop: "none",
89+
[`@media (min-width: ${lgBp})`]: {
90+
"&:first-child": {
91+
paddingLeft: 0,
92+
borderLeft: 0,
8693
},
87-
lg: {
94+
"&:nth-child(-n + 2)": {
8895
borderTop: "1px solid",
8996
borderTopColor: "searchBackground",
9097
},
91-
},
92-
"&:nth-child(2n + 1)": {
93-
md: {
94-
borderLeft: "none",
95-
},
96-
lg: {
98+
"&:nth-child(2n + 1)": {
9799
borderLeft: "1px solid",
98100
borderLeftColor: "searchBackground",
99101
},
100-
},
101-
"&:nth-child(-n + 3)": {
102-
lg: {
103-
borderTop: "none",
102+
"&:nth-child(-n + 3)": {
103+
borderTop: 0,
104104
justifyContent: "start",
105105
paddingTop: 0,
106106
},
107-
},
108-
"&:nth-child(3n + 1)": {
109-
lg: {
107+
"&:nth-child(3n + 1)": {
110108
paddingLeft: 0,
111-
borderLeft: "none",
109+
borderLeft: 0,
112110
},
113-
},
114-
"&:nth-child(n + 4)": {
115-
lg: {
111+
"&:nth-child(n + 4)": {
116112
justifyContent: "start",
117113
paddingBottom: 0,
118114
},

0 commit comments

Comments
 (0)