Skip to content

Commit 18db710

Browse files
committed
feat: migrate PageHero to tailwind
1 parent 9e4a8c9 commit 18db710

File tree

3 files changed

+69
-81
lines changed

3 files changed

+69
-81
lines changed

src/components/PageHero.tsx

Lines changed: 60 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import type { ReactNode } from "react"
2-
import { Box, Center, Flex, Heading, Wrap, WrapItem } from "@chakra-ui/react"
2+
3+
import { type ImageProps, TwImage } from "@/components/Image"
4+
5+
import { cn } from "@/lib/utils/cn"
6+
import { type MatomoEventOptions } from "@/lib/utils/matomo"
37

48
import {
59
Button,
610
ButtonLink,
7-
type ButtonLinkProps,
8-
type ButtonProps,
9-
} from "@/components/Buttons"
10-
import { Image, type ImageProps } from "@/components/Image"
11-
import Text from "@/components/OldText"
12-
13-
import { type MatomoEventOptions, trackCustomEvent } from "@/lib/utils/matomo"
11+
ButtonLinkProps,
12+
ButtonProps,
13+
} from "./ui/buttons/Button"
14+
import { Center, Flex } from "./ui/flex"
1415

1516
type ButtonLinkType = Omit<ButtonLinkProps, "content"> & {
1617
content: ReactNode
@@ -48,113 +49,93 @@ const PageHero = ({
4849
children,
4950
className,
5051
}: PageHeroProps) => (
51-
<Box py={4} px={8} width="full">
52+
<div className="w-full px-8 py-4">
5253
<Flex
53-
justifyContent="space-between"
54-
mt={8}
55-
px={{ base: 0, lg: 16 }}
56-
direction={{ base: isReverse ? "column" : "column-reverse", lg: "row" }}
57-
className={className}
54+
className={cn(
55+
"mt-8 justify-between px-0 lg:px-16",
56+
isReverse ? "flex-col" : "flex-col-reverse",
57+
"lg:flex-row",
58+
className
59+
)}
5860
>
59-
<Box
60-
maxW={{ base: "full", lg: "container.sm" }}
61-
pt={{ base: isReverse ? 0 : 8, lg: 32 }}
62-
pb={{ base: isReverse ? 8 : 0, lg: 32 }}
63-
ps={{ base: 0, lg: 8 }}
64-
me={{ base: 0, lg: 4 }}
61+
<div
62+
// TODO: container.sm width unavailable
63+
className={cn(
64+
"max-w-full lg:max-w-[640px]",
65+
66+
isReverse ? "pb-8 pt-0" : "pb-0 pt-8",
67+
"lg:py-32",
68+
"ps-0 lg:ps-8",
69+
"me-0 lg:me-4"
70+
)}
6571
>
66-
<Heading
67-
as="h1"
68-
textTransform="uppercase"
69-
fontSize="md"
70-
fontWeight="normal"
71-
mt={{ base: 0, lg: 8 }}
72-
mb={4}
73-
color="text300"
74-
lineHeight={1.4}
75-
>
72+
<h1 className="mb-4 mt-0 text-md font-normal uppercase !leading-[1.4] text-text-300 lg:mt-8">
7673
{title}
77-
</Heading>
78-
<Heading
79-
as="h2"
80-
fontWeight="bold"
81-
fontSize={{ base: "2.5rem", lg: "5xl" }}
82-
maxW="full"
83-
mb={0}
84-
mt={{ base: 8, lg: 12 }}
85-
color="text00"
86-
lineHeight={1.4}
87-
>
74+
</h1>
75+
76+
<h2 className="mb-0 mt-8 max-w-full text-[2.5rem] font-bold !leading-[1.4] lg:mt-12 lg:text-5xl">
8877
{header}
89-
</Heading>
90-
<Text
91-
fontSize={{ base: "xl", lg: "2xl" }}
92-
lineHeight={1.4}
93-
color="text200"
94-
mt={4}
95-
mb={8}
96-
>
78+
</h2>
79+
<p className="mb-8 mt-4 text-xl !leading-[1.4] text-text-200 lg:text-2xl">
9780
{subtitle}
98-
</Text>
81+
</p>
82+
9983
{buttons && (
100-
<Wrap spacing={2} overflow="visible" sx={{ ul: { m: 0 } }}>
84+
<Flex className="gap-2 overflow-visible [&_ul]:m-0">
10185
{buttons.map((button, idx) => {
10286
const isSecondary = idx !== 0
10387
if (isButtonLink(button)) {
10488
return (
105-
<WrapItem key={idx}>
89+
<div key={idx}>
10690
<ButtonLink
10791
variant={button.variant}
10892
href={button.href}
109-
onClick={() =>
110-
trackCustomEvent({
111-
eventCategory: button.matomo.eventCategory,
112-
eventAction: button.matomo.eventAction,
113-
eventName: button.matomo.eventName,
114-
})
115-
}
93+
customEventOptions={{
94+
eventCategory: button.matomo.eventCategory,
95+
eventAction: button.matomo.eventAction,
96+
eventName: button.matomo.eventName,
97+
}}
11698
isSecondary={isSecondary}
11799
>
118100
{button.content}
119101
</ButtonLink>
120-
</WrapItem>
102+
</div>
121103
)
122104
}
123105

124106
if (button.toId) {
125107
return (
126-
<WrapItem key={idx}>
108+
<div key={idx}>
127109
<Button
128110
variant={button.variant}
129111
toId={button.toId}
130-
onClick={() =>
131-
trackCustomEvent({
132-
eventCategory: button.matomo.eventCategory,
133-
eventAction: button.matomo.eventAction,
134-
eventName: button.matomo.eventName,
135-
})
136-
}
112+
customEventOptions={{
113+
eventCategory: button.matomo.eventCategory,
114+
eventAction: button.matomo.eventAction,
115+
eventName: button.matomo.eventName,
116+
}}
137117
isSecondary={isSecondary}
138118
>
139119
{button.content}
140120
</Button>
141-
</WrapItem>
121+
</div>
142122
)
143123
}
144124
})}
145-
</Wrap>
125+
</Flex>
146126
)}
147127
{children}
148-
</Box>
128+
</div>
149129
<Center
150-
flex="1 1 50%"
151-
maxWidth={{ base: "560px", lg: "624px" }}
152-
mt={{ base: 0, lg: 12 }}
153-
ms={{ base: 0, lg: 12 }}
154-
w="full"
155-
alignSelf="center"
130+
className={cn(
131+
"flex-[1_1_50%]",
132+
"max-w-[560px] lg:max-w-[624px]",
133+
"mt-0 lg:mt-12",
134+
"ms-0 lg:ms-12",
135+
"w-full self-center"
136+
)}
156137
>
157-
<Image
138+
<TwImage
158139
src={image}
159140
// TODO: adjust value when the old theme breakpoints are removed (src/theme.ts)
160141
sizes="(max-width: 992px) 100vw, 624px"
@@ -168,7 +149,7 @@ const PageHero = ({
168149
/>
169150
</Center>
170151
</Flex>
171-
</Box>
152+
</div>
172153
)
173154

174155
export default PageHero

src/styles/global.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
rgba(145, 234, 228, 0.2) 100%
128128
);
129129
--search-background: var(--background);
130+
--text-200: #666666;
131+
--text-300: #4c4c4c;
130132
}
131133

132134
[data-theme="dark"] {
@@ -195,6 +197,8 @@
195197
rgba(134, 253, 232, 0.08) 100%
196198
);
197199
--search-background: #4c4c4c;
200+
--text-200: #b2b2b2;
201+
--text-300: #cccccc;
198202
}
199203
}
200204

@@ -204,7 +208,7 @@
204208
}
205209

206210
a {
207-
@apply underline-offset-3 text-primary underline hover:text-primary-hover focus-visible:rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-hover;
211+
@apply text-primary underline underline-offset-3 hover:text-primary-hover focus-visible:rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-hover;
208212
}
209213

210214
h1,

tailwind.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ const config = {
102102
800: "var(--orange-800)",
103103
900: "var(--orange-900)",
104104
},
105-
105+
text: {
106+
200: "var(--text-200)",
107+
300: "var(--text-300)",
108+
},
106109
primary: {
107110
DEFAULT: "var(--primary)",
108111
"high-contrast": "var(--primary-high-contrast)",

0 commit comments

Comments
 (0)