Blocks

CTA 60

edge_to_edge
2 ColumnsImage/Video RightText Align LeftImage
CTA 60

Code

relume-cta60.tsx
"use client";

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

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

type Props = {
  heading: string;
  description: string;
  inputPlaceholder?: string;
  button: ButtonProps;
  termsAndConditions: string;
  image: ImageProps;
};

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

export const Cta60 = (props: Cta60Props) => {
  const { heading, description, inputPlaceholder, button, termsAndConditions, image } = {
    ...Cta60Defaults,
    ...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 w-full max-w-sm md:mt-8">
              <form
                className="mb-4 grid w-full max-w-sm grid-cols-1 gap-y-3 sm:grid-cols-[1fr_max-content] sm:gap-4"
                onSubmit={handleSubmit}
              >
                <Input
                  id="email"
                  type="email"
                  placeholder={inputPlaceholder}
                  value={emailInput}
                  onChange={(e) => setEmailInput(e.target.value)}
                />
                <Button {...button} className="items-center justify-center px-6 py-3">
                  {button.title}
                </Button>
              </form>
              <div dangerouslySetInnerHTML={{ __html: termsAndConditions }} />
            </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 Cta60Defaults: Props = {
  heading: "Medium length section heading goes here",
  description:
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.",
  inputPlaceholder: "Enter your email",
  button: {
    title: "Sign up",
    size: "sm",
  },
  termsAndConditions: `
    <p class='text-tiny'>
      By clicking Sign Up you're confirming that you agree with our
      <a href='#' class='underline'>Terms and Conditions</a>.
    </p>
    `,
  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-radio-group @radix-ui/react-select @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