AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

newsletter.tsx 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { cn } from '@/lib/utils';
  2. import type { NewsletterSection } from '../types';
  3. import { Container } from '../ui';
  4. export function Newsletter({ section }: { section: NewsletterSection }) {
  5. const { heading, body, placeholder, buttonLabel } = section.content;
  6. const card = section.variant === 'card';
  7. // split: a big heading on one side, the form on the other, in the store's normal colours.
  8. if (section.variant === 'split') {
  9. return (
  10. <section
  11. id={section.id}
  12. className="sf-section scroll-mt-20 border-y border-(--sf-border) py-16 md:py-20"
  13. data-layout="split"
  14. >
  15. <Container className="grid gap-8 md:grid-cols-2 md:items-end">
  16. <div>
  17. <h2 className="sf-heading text-3xl leading-tight font-semibold text-balance sm:text-4xl">
  18. {heading}
  19. </h2>
  20. {body && (
  21. <p className="mt-3 max-w-md text-(--sf-muted)">
  22. {body}
  23. </p>
  24. )}
  25. </div>
  26. <form
  27. className="flex w-full gap-2 md:justify-self-end"
  28. onSubmit={(event) => event.preventDefault()}
  29. >
  30. <label
  31. className="sr-only"
  32. htmlFor={`${section.id}-email`}
  33. >
  34. {placeholder}
  35. </label>
  36. <input
  37. id={`${section.id}-email`}
  38. type="email"
  39. placeholder={placeholder}
  40. 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)"
  41. />
  42. <button
  43. type="submit"
  44. 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"
  45. >
  46. {buttonLabel}
  47. </button>
  48. </form>
  49. </Container>
  50. </section>
  51. );
  52. }
  53. return (
  54. <section
  55. id={section.id}
  56. className={cn(
  57. 'scroll-mt-20',
  58. card
  59. ? 'sf-section py-16'
  60. : 'bg-(--sf-primary) text-(--sf-primary-fg)',
  61. )}
  62. >
  63. <Container
  64. className={cn(
  65. 'flex flex-col gap-6 md:flex-row md:items-center md:justify-between',
  66. card
  67. ? 'max-w-4xl rounded-(--sf-radius-card) bg-(--sf-primary) p-8 text-(--sf-primary-fg) sm:p-10'
  68. : 'py-12',
  69. )}
  70. >
  71. <div className="max-w-md">
  72. <h2 className="sf-heading text-2xl font-semibold sm:text-3xl">
  73. {heading}
  74. </h2>
  75. {body && <p className="mt-2 opacity-85">{body}</p>}
  76. </div>
  77. {/* Sign-ups are not saved yet. That arrives with the commerce step. */}
  78. <form
  79. className="flex w-full max-w-md gap-2"
  80. onSubmit={(event) => event.preventDefault()}
  81. >
  82. <label className="sr-only" htmlFor={`${section.id}-email`}>
  83. {placeholder}
  84. </label>
  85. <input
  86. id={`${section.id}-email`}
  87. type="email"
  88. placeholder={placeholder}
  89. 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)"
  90. />
  91. <button
  92. type="submit"
  93. 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"
  94. >
  95. {buttonLabel}
  96. </button>
  97. </form>
  98. </Container>
  99. </section>
  100. );
  101. }