Blocks

CTA 59

edge_to_edge
2 ColumnsImage/Video RightText Align LeftImage
CTA 59

Code

relume-cta59.tsx
"use client";

import { useState } from "react";
import { Button, type ButtonProps } from "@/components/ui/button";

type ImageProps = {
  src: string;
  alt?: string;
};

type Props = {
  heading: string;
  description: string;
  buttons: ButtonProps[];
  image: ImageProps;
};

export type Cta59Props = React.ComponentPropsWithoutRef<"section"> & Partial<Props>;

export const Cta59 = (props: Cta59Props) => {
  const { heading, description, buttons, image } = {
    ...Cta59Defaults,
    ...props,
  };

  const [emailInput, setEmailInput] = useState<string>("");
  const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
    event.preventDefault();
    console.log({
      emailInput,
    });
  };

  return (
    <section>
      <div className="grid auto-cols-fr grid-cols-1 items-center lg:grid-cols-2">
        <div className="justify-self-end py-16 md:py-24 lg:py-28">
          <div className="mx-[5%] max-w-md lg:mr-20 lg:ml-[5vw]">
            <h2 className="mb-5 text-h2 font-bold md:mb-6">{heading}</h2>
            <p className="text-medium">{description}</p>
            <div className="mt-6 flex flex-wrap gap-4 md:mt-8">
              {buttons.map((button, index) => (
                <Button key={index} {...button}>
                  {button.title}
                </Button>
              ))}
            </div>
          </div>
        </div>
        <div className="relative size-full overflow-hidden">
          <img
            src={image.src}
            className="static inset-0 size-full object-cover lg:absolute"
            alt={image.alt}
          />
        </div>
      </div>
    </section>
  );
};

export const Cta59Defaults: Props = {
  heading: "Medium length section heading goes here",
  description:
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.",
  buttons: [
    {
      title: "Button",
    },
    {
      title: "Button",
      variant: "secondary",
    },
  ],
  image: {
    src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image.svg",
    alt: "Relume placeholder image",
  },
};

npm i @radix-ui/react-checkbox @radix-ui/react-label @radix-ui/react-slot class-variance-authority@0.7.1 clsx@^2.1.1 embla-carousel-react@^8.5.2 motion@^12.15.0 relume-icons@1.3.0 tailwind-merge@^2.2.2