import { useState } from "react"; import type { Meta, StoryObj } from "@storybook/react"; import { Box, ContentBlock, SmoothScroll, Stack, Text, } from "../../../components"; import { useTransform, useMotionValueEvent, useSpring } from "framer-motion"; import { useScrollTrigger } from "../../../components"; const meta: Meta = { component: Box, parameters: { backgrounds: { default: "dark", }, }, }; export default meta; type Story = StoryObj; const boxStyles = { className: "rounded-3xl w-40 h-40 bg-blue-500", }; export const PlainBox: Story = { args: { ...boxStyles, }, }; export const AnimatedBox: Story = { args: { ...boxStyles, // animation props initial: "inactive", animate: "active", variants: { inactive: { x: 0, scale: 0, }, active: { x: 400, scale: 0, transition: { repeat: Infinity, repeatType: "mirror", type: "spring", damping: 20, stiffness: 400, repeatDelay: 1, }, }, }, whileInView: { scale: 1, transition: { duration: 1 } }, whileHover: { backgroundColor: "purple", borderRadius: "100%", transition: { type: "spring", damping: 50, stiffness: 80, }, }, }, }; const data: any = { preHeading: "Editorial", headingTitle: "Blog Article Title", subHeading: "07.07.2023     |     15 minutes", description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nec vestibulum eros. Curabitur ac libero malesuada, feugiat ligula quis, sodales diam.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nec vestibulum eros. Curabitur ac libero malesuada, feugiat ligula quis, sodales diam. ", primaryCta: "View article", variant: "primary", }; export const Section: Story = { args: { variant: "section", className: "bg-white p-6", children: , }, }; export const Header: Story = { args: { variant: "header", className: "bg-white p-6", children: ( ), }, }; export const Footer: Story = { args: { variant: "footer", className: "bg-white p-6", children: ( ), }, }; const ProgressChild = () => { const { progress, inView, scrollState, motionState } = useScrollTrigger(); const [percent, setPercent] = useState(0); // const progressSpring = useSpring(progress, { stiffness: 100, damping: 40 }); const x = useTransform(progress, [0, 1], [0, 300]); const width = useTransform(progress, [0, 1], [0, 600]); useMotionValueEvent(progress, "change", (x: number) => { setPercent(Math.round(x * 100)); }); return ( ); }; export const ScrollTrigger: Story = { args: { className: "rounded-3xl w-40 h-40 bg-blue-500 relative", children: , initial: "inactive", animateOnScrollDown: true, debug: true, variants: { inactive: { opacity: 0, scale: 0, }, active: { opacity: 1, scale: 1, }, }, }, }; export const ScrollTriggerPin: Story = { decorators: [ (Story) => { return ( <> ); }, ], args: { className: "rounded-3xl w-40 h-40 bg-blue-500 relative", children: , onLeaveBack: "active", scrollTrigger: { pin: true, start: "top center", end: "+=400", }, debug: true, }, }; export const ScrollTriggerAnimateOnScrollDown: Story = { decorators: [ (Story) => { return ( <> ); }, ], args: { className: "rounded-3xl w-40 h-40 bg-blue-500 relative", animateOnScrollDown: true, debug: true, variants: { inactive: { opacity: 0, scale: 0, }, active: { opacity: 1, scale: 1, transition: { duration: 0.5, }, }, }, }, }; const InViewChild = () => { const { inView } = useScrollTrigger(); return ( ); }; export const ScrollTriggerInView: Story = { decorators: [ (Story) => { const handleLoaded = (scroll: any) => { console.log("scroll", scroll, window); }; return ( <> ); }, ], args: { className: "rounded-3xl w-40 h-40 bg-blue-500 relative", debug: true, children: , scrollTrigger: true, }, };