Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadcn migration - BannerGrid #13666

Merged
merged 6 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 22 additions & 88 deletions src/components/BannerGrid/index.tsx
Original file line number Diff line number Diff line change
@@ -1,117 +1,51 @@
import React from "react"
import { Box, Flex, Grid, useToken } from "@chakra-ui/react"

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

import { Flex } from "@/components/ui/flex"

import { cn } from "@/lib/utils/cn"

export const Banner = ({ children }: ChildOnlyProp) => {
return (
<Flex
w="full"
background="bannerGridGradient"
direction={{ base: "column", lg: "row" }}
wrap="nowrap"
sx={{
h2: {
mt: 0,
},
ul: {
mb: 0,
},
}}
>
<Flex className="w-full flex-col flex-nowrap bg-banner-grid-gradient lg:flex-row [&_h2]:mt-0 [&_ul]:mb-0">
{children}
</Flex>
)
}

export const BannerBody = ({ children }: ChildOnlyProp) => {
return (
<Box flex={4} p={10}>
{children}
</Box>
)
return <div className="w-full flex-[4] p-10">{children}</div>
}

export const BannerImage = ({ children }: ChildOnlyProp) => {
return (
<Flex justifyContent="end" flex={2} alignSelf="end">
{children}
</Flex>
)
return <Flex className="flex-[2] justify-end self-end">{children}</Flex>
}

export const BannerGrid = ({ children }: ChildOnlyProp) => {
return (
<Grid
templateColumns={{
base: "repeat(1,1fr)",
md: "repeat(2,1fr)",
lg: "repeat(3,1fr)",
}}
templateRows={{
md: "repeat(3, 1fr)",
lg: "repeat(2, 1fr)",
}}
columnGap={0}
rowGap={0}
>
<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)]">
{children}
</Grid>
</div>
)
}

export const BannerGridCell = ({ children }: ChildOnlyProp) => {
const [medBp, lgBp] = useToken("breakpoints", ["md", "lg"])

return (
<Flex
px={{ base: 0, md: 12 }}
py={8}
direction="column"
borderTop="1px solid"
borderTopColor="searchBackground"
borderInlineStart={{ base: 0, md: "1px solid" }}
borderInlineStartColor={{ md: "searchBackground" }}
sx={{
"&:first-child": {
borderTop: 0,
},
[`@media (min-width: ${medBp})`]: {
"&:nth-child(-n + 2)": {
borderTop: 0,
},
"&:nth-child(2n + 1)": {
borderInlineStart: 0,
},
},
[`@media (min-width: ${lgBp})`]: {
"&:first-child": {
ps: 0,
borderInlineStart: 0,
},
"&:nth-child(-n + 2)": {
borderTop: "1px solid",
borderTopColor: "searchBackground",
},
"&:nth-child(2n + 1)": {
borderInlineStart: "1px solid",
borderInlineStartColor: "searchBackground",
},
"&:nth-child(-n + 3)": {
borderTop: 0,
justifyContent: "start",
paddingTop: 0,
},
"&:nth-child(3n + 1)": {
ps: 0,
borderInlineStart: 0,
},
"&:nth-child(n + 4)": {
justifyContent: "start",
paddingBottom: 0,
},
},
}}
className={cn(
"px-0 py-8 md:px-12",
"flex-col",
"border-t border-t-search-background",
"md:border-s md:border-s-search-background",
"first:border-t-0",
"lg:[&:first-child]:border-s-0",
"md:[&:nth-child(-n+2)]:border-t-0 lg:[&:nth-child(-n+2)]:border-t lg:[&:nth-child(-n+2)]:border-t-search-background",
"md:[&:nth-child(2n+1)]:border-s-0 lg:[&:nth-child(2n+1)]:border-s lg:[&:nth-child(2n+1)]:border-s-search-background",
"lg:[&:nth-child(-n+3)]:justify-start lg:[&:nth-child(-n+3)]:border-t-0 lg:[&:nth-child(-n+3)]:pt-0",
"lg:[&:nth-child(3n+1)]:border-s-0 lg:[&:nth-child(3n+1)]:ps-0",
"lg:[&:nth-child(n+4)]:justify-start lg:[&:nth-child(n+4)]:pb-0"
)}
saurabhburade marked this conversation as resolved.
Show resolved Hide resolved
>
{children}
</Flex>
Expand Down
13 changes: 13 additions & 0 deletions src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@
--table-box-shadow: 0 14px 66px rgba(0, 0, 0, 0.07),
0 10px 17px rgba(0, 0, 0, 0.03), 0 4px 7px rgba(0, 0, 0, 0.05);
--table-item-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
--banner-grid-gradient: linear-gradient(
90deg,
rgba(127, 127, 213, 0.2) 0%,
rgba(132, 145, 221, 0.2) 50%,
rgba(145, 234, 228, 0.2) 100%
);
--search-background: var(--background);
}

[data-theme="dark"] {
Expand Down Expand Up @@ -176,6 +183,12 @@
--table-box-shadow: 0 14px 66px hsla(0, 0%, 96.1%, 0.07),
0 10px 17px hsla(0, 0%, 96.1%, 0.03), 0 4px 7px hsla(0, 0%, 96.1%, 0.05);
--table-item-box-shadow: 0 1px 1px hsla(0, 0%, 100%, 0.1);
--banner-grid-gradient: linear-gradient(
90deg,
rgba(172, 182, 229, 0.08) 0%,
rgba(134, 253, 232, 0.08) 100%
);
--search-background: #4c4c4c;
}
}

Expand Down
2 changes: 2 additions & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const config = {
"tooltip-shadow": "var(--tooltip-shadow)",
"switch-background": "var(--switch-background)",
"hub-hero-content-bg": "var(--hub-hero-content-bg)",
"search-background": "var(--search-background)",
attention: {
DEFAULT: "var(--attention)",
light: "var(--attention-light)",
Expand All @@ -148,6 +149,7 @@ const config = {
backgroundImage: {
"main-gradient": "var(--main-gradient)",
"feedback-gradient": "var(--feedback-gradient)",
"banner-grid-gradient": "var(--banner-grid-gradient)",
},
boxShadow: {
"table-box": "var(--table-box-shadow)",
Expand Down
Loading