diff --git a/apps/frontpage/components/home/social-validation/slider.tsx b/apps/frontpage/components/home/social-validation/slider.tsx new file mode 100644 index 00000000..5325ab3d --- /dev/null +++ b/apps/frontpage/components/home/social-validation/slider.tsx @@ -0,0 +1,176 @@ +import React, { useEffect, useState, useRef } from 'react'; +import { useReducedMotion, useInView } from 'framer-motion'; +import Image from 'next/image'; + +const SLIDE_WIDTH = 400; +const ANIMATION_INTERVAL = 4000; + +function getTranslateX(indexOffset : number ) { + return indexOffset * SLIDE_WIDTH; +} + +export const storybooks = [ + { + name: 'Monday.com', + url: 'https://style.monday.com/', + logo: 'https://avatars.githubusercontent.com/u/61420283?v=4', + image: { + src: '/home/community/storybooks/monday-com.webp', + width: 1440, + height: 1050, + }, + }, + { + name: 'Microsoft', + url: 'https://master--628d031b55e942004ac95df1.chromatic.com/', + logo: 'https://avatars.githubusercontent.com/u/6154722?v=4', + image: { + src: '/home/community/storybooks/microsoft.webp', + width: 1440, + height: 1050, + }, + }, + { + name: 'D2IQ', + url: 'http://design-system.d2iq.com/', + logo: 'https://avatars.githubusercontent.com/u/19392808?v=4', + image: { + src: '/home/community/storybooks/d2iq.webp', + width: 1440, + height: 1050, + }, + }, + { + name: 'Drei', + url: 'https://drei.pmnd.rs/', + logo: 'https://avatars.githubusercontent.com/u/45790596?v=4', + image: { + src: '/home/community/storybooks/drei.webp', + width: 1440, + height: 1050, + }, + }, + { + name: 'Shopify', + url: 'https://main--5d559397bae39100201eedc1.chromatic.com/', + logo: 'https://avatars.githubusercontent.com/u/8085?v=4', + image: { + src: '/home/community/storybooks/shopify.webp', + width: 1440, + height: 1050, + }, + }, + { + name: 'kickstartDS', + url: 'https://www.kickstartds.com/storybook/', + logo: 'https://avatars.githubusercontent.com/u/79609753?v=4', + image: { + src: '/home/community/storybooks/kickstart-ds.webp', + width: 1440, + height: 1050, + }, + }, + { + name: 'Grommet', + url: 'https://master--5d9774839a6eff00203f5cbf.chromatic.com/', + logo: 'https://avatars.githubusercontent.com/u/14203820?v=4', + image: { + src: '/home/community/storybooks/grommet.webp', + width: 1440, + height: 1050, + }, + }, + { + name: 'JSTOR', + url: 'https://develop--60919c26122bd50039b34644.chromatic.com/', + logo: 'https://avatars.githubusercontent.com/u/74469?v=4', + image: { + src: '/home/community/storybooks/jstor.webp', + width: 1440, + height: 1050, + }, + }, +]; + +export default function AutoSlider() { + const ref = useRef(null); + const isInView = useInView(ref, { once: true, amount: 'all' }); + const shouldReduceMotion = useReducedMotion(); + const centerIndex = Math.floor(storybooks.length / 2); + + const [animationState, setAnimationState] = useState({ + storybooks, + isAnimating: false, + }); + + useEffect(() => { + if (shouldReduceMotion || !isInView) return; + + const timer = setTimeout(() => { + setAnimationState((prev) => ({ + isAnimating: true, + storybooks: [...prev.storybooks.slice(1), prev.storybooks[0]], + })); + }, ANIMATION_INTERVAL); + + return () => clearTimeout(timer); + }, [animationState.storybooks, isInView, shouldReduceMotion]); + + return ( + + +
+
+ {animationState.storybooks.map((item, index) => { + const offset = index - centerIndex; + const isActive = offset === 0; + return ( +
+ +
+
+ + ); + })} +
+
+ ); +} diff --git a/apps/frontpage/components/home/social-validation/social-validation.tsx b/apps/frontpage/components/home/social-validation/social-validation.tsx index f0f9c4b7..6149ad53 100644 --- a/apps/frontpage/components/home/social-validation/social-validation.tsx +++ b/apps/frontpage/components/home/social-validation/social-validation.tsx @@ -8,14 +8,16 @@ import { Button } from '../../ui/button'; import { AspectRatio } from '../../ui/aspect-ratio'; import { Community } from '../../community'; import { Youtube } from '../../logos/youtube'; +import AutoSlider from './slider'; import BlueskySvg from '../share/images/bluesky.svg'; import XSvg from '../share/images/x.svg'; + const projects = [ { name: 'Polaris', bgColor: '#377e62', - width: 100, + width: 80, height: 28, logoAlt: 'Shopify', logoUrl: '/home/community/logos/shopify.svg', @@ -24,7 +26,7 @@ const projects = [ { name: 'Psammead', bgColor: '#8F1F19', - width: 102, + width: 80, height: 28, logoAlt: 'BBC', logoUrl: '/home/community/logos/bbc.svg', @@ -33,7 +35,7 @@ const projects = [ { name: 'UI React', bgColor: '#333333', - width: 88, + width: 80, height: 30, logoAlt: 'Audi UI React', logoUrl: '/home/community/logos/audi.svg', @@ -42,8 +44,8 @@ const projects = [ { name: 'Fluent UI Web Compnents', bgColor: '#0078d4', - width: 40, - height: 70, + width: 20, + height: 40, logoAlt: 'Fluent UI Web Compnents', logoUrl: '/home/community/logos/fluent.svg', projectUrl: @@ -52,8 +54,8 @@ const projects = [ { name: 'Gutenberg', bgColor: '#3171A6', - width: 52, - height: 52, + width: 40, + height: 40, logoAlt: 'WordPress Gutenberg', logoUrl: '/home/community/logos/wordpress.svg', projectUrl: 'https://storybook.js.org/showcase/wordpress-gutenberg', @@ -61,7 +63,7 @@ const projects = [ { name: 'Explorer 1', bgColor: '#0b3d91', - width: 100, + width: 80, height: 28, logoAlt: 'Nasa Explorer 1', logoUrl: '/home/community/logos/nasa.svg', @@ -70,8 +72,8 @@ const projects = [ { name: 'React Spectrum', bgColor: '#e03422', - width: 56, - height: 48, + width: 36, + height: 38, logoAlt: 'Adobe', logoUrl: '/home/community/logos/adobe.svg', projectUrl: @@ -79,88 +81,6 @@ const projects = [ }, ]; -const storybooks = [ - { - name: 'Monday.com', - url: 'https://style.monday.com/', - logo: 'https://avatars.githubusercontent.com/u/61420283?v=4', - image: { - src: '/home/community/storybooks/monday-com.webp', - width: 1440, - height: 1050, - }, - }, - { - name: 'Microsoft', - url: 'https://master--628d031b55e942004ac95df1.chromatic.com/', - logo: 'https://avatars.githubusercontent.com/u/6154722?v=4', - image: { - src: '/home/community/storybooks/microsoft.webp', - width: 1440, - height: 1050, - }, - }, - { - name: 'D2IQ', - url: 'http://design-system.d2iq.com/', - logo: 'https://avatars.githubusercontent.com/u/19392808?v=4', - image: { - src: '/home/community/storybooks/d2iq.webp', - width: 1440, - height: 1050, - }, - }, - { - name: 'Drei', - url: 'https://drei.pmnd.rs/', - logo: 'https://avatars.githubusercontent.com/u/45790596?v=4', - image: { - src: '/home/community/storybooks/drei.webp', - width: 1440, - height: 1050, - }, - }, - { - name: 'Shopify', - url: 'https://main--5d559397bae39100201eedc1.chromatic.com/', - logo: 'https://avatars.githubusercontent.com/u/8085?v=4', - image: { - src: '/home/community/storybooks/shopify.webp', - width: 1440, - height: 1050, - }, - }, - { - name: 'kickstartDS', - url: 'https://www.kickstartds.com/storybook/', - logo: 'https://avatars.githubusercontent.com/u/79609753?v=4', - image: { - src: '/home/community/storybooks/kickstart-ds.webp', - width: 1440, - height: 1050, - }, - }, - { - name: 'Grommet', - url: 'https://master--5d9774839a6eff00203f5cbf.chromatic.com/', - logo: 'https://avatars.githubusercontent.com/u/14203820?v=4', - image: { - src: '/home/community/storybooks/grommet.webp', - width: 1440, - height: 1050, - }, - }, - { - name: 'JSTOR', - url: 'https://develop--60919c26122bd50039b34644.chromatic.com/', - logo: 'https://avatars.githubusercontent.com/u/74469?v=4', - image: { - src: '/home/community/storybooks/jstor.webp', - width: 1440, - height: 1050, - }, - }, -]; const contributors = [ '/home/community/contributor6.jpg', @@ -218,45 +138,11 @@ export function SocialValidation({
-
- {storybooks.map((storybookProject) => ( - -
-
-
-
-
-
- {storybookProject.name} -
-
- {storybookProject.name} - {storybookProject.name} -
-
- ))} -
-
+ +
{projects.map((project) => ( - {project.name} +

{project.name}

))}