feat: make tryIt presets, limits, badges and buttons completely dynamic from JSON configs
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import React, { useRef, useState, useEffect, useCallback } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { ArrowRight, Check, Smartphone, ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
import { DeferredComparison } from '@/components/ui/DeferredComparison';
|
||||
import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
|
||||
|
||||
export interface ShowcaseItem {
|
||||
id: string;
|
||||
@@ -31,6 +31,7 @@ interface CinematicHorizontalProps {
|
||||
badge?: string;
|
||||
subtitle?: string;
|
||||
items?: ShowcaseItem[];
|
||||
animationMode?: 'horizontal' | 'vertical';
|
||||
}
|
||||
|
||||
export function CinematicHorizontalScrollSection({
|
||||
@@ -38,6 +39,7 @@ export function CinematicHorizontalScrollSection({
|
||||
badge = 'FLAGSHIP TRANSFORMATION MODELS',
|
||||
subtitle = 'Browse the flagship tools with native cinematic pan controls.',
|
||||
items = [],
|
||||
animationMode = 'horizontal',
|
||||
}: CinematicHorizontalProps) {
|
||||
const containerRef = useRef<HTMLElement>(null);
|
||||
const trackRef = useRef<HTMLDivElement>(null);
|
||||
@@ -180,6 +182,28 @@ export function CinematicHorizontalScrollSection({
|
||||
|
||||
if (!items.length) return null;
|
||||
|
||||
// Clean fluid vertical stack when horizontal scroll animation is disabled
|
||||
if (animationMode === 'vertical') {
|
||||
return (
|
||||
<section id="flagship-models" className="py-16 sm:py-24 border-y border-slate-900/[0.08] bg-[#FAF8F5]">
|
||||
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 mb-8 sm:mb-12">
|
||||
<div className="max-w-2xl">
|
||||
<p className="eyebrow">{badge}</p>
|
||||
<h2 className="mt-1 text-2xl font-display font-bold tracking-tight text-slate-900 sm:text-3xl lg:text-4xl">
|
||||
{title}
|
||||
</h2>
|
||||
<p className="mt-1 text-xs text-slate-600 sm:text-sm">{subtitle}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mx-auto max-w-5xl px-4 sm:px-6 lg:px-8 space-y-8">
|
||||
{items.map((item) => (
|
||||
<ShowcaseCard key={item.id} item={item} isVertical />
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
// Fluid vertical scroll distance: 100vh base + 85vh per additional card
|
||||
const containerHeightVh = 100 + (items.length - 1) * 85;
|
||||
|
||||
@@ -261,28 +285,34 @@ export function CinematicHorizontalScrollSection({
|
||||
);
|
||||
}
|
||||
|
||||
function ShowcaseCard({ item }: { item: ShowcaseItem }) {
|
||||
function ShowcaseCard({ item, isVertical }: { item: ShowcaseItem; isVertical?: boolean }) {
|
||||
const comparison = item.variant !== 'banner' && item.beforeUrl && item.afterUrl;
|
||||
|
||||
return (
|
||||
<article className="w-[88vw] shrink-0 overflow-hidden rounded-3xl border border-slate-900/[0.09] bg-white shadow-cream-md sm:w-[680px] lg:w-[780px]">
|
||||
<article
|
||||
className={`${
|
||||
isVertical
|
||||
? 'w-full'
|
||||
: 'w-[88vw] shrink-0 sm:w-[680px] lg:w-[780px]'
|
||||
} overflow-hidden rounded-3xl border border-slate-900/[0.09] bg-white shadow-cream-md`}
|
||||
>
|
||||
<div className="grid lg:grid-cols-[1.1fr_.9fr]">
|
||||
<div className="min-h-[260px] sm:min-h-[290px] bg-slate-100">
|
||||
<div className="relative min-h-[280px] sm:min-h-[320px] lg:min-h-full h-full bg-slate-950 overflow-hidden">
|
||||
{comparison ? (
|
||||
<DeferredComparison
|
||||
<CardBeforeAfterSlider
|
||||
beforeUrl={item.beforeUrl!}
|
||||
afterUrl={item.afterUrl!}
|
||||
beforeLabel="Original"
|
||||
afterLabel="CRE result"
|
||||
aspectRatio="aspect-[4/3] lg:aspect-auto lg:h-full"
|
||||
beforeLabel="BEFORE"
|
||||
afterLabel="AI RESULT"
|
||||
aspectRatio="aspect-[4/3] sm:aspect-[16/10] lg:aspect-auto lg:h-full"
|
||||
/>
|
||||
) : (
|
||||
<div className="relative h-full min-h-[260px] sm:min-h-[290px] overflow-hidden bg-slate-950">
|
||||
<div className="relative h-full min-h-[280px] sm:min-h-[320px] overflow-hidden bg-slate-950">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
src={item.bannerImage || item.beforeUrl || ''}
|
||||
alt={item.title}
|
||||
loading="lazy"
|
||||
loading="eager"
|
||||
decoding="async"
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user