"use client";
import React, { useRef, useState } from "react";
import {
motion,
useScroll,
useTransform,
useMotionValueEvent,
} from "motion/react";
import { IconRocket } from "@tabler/icons-react";
import Image from "next/image";
const features = [
{
icon: ,
title: "Generate ultra realistic images in seconds",
description:
"With our state of the art AI, you can generate ultra realistic images in no time at all.",
content: (
),
},
{
icon: ,
title: "Replicate great Art",
description:
"Generate the painting of renowned artists, like Van Gogh or Monet or Majnu bhai.",
content: (
),
},
{
icon: ,
title: "Batch generate images with a single click.",
description:
"With our state of the art AI, you can generate a batch of images within 10 seconds with absolutely no compute power.",
content: (
),
},
];
export function FeaturesWithStickyScroll() {
const ref = useRef(null);
const { scrollYProgress } = useScroll({
target: ref,
offset: ["start end", "end start"],
});
const backgrounds = ["#1f2937", "#262626", "#1e293b"];
const [gradient, setGradient] = useState(backgrounds[0]);
useMotionValueEvent(scrollYProgress, "change", (latest) => {
const cardsBreakpoints = features.map(
(_, index) => index / features.length
);
const closestBreakpointIndex = cardsBreakpoints.reduce(
(acc, breakpoint, index) => {
const distance = Math.abs(latest - breakpoint);
if (distance < Math.abs(latest - cardsBreakpoints[acc])) {
return index;
}
return acc;
},
0
);
setGradient(backgrounds[closestBreakpointIndex % backgrounds.length]);
});
return (
AI Smarter than Aliens
Our AI is smarter than aliens, it can predict the future and help you
generate wild images.
);
}
export const StickyScroll = ({
content,
}: {
content: { title: string; description: string; icon?: React.ReactNode }[];
}) => {
return (
{content.map((item, index) => (
))}
{content.map((item, index) => (
))}
);
};
export const ScrollContent = ({
item,
index,
}: {
item: {
title: string;
description: string;
icon?: React.ReactNode;
content?: React.ReactNode;
};
index: number;
}) => {
const ref = useRef(null);
const { scrollYProgress } = useScroll({
target: ref,
offset: ["start end", "end start"],
});
const translate = useTransform(scrollYProgress, [0, 1], [0, 250]);
const translateContent = useTransform(scrollYProgress, [0, 1], [0, -200]);
const opacity = useTransform(
scrollYProgress,
[0, 0.05, 0.5, 0.7, 1],
[0, 1, 1, 0, 0]
);
const opacityContent = useTransform(
scrollYProgress,
[0, 0.2, 0.5, 0.8, 1],
[0, 0, 1, 1, 0]
);
return (
{item.icon}
{item.title}
{item.description}
{item.content && item.content}
);
};
export const ScrollContentMobile = ({
item,
index,
}: {
item: {
title: string;
description: string;
icon?: React.ReactNode;
content?: React.ReactNode;
};
index: number;
}) => {
return (
{item.content && item.content}
{item.icon}
{item.title}
{item.description}
);
};