From a372be4578e57a2c6d6f68a965cd6cc65d4d7e91 Mon Sep 17 00:00:00 2001
From: vshnosngh
Date: Wed, 11 Nov 2026 12:53:39 +0530
Subject: [PATCH] feat(tool-page): add dynamic support for before/after
comparison animations and videos in alternating features
---
.../collections/tools/blemish-remover.json | 22 +------
.../tools/AlternatingFeaturesSection.tsx | 60 +++++++++++++++----
src/types/index.ts | 7 ++-
3 files changed, 56 insertions(+), 33 deletions(-)
diff --git a/content/collections/tools/blemish-remover.json b/content/collections/tools/blemish-remover.json
index 7c0b841..06f2202 100644
--- a/content/collections/tools/blemish-remover.json
+++ b/content/collections/tools/blemish-remover.json
@@ -88,25 +88,9 @@
"en": "Dual-alias endpoint — /improver/ and /eye_fix/ call the same skin-enhancement pipeline that fixes puffy under-eye bags, redness, and overall skin smoothness. Applies the process_improver routine. secretKey validation: optional — invalid key is rejected, absent key is allowed.",
"hi": "अत्याधुनिक डीप लर्निंग मॉडल। फोटो प्रोसेस होने के तुरंत बाद सुरक्षित रूप से हटा दी जाती है।"
},
- "image": "https://images.unsplash.com/photo-1517841905240-472988babdf9?w=800&auto=format&fit=crop&q=80",
- "badge": {
- "en": "Verified Model",
- "hi": "सत्यापित मॉडल"
- },
- "caption": {
- "en": "Blemish Remover — Skin Improver & Eye Fix output quality specimen",
- "hi": "परिणाम नमूना"
- },
- "metrics": [
- {
- "label": "Service Group",
- "value": "ML"
- },
- {
- "label": "Latency",
- "value": "350ms"
- }
- ]
+ "mediaType": "comparison",
+ "before": "https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=800&auto=format&fit=crop&q=80",
+ "after": "https://images.unsplash.com/photo-1517841905240-472988babdf9?w=800&auto=format&fit=crop&q=80"
},
{
"title": {
diff --git a/src/components/tools/AlternatingFeaturesSection.tsx b/src/components/tools/AlternatingFeaturesSection.tsx
index f14d2e4..23b1203 100644
--- a/src/components/tools/AlternatingFeaturesSection.tsx
+++ b/src/components/tools/AlternatingFeaturesSection.tsx
@@ -3,6 +3,7 @@
import React from 'react';
import { AlternatingFeature, resolveLocalised } from '@/types';
import { KineticText } from '@/components/magicui/kinetic-text';
+import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
interface AlternatingFeaturesSectionProps {
features?: AlternatingFeature[];
@@ -35,39 +36,72 @@ export function AlternatingFeaturesSection({
- {/* Alternating Feature Items: Image at Left - Text at Right, then Text at Left - Image at Right (No cards, pure editorial) */}
+ {/* Alternating Feature Items: Supports Image, Interactive Before/After Comparison, or Video */}
{features.map((feature, idx) => {
const isEven = idx % 2 === 0;
const title = resolveLocalised(feature.title, locale);
const desc = resolveLocalised(feature.description, locale);
+ // Dynamically detect media format: comparison animation/slider, video, or image
+ const isComparison = feature.mediaType === 'comparison' || (Boolean(feature.before) && Boolean(feature.after));
+ const isVideo = feature.mediaType === 'video' || Boolean(feature.videoUrl) || (feature.image ? /\.(mp4|webm|mov)(\?.*)?$/i.test(feature.image) : false);
+
return (
- {/* Visual / Image Block */}
+ {/* Visual / Media Block */}
-
- {/* eslint-disable-next-line @next/next/no-img-element */}
-

-
+ {/* 1. Comparison Interactive Slider / Animation */}
+ {isComparison && feature.before && feature.after ? (
+
+
+
+ ) : isVideo ? (
+ /* 2. Autoplay Looped Video Specimen */
+
+
+
+ ) : (
+ /* 3. High-Resolution Single Specimen Image */
+
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+

+
+ )}
- {/* Text Paragraph Block: Clean Heading + Spacious Paragraph (No cards, no Feature labels, no pills) */}
+ {/* Text Paragraph Block: Clean Heading + Spacious Paragraph */}
;