Skip to content

Commit 67eebaa

Browse files
authored
Merge pull request #13691 from saurabhburade/shadcn-migration/HubHero
Shadcn migration - HubHero
2 parents 7817658 + 652729a commit 67eebaa

File tree

2 files changed

+37
-50
lines changed

2 files changed

+37
-50
lines changed

src/components/Hero/CallToAction.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { ReactNode } from "react"
22

3-
import { Button, type ButtonProps } from "@/components/Buttons"
3+
import { Button, type ButtonProps } from "@/components/ui/buttons/Button"
44

5+
import { cn } from "@/lib/utils/cn"
56
import { type MatomoEventOptions, trackCustomEvent } from "@/lib/utils/matomo"
67

78
export type CallToActionProps = Omit<
@@ -17,14 +18,15 @@ export const CallToAction = ({
1718
content,
1819
matomo,
1920
index,
21+
className,
2022
...props
2123
}: CallToActionProps) => {
2224
const handleClick = () => trackCustomEvent(matomo)
2325

2426
const buttonProps: ButtonProps = {
2527
variant: index === 0 ? "solid" : "outline",
2628
isSecondary: index !== 0,
27-
flex: { base: 1, md: "initial" },
29+
className: cn("flex-[1] md:flex-[initial]", className),
2830
}
2931

3032
return (

src/components/Hero/HubHero/index.tsx

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Box, Heading, Stack, Text } from "@chakra-ui/react"
2-
31
import type { CommonHeroProps } from "@/lib/types"
42

53
import { CallToAction } from "@/components/Hero/CallToAction"
6-
import { Image } from "@/components/Image"
4+
import { TwImage } from "@/components/Image"
5+
import { Stack } from "@/components/ui/flex"
6+
7+
import { cn } from "@/lib/utils/cn"
78

89
export type HubHeroProps = Omit<CommonHeroProps, "breadcrumbs" | "blurDataURL">
910

@@ -21,72 +22,56 @@ const HubHero = ({
2122
}
2223

2324
return (
24-
<Box position="relative">
25-
<Image
25+
<div className="relative">
26+
<TwImage
2627
src={heroImg}
2728
alt=""
2829
priority
2930
// TODO: adjust value when the old theme breakpoints are removed (src/theme.ts)
3031
sizes="(max-width: 1504px) 100vw, 1504px"
3132
style={{ width: "100vw", objectFit: "cover" }}
32-
h={{
33-
base: "192px",
34-
md: "256px",
35-
lg: "320px",
36-
xl: "576px",
37-
"2xl": "672px",
38-
}}
33+
className="h-[192px] w-screen object-cover md:h-[256px] lg:h-[320px] xl:h-[576px] 2xl:h-[672px]"
3934
/>
4035
<Stack
41-
spacing="4"
42-
p={{ base: "4", lg: "8" }}
43-
textAlign={{ base: "center", xl: "start" }}
44-
borderRadius={{ xl: "base" }}
45-
bg={{ xl: "hubHeroContentBg" }}
46-
position={{ xl: "absolute" }}
47-
maxW={{ xl: "sm" }}
48-
top={{ xl: "50%" }}
49-
transform={{ xl: "translateY(-50%)" }}
50-
backdropFilter={{ xl: "auto" }}
51-
backdropBlur={{ xl: "base" }}
52-
wordBreak="break-word"
53-
sx={{
54-
"inset-inline-start": { xl: "32px" },
55-
}}
36+
className={cn(
37+
"gap-4 p-4 lg:p-8",
38+
"text-center xl:text-start",
39+
"xl:rounded",
40+
"xl:bg-hub-hero-content-bg",
41+
"xl:absolute xl:top-1/2 xl:max-w-sm",
42+
"xl:-translate-y-1/2 xl:transform",
43+
"xl:backdrop-blur xl:backdrop-filter",
44+
"break-words",
45+
"xl:start-[32px]"
46+
)}
5647
>
5748
{title ? (
58-
<Text
59-
as="h1"
60-
size="md"
61-
color="body.medium"
62-
fontWeight="normal"
63-
textTransform="uppercase"
64-
>
49+
<h1 className="text-md font-normal uppercase text-body-medium">
6550
{title}
66-
</Text>
51+
</h1>
6752
) : null}
68-
<Stack
69-
alignSelf="center"
70-
spacing={{ base: "2", md: "1" }}
71-
maxW="container.md"
72-
>
73-
<Heading as={title ? "h2" : "h1"} size="2xl">
74-
{header}
75-
</Heading>
76-
<Text size="lg">{description}</Text>
53+
<Stack className="max-w-screen-md gap-2 self-center md:gap-1">
54+
{title ? (
55+
<h2 className="text-4xl lg:text-5xl">{header}</h2>
56+
) : (
57+
<h1 className="text-4xl lg:text-5xl">{header}</h1>
58+
)}
59+
60+
<p className="text-lg">{description}</p>
7761
</Stack>
7862
<Stack
79-
direction={{ base: "column", md: "row" }}
80-
justify={{ md: "center", xl: "start" }}
81-
spacing="4"
63+
className={cn(
64+
"flex-col gap-4 md:flex-row",
65+
"md:justify-center xl:justify-start"
66+
)}
8267
>
8368
{buttons?.map((button, idx) => {
8469
if (!button) return
8570
return <CallToAction key={idx} index={idx} {...button} />
8671
})}
8772
</Stack>
8873
</Stack>
89-
</Box>
74+
</div>
9075
)
9176
}
9277

0 commit comments

Comments
 (0)