Blocks

Testimonial 37

card
4 ColumnsText Align CenterStar RatingCardsLogosTestimonial Section
Testimonial 37

Code

relume-testimonial37.tsx
import clsx from "clsx";
import { Card } from "@/components/ui/card";
import { StarFull } from "relume-icons";

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

type LogoCardProps = {
  logo: ImageProps;
};

type QuoteCardProps = {
  numberOfStars: number;
  quote: string;
  image: ImageProps;
  name: string;
  position: string;
  companyName: string;
};

type Props = {
  heading: string;
  description: string;
  testimonialCards: (
    | { component: "logo"; props: LogoCardProps }
    | { component: "quote"; props: QuoteCardProps }
  )[];
};

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

export const Testimonial37 = (props: Testimonial37Props) => {
  const { heading, description, testimonialCards } = {
    ...Testimonial37Defaults,
    ...props,
  };

  return (
    <section className="px-[5%] py-16 md:py-24 lg:py-28">
      <div className="container">
        <div className="mb-12 md:mb-18 lg:mb-20">
          <div className="mx-auto w-full max-w-lg text-center">
            <h1 className="mb-5 text-h2 font-bold md:mb-6">{heading}</h1>
            <p className="text-medium">{description}</p>
          </div>
        </div>
        <div className="gid-cols-1 grid gap-6 sm:grid-rows-4 md:grid-cols-2 md:gap-8 lg:grid-cols-4 lg:grid-rows-2">
          {testimonialCards.map((card, index) =>
            card.component === "logo" ? (
              <LogoCard key={index} {...card.props} />
            ) : (
              <QuoteCard
                key={index}
                {...card.props}
                className={clsx({
                  "order-last lg:order-none": index === 2,
                })}
              />
            ),
          )}
        </div>
      </div>
    </section>
  );
};

const LogoCard = ({ logo }: LogoCardProps) => (
  <Card className="flex items-center justify-center p-6 md:p-8 lg:p-6">
    <img src={logo.src} alt={logo.alt} className="max-h-12" />
  </Card>
);

const QuoteCard = ({
  numberOfStars,
  quote,
  image,
  name,
  position,
  companyName,
  className,
}: QuoteCardProps & { className?: string }) => (
  <Card
    className={clsx(
      "flex flex-col items-start justify-between p-6 sm:col-span-2 md:p-8",
      className,
    )}
  >
    <div className="mb-5 flex gap-1 md:mb-6">
      {Array(numberOfStars)
        .fill(null)
        .map((_, index) => (
          <StarFull key={index} className="size-6 text-scheme-text" />
        ))}
    </div>
    <h5 className="text-medium">{quote}</h5>
    <div className="mt-5 flex w-full flex-col items-start md:mt-6 md:w-fit md:flex-row md:items-center">
      <div>
        <img src={image.src} alt={image.alt} className="size-full object-cover" />
      </div>
      <div>
        <p className="font-semibold">{name}</p>
        <p>
          <span>{position}</span>, <span>{companyName}</span>
        </p>
      </div>
    </div>
  </Card>
);

export const Testimonial37Defaults: Props = {
  heading: "Customer testimonials",
  description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
  testimonialCards: [
    {
      component: "logo",
      props: {
        logo: {
          src: "https://d22po4pjz3o32e.cloudfront.net/relume-logo.svg",
          alt: "Relume logo 1",
        },
      },
    },
    {
      component: "logo",
      props: {
        logo: {
          src: "https://d22po4pjz3o32e.cloudfront.net/webflow-logo.svg",
          alt: "Webflow logo 1",
        },
      },
    },
    {
      component: "quote",
      props: {
        numberOfStars: 5,
        quote:
          '"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare."',
        image: {
          src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image.svg",
          alt: "Testimonial image 1",
        },
        name: "Name Surname",
        position: "Position",
        companyName: "Company name",
      },
    },
    {
      component: "quote",
      props: {
        numberOfStars: 5,
        quote:
          '"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare."',
        image: {
          src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image.svg",
          alt: "Testimonial image 2",
        },
        name: "Name Surname",
        position: "Position",
        companyName: "Company name",
      },
    },
    {
      component: "logo",
      props: {
        logo: {
          src: "https://d22po4pjz3o32e.cloudfront.net/relume-logo.svg",
          alt: "Relume logo 2",
        },
      },
    },
    {
      component: "logo",
      props: {
        logo: {
          src: "https://d22po4pjz3o32e.cloudfront.net/webflow-logo.svg",
          alt: "Webflow logo 2",
        },
      },
    },
  ],
};

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