| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import { cn } from '@/lib/utils';
- import type { NewsletterSection } from '../types';
- import { Container } from '../ui';
-
- export function Newsletter({ section }: { section: NewsletterSection }) {
- const { heading, body, placeholder, buttonLabel } = section.content;
- const card = section.variant === 'card';
-
- // split: a big heading on one side, the form on the other, in the store's normal colours.
- if (section.variant === 'split') {
- return (
- <section
- id={section.id}
- className="sf-section scroll-mt-20 border-y border-(--sf-border) py-16 md:py-20"
- data-layout="split"
- >
- <Container className="grid gap-8 md:grid-cols-2 md:items-end">
- <div>
- <h2 className="sf-heading text-3xl leading-tight font-semibold text-balance sm:text-4xl">
- {heading}
- </h2>
- {body && (
- <p className="mt-3 max-w-md text-(--sf-muted)">
- {body}
- </p>
- )}
- </div>
- <form
- className="flex w-full gap-2 md:justify-self-end"
- onSubmit={(event) => event.preventDefault()}
- >
- <label
- className="sr-only"
- htmlFor={`${section.id}-email`}
- >
- {placeholder}
- </label>
- <input
- id={`${section.id}-email`}
- type="email"
- placeholder={placeholder}
- className="min-w-0 flex-1 rounded-(--sf-radius) border border-(--sf-border) bg-(--sf-bg) px-4 py-3 text-sm placeholder:text-(--sf-muted) focus-visible:outline-2 focus-visible:outline-(--sf-primary)"
- />
- <button
- type="submit"
- className="sf-btn-primary rounded-(--sf-radius) bg-(--sf-primary) px-5 py-3 text-sm font-semibold text-(--sf-primary-fg) transition-opacity hover:opacity-90"
- >
- {buttonLabel}
- </button>
- </form>
- </Container>
- </section>
- );
- }
-
- return (
- <section
- id={section.id}
- className={cn(
- 'scroll-mt-20',
- card
- ? 'sf-section py-16'
- : 'bg-(--sf-primary) text-(--sf-primary-fg)',
- )}
- >
- <Container
- className={cn(
- 'flex flex-col gap-6 md:flex-row md:items-center md:justify-between',
- card
- ? 'max-w-4xl rounded-(--sf-radius-card) bg-(--sf-primary) p-8 text-(--sf-primary-fg) sm:p-10'
- : 'py-12',
- )}
- >
- <div className="max-w-md">
- <h2 className="sf-heading text-2xl font-semibold sm:text-3xl">
- {heading}
- </h2>
- {body && <p className="mt-2 opacity-85">{body}</p>}
- </div>
-
- {/* Sign-ups are not saved yet. That arrives with the commerce step. */}
- <form
- className="flex w-full max-w-md gap-2"
- onSubmit={(event) => event.preventDefault()}
- >
- <label className="sr-only" htmlFor={`${section.id}-email`}>
- {placeholder}
- </label>
- <input
- id={`${section.id}-email`}
- type="email"
- placeholder={placeholder}
- className="min-w-0 flex-1 rounded-(--sf-radius) border border-(--sf-primary-fg)/30 bg-(--sf-primary-fg)/10 px-4 py-2.5 text-sm placeholder:text-(--sf-primary-fg)/65 focus-visible:outline-2 focus-visible:outline-(--sf-primary-fg)"
- />
- <button
- type="submit"
- className="rounded-(--sf-radius) bg-(--sf-primary-fg) px-5 py-2.5 text-sm font-semibold text-(--sf-primary) transition-opacity hover:opacity-90"
- >
- {buttonLabel}
- </button>
- </form>
- </Container>
- </section>
- );
- }
|