Skip to content

Commit f2c8ca6

Browse files
authored
Merge pull request #13666 from saurabhburade/shadcn-migrate/BannerGrid
Shadcn migration - BannerGrid
2 parents 6ec62c3 + 9ca4ac2 commit f2c8ca6

File tree

3 files changed

+37
-88
lines changed

3 files changed

+37
-88
lines changed

src/components/BannerGrid/index.tsx

Lines changed: 22 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,51 @@
11
import React from "react"
2-
import { Box, Flex, Grid, useToken } from "@chakra-ui/react"
32

43
import { ChildOnlyProp } from "@/lib/types"
54

5+
import { Flex } from "@/components/ui/flex"
6+
7+
import { cn } from "@/lib/utils/cn"
8+
69
export const Banner = ({ children }: ChildOnlyProp) => {
710
return (
8-
<Flex
9-
w="full"
10-
background="bannerGridGradient"
11-
direction={{ base: "column", lg: "row" }}
12-
wrap="nowrap"
13-
sx={{
14-
h2: {
15-
mt: 0,
16-
},
17-
ul: {
18-
mb: 0,
19-
},
20-
}}
21-
>
11+
<Flex className="w-full flex-col flex-nowrap bg-banner-grid-gradient lg:flex-row [&_h2]:mt-0 [&_ul]:mb-0">
2212
{children}
2313
</Flex>
2414
)
2515
}
2616

2717
export const BannerBody = ({ children }: ChildOnlyProp) => {
28-
return (
29-
<Box flex={4} p={10}>
30-
{children}
31-
</Box>
32-
)
18+
return <div className="w-full flex-[4] p-10">{children}</div>
3319
}
3420

3521
export const BannerImage = ({ children }: ChildOnlyProp) => {
36-
return (
37-
<Flex justifyContent="end" flex={2} alignSelf="end">
38-
{children}
39-
</Flex>
40-
)
22+
return <Flex className="flex-[2] justify-end self-end">{children}</Flex>
4123
}
4224

4325
export const BannerGrid = ({ children }: ChildOnlyProp) => {
4426
return (
45-
<Grid
46-
templateColumns={{
47-
base: "repeat(1,1fr)",
48-
md: "repeat(2,1fr)",
49-
lg: "repeat(3,1fr)",
50-
}}
51-
templateRows={{
52-
md: "repeat(3, 1fr)",
53-
lg: "repeat(2, 1fr)",
54-
}}
55-
columnGap={0}
56-
rowGap={0}
57-
>
27+
<div className="md:grid-rows-[repeat(3, 1fr)] lg:grid-rows-[repeat(2, 1fr)] grid w-full grid-cols-[repeat(1,1fr)] gap-0 md:grid-cols-[repeat(2,1fr)] lg:grid-cols-[repeat(3,1fr)]">
5828
{children}
59-
</Grid>
29+
</div>
6030
)
6131
}
6232

6333
export const BannerGridCell = ({ children }: ChildOnlyProp) => {
64-
const [medBp, lgBp] = useToken("breakpoints", ["md", "lg"])
65-
6634
return (
6735
<Flex
68-
px={{ base: 0, md: 12 }}
69-
py={8}
70-
direction="column"
71-
borderTop="1px solid"
72-
borderTopColor="searchBackground"
73-
borderInlineStart={{ base: 0, md: "1px solid" }}
74-
borderInlineStartColor={{ md: "searchBackground" }}
75-
sx={{
76-
"&:first-child": {
77-
borderTop: 0,
78-
},
79-
[`@media (min-width: ${medBp})`]: {
80-
"&:nth-child(-n + 2)": {
81-
borderTop: 0,
82-
},
83-
"&:nth-child(2n + 1)": {
84-
borderInlineStart: 0,
85-
},
86-
},
87-
[`@media (min-width: ${lgBp})`]: {
88-
"&:first-child": {
89-
ps: 0,
90-
borderInlineStart: 0,
91-
},
92-
"&:nth-child(-n + 2)": {
93-
borderTop: "1px solid",
94-
borderTopColor: "searchBackground",
95-
},
96-
"&:nth-child(2n + 1)": {
97-
borderInlineStart: "1px solid",
98-
borderInlineStartColor: "searchBackground",
99-
},
100-
"&:nth-child(-n + 3)": {
101-
borderTop: 0,
102-
justifyContent: "start",
103-
paddingTop: 0,
104-
},
105-
"&:nth-child(3n + 1)": {
106-
ps: 0,
107-
borderInlineStart: 0,
108-
},
109-
"&:nth-child(n + 4)": {
110-
justifyContent: "start",
111-
paddingBottom: 0,
112-
},
113-
},
114-
}}
36+
className={cn(
37+
"px-0 py-8 md:px-12",
38+
"flex-col",
39+
"border-t border-t-search-background",
40+
"md:border-s md:border-s-search-background",
41+
"first:border-t-0",
42+
"lg:[&:first-child]:border-s-0",
43+
"md:[&:nth-child(-n+2)]:border-t-0 lg:[&:nth-child(-n+2)]:border-t lg:[&:nth-child(-n+2)]:border-t-search-background",
44+
"md:[&:nth-child(2n+1)]:border-s-0 lg:[&:nth-child(2n+1)]:border-s lg:[&:nth-child(2n+1)]:border-s-search-background",
45+
"lg:[&:nth-child(-n+3)]:justify-start lg:[&:nth-child(-n+3)]:border-t-0 lg:[&:nth-child(-n+3)]:pt-0",
46+
"lg:[&:nth-child(3n+1)]:border-s-0 lg:[&:nth-child(3n+1)]:ps-0",
47+
"lg:[&:nth-child(n+4)]:justify-start lg:[&:nth-child(n+4)]:pb-0"
48+
)}
11549
>
11650
{children}
11751
</Flex>

src/styles/global.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@
120120
--table-box-shadow: 0 14px 66px rgba(0, 0, 0, 0.07),
121121
0 10px 17px rgba(0, 0, 0, 0.03), 0 4px 7px rgba(0, 0, 0, 0.05);
122122
--table-item-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
123+
--banner-grid-gradient: linear-gradient(
124+
90deg,
125+
rgba(127, 127, 213, 0.2) 0%,
126+
rgba(132, 145, 221, 0.2) 50%,
127+
rgba(145, 234, 228, 0.2) 100%
128+
);
129+
--search-background: var(--background);
123130
}
124131

125132
[data-theme="dark"] {
@@ -180,6 +187,12 @@
180187
--table-box-shadow: 0 14px 66px hsla(0, 0%, 96.1%, 0.07),
181188
0 10px 17px hsla(0, 0%, 96.1%, 0.03), 0 4px 7px hsla(0, 0%, 96.1%, 0.05);
182189
--table-item-box-shadow: 0 1px 1px hsla(0, 0%, 100%, 0.1);
190+
--banner-grid-gradient: linear-gradient(
191+
90deg,
192+
rgba(172, 182, 229, 0.08) 0%,
193+
rgba(134, 253, 232, 0.08) 100%
194+
);
195+
--search-background: #4c4c4c;
183196
}
184197
}
185198

tailwind.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ const config = {
127127
"tooltip-shadow": "var(--tooltip-shadow)",
128128
"switch-background": "var(--switch-background)",
129129
"hub-hero-content-bg": "var(--hub-hero-content-bg)",
130+
"search-background": "var(--search-background)",
130131
attention: {
131132
DEFAULT: "var(--attention)",
132133
light: "var(--attention-light)",
@@ -148,6 +149,7 @@ const config = {
148149
backgroundImage: {
149150
"main-gradient": "var(--main-gradient)",
150151
"feedback-gradient": "var(--feedback-gradient)",
152+
"banner-grid-gradient": "var(--banner-grid-gradient)",
151153
},
152154
boxShadow: {
153155
"table-box": "var(--table-box-shadow)",

0 commit comments

Comments
 (0)