Skip to content

Commit 816b1d8

Browse files
authored
Merge pull request #12015 from TylerAPfledderer/fix/CallToAction-index-prop
fix(CallToAction): update and constrain prop object type shape
2 parents b116be9 + 50f63e6 commit 816b1d8

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

src/components/Hero/CallToAction.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ import { Button, type ButtonProps } from "@/components/Buttons"
44

55
import { type MatomoEventOptions, trackCustomEvent } from "@/lib/utils/matomo"
66

7-
export type CallToActionProps = Omit<ButtonProps, "children" | "content"> & {
7+
export type CallToActionProps = Omit<
8+
ButtonProps,
9+
"children" | "content" | "variant" | "isSecondary"
10+
> & {
811
content: ReactNode
912
matomo: MatomoEventOptions
13+
index: number
1014
}
1115

12-
export function CallToAction({
16+
export const CallToAction = ({
1317
content,
1418
matomo,
15-
key: index,
19+
index,
1620
...props
17-
}: CallToActionProps) {
21+
}: CallToActionProps) => {
1822
const handleClick = () => trackCustomEvent(matomo)
1923

2024
const buttonProps: ButtonProps = {

src/components/Hero/ContentHero/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const ContentHero = (props: ContentHeroProps) => {
3838
<HStack spacing="4">
3939
{buttons!.map((button, idx) => {
4040
if (!button) return
41-
return <CallToAction key={idx} {...button} />
41+
return <CallToAction key={idx} index={idx} {...button} />
4242
})}
4343
</HStack>
4444
</Stack>

src/components/Hero/HubHero/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ const HubHero = ({
7171
<Text size="lg">{description}</Text>
7272
</Stack>
7373
<HStack justify={{ md: "center", xl: "start" }} spacing="4">
74-
{(buttons || []).map((button, idx) => {
74+
{buttons?.map((button, idx) => {
7575
if (!button) return
76-
return <CallToAction key={idx} {...button} />
76+
return <CallToAction key={idx} index={idx} {...button} />
7777
})}
7878
</HStack>
7979
</Stack>

src/lib/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,14 @@ export type IRemarkTocOptions = {
372372
callback: (toc: TocNodeType) => void
373373
}
374374

375+
type HeroButtonProps = Omit<CallToActionProps, "index">
376+
375377
export type CommonHeroProps = {
376378
heroImg: StaticImageData
377379
header: string
378380
title: string
379381
description: string
380-
buttons?: [CallToActionProps, CallToActionProps?]
382+
buttons?: [HeroButtonProps, HeroButtonProps?]
381383
}
382384

383385
// Learning Tools

src/pages/layer-2.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ const Layer2Page = () => {
137137
{
138138
content: t("layer-2-hero-button-1"),
139139
toId: "what-is-layer-2",
140-
variant: "solid",
141140
matomo: {
142141
eventCategory: "layer 2 hero buttons",
143142
eventAction: "click",
@@ -147,7 +146,6 @@ const Layer2Page = () => {
147146
{
148147
content: t("layer-2-hero-button-2"),
149148
toId: "use-layer-2",
150-
variant: "outline",
151149
matomo: {
152150
eventCategory: "layer 2 hero buttons",
153151
eventAction: "click",

src/pages/learn.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ const LearnPage = () => {
198198
eventAction: "click",
199199
eventName: "lets get started",
200200
},
201-
variant: "solid",
202201
},
203202
],
204203
}

0 commit comments

Comments
 (0)