Files
supabase/apps/www/components/Solutions/CtaSection.tsx
Gildas GarciaandIvan Vasilov 96d43099bb chore: refactor Button API so that it can be used a standard button (#46880)
## Problem

Our `<Button>` component breaks the default `button` contract by
redefining the `type` prop to set its variant (`primary`, `default`,
etc) instead of the button type (`submit`, `button`, etc).
This is confusing and forces to write more code when using it with
shadcn components that expect/inject the standard button props.

## Solution

- rename the `type` prop to `variant`
- rename the `htmlType` prop to `type`
- propagate the changes where necessary
- format code

## How to test

As this is just prop renaming, if it builds it's ok

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-06-16 23:59:58 +02:00

66 lines
1.7 KiB
TypeScript

import Link from 'next/link'
import React from 'react'
import { Button, cn } from 'ui'
import SectionContainer from '@/components/Layouts/SectionContainer'
export interface CtaSectionProps {
id: string
title: string | React.ReactNode
subtitle?: string
primaryCta: {
label: string
url: string
target?: string
icon?: React.ReactNode
}
secondaryCta?: {
label: string
url: string
}
image?: {
dark: string
light: string
}
className?: string
}
const CtaSection = ({
id,
title,
subtitle,
primaryCta,
secondaryCta,
className,
}: CtaSectionProps) => {
return (
<SectionContainer
id={id}
className={cn('py-16 md:py-24 lg:py-32 relative overflow-hidden', className)}
>
<div className="mx-auto relative z-10">
<div className="flex flex-col gap-6 text-center items-center max-w-5xl mx-auto">
<h2 className="text-foreground-light text-2xl lg:text-3xl leading-tight">{title}</h2>
{subtitle && <p className="text-foreground-light text-lg">{subtitle}</p>}
<div className="flex flex-wrap gap-3 pt-4">
<Button asChild size="medium" icon={primaryCta.icon}>
<Link href={primaryCta.url} target={primaryCta.target}>
{primaryCta.label}
</Link>
</Button>
{secondaryCta && (
<Button asChild size="medium" variant="default">
<Link href={secondaryCta.url}>{secondaryCta.label}</Link>
</Button>
)}
</div>
</div>
</div>
<div className="absolute inset-0 w-full h-full bg-linear-to-r from-transparent via-transparent to-background opacity-80 z-0"></div>
</SectionContainer>
)
}
export default CtaSection