diff --git a/src/app/globals.css b/src/app/globals.css index abc0df4..36a7eb6 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -105,8 +105,31 @@ body { @apply transition-[opacity,transform] duration-700 ease-out; } .zoom.pre { - @apply opacity-0 scale-95; + opacity: 0; + transform: scale(1.05); } .zoom.post { - @apply opacity-100 scale-100; + opacity: 1; + transform: scale(1); +} + +.fadeImage { + /* scale: 0.8; + opacity: 0.2; */ + animation: fadeInKf linear forwards; + animation-timeline: view(); + /* animation-range-start: contain; +animation-range-end: contain; */ + /* animation-range: entry 100px; */ +} + +@keyframes fadeInKf { + from { + scale: 0.8; + opacity: 0.2; + } + to { + scale: 1; + opacity: 1; + } } diff --git a/src/components/animated-link.tsx b/src/components/animated-link.tsx new file mode 100644 index 0000000..73ea92b --- /dev/null +++ b/src/components/animated-link.tsx @@ -0,0 +1,41 @@ +'use client'; +import React from 'react'; +import { ReactNode } from 'react'; +import useInView from '@/hooks/useInView'; + +interface AnimatedLiProps { + children: ReactNode; + className?: string; + startClass?: string; + finishClass?: string; + threshold?: number; + // Additional props if needed + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: any; +} + +export function AnimatedLi({ + children, + className = '', + startClass, + finishClass, + threshold, + ...props +}: AnimatedLiProps) { + const [ref, isVisible] = useInView({ + threshold: threshold ?? 0.1, + triggerOnce: true, + }); + + return ( +
  • } + className={`transition-[opacity, transform] ease-out duration-1000 ${ + isVisible ? 'opacity-100' : 'opacity-0' + } ${isVisible ? finishClass : startClass} ${className}`} + {...props} + > + {children} +
  • + ); +} diff --git a/src/components/category-slider.tsx b/src/components/category-slider.tsx index f234391..b9cb3c7 100644 --- a/src/components/category-slider.tsx +++ b/src/components/category-slider.tsx @@ -2,6 +2,7 @@ import { useState } from 'react'; import Image from 'next/image'; import styles from './category-slider.module.css'; +import { AnimatedLi } from './animated-link'; const categories = [ { name: 'Bars', image: '/images/categories/bars.jpg' }, @@ -14,15 +15,19 @@ const categories = [ export function ChocolateCategories() { const [currentImage, setCurrentImage] = useState(categories[0].image); + const startClass = 'translate-x-8'; + const finishClass = 'translate-x-0 delay-300'; return (
    diff --git a/src/components/our-collection.tsx b/src/components/our-collection.tsx index 972031b..33ba7cf 100644 --- a/src/components/our-collection.tsx +++ b/src/components/our-collection.tsx @@ -17,19 +17,18 @@ const collections = [ export function Collections() { return ( -
    +
    {collections.map((collection, index) => ( -
    - {collection.title} +
    +
    + {collection.title} +

    {collection.title}