From f70a5bdec59b458a5d4da738eb81e96de300c998 Mon Sep 17 00:00:00 2001 From: Karlen9 Date: Tue, 6 Aug 2024 18:57:04 +0400 Subject: [PATCH] feat: arrows for scroll + small fixes --- apps/common/components/AppsCarousel.tsx | 33 +++++------------ apps/common/components/FeaturedApp.tsx | 13 ++++--- pages/_app.tsx | 4 +-- pages/home/index.tsx | 47 +++++++++++++++++++++---- 4 files changed, 60 insertions(+), 37 deletions(-) diff --git a/apps/common/components/AppsCarousel.tsx b/apps/common/components/AppsCarousel.tsx index 011c0bd14..b2711f305 100644 --- a/apps/common/components/AppsCarousel.tsx +++ b/apps/common/components/AppsCarousel.tsx @@ -1,26 +1,15 @@ -import {useEffect, useRef, useState} from 'react'; -import {motion} from 'framer-motion'; +import {type ForwardedRef, forwardRef, type ReactElement} from 'react'; import {FeaturedApp} from './FeaturedApp'; import type {TApp} from 'pages/home/[category]'; -import type {ReactElement} from 'react'; - -export function AppsCarousel(props: {apps: TApp[]}): ReactElement { - const targetRef = useRef(null); - const [width, set_width] = useState(0); - - useEffect(() => { - set_width(Number(targetRef.current?.scrollWidth) - Number(targetRef.current?.offsetWidth)); - }, []); +export const AppsCarousel = forwardRef((props: {apps: TApp[]}, ref: ForwardedRef): ReactElement => { return ( -
+
- +
{props.apps.map((app, i) => ( ))} - +
); -} +}); diff --git a/apps/common/components/FeaturedApp.tsx b/apps/common/components/FeaturedApp.tsx index 2614246b1..1b4674945 100644 --- a/apps/common/components/FeaturedApp.tsx +++ b/apps/common/components/FeaturedApp.tsx @@ -1,4 +1,5 @@ import Image from 'next/image'; +import Link from 'next/link'; import {cl} from '@builtbymom/web3/utils'; import {IconShare} from '@common/icons/IconShare'; @@ -7,9 +8,11 @@ import type {ReactElement} from 'react'; export function FeaturedApp(props: {app: TApp}): ReactElement { return ( -

{props.app.name}

- -
+

{props.app.description}

+ ); } diff --git a/pages/_app.tsx b/pages/_app.tsx index 12ed05fc9..ae9a1eec1 100755 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -57,7 +57,7 @@ const WithLayout = memo(function WithLayout(props: {supportedNetworks: Chain[]}
+ className={'mb-0 flex min-h-screen justify-center bg-gray-900 font-aeonik'}>
(null); + + const scrollBack = (): void => { + if (!carouselRef.current) return; + carouselRef.current.scrollLeft -= 400; + }; + + const scrollForward = (): void => { + if (!carouselRef.current) return; + carouselRef.current.scrollLeft += 400; + }; + useMountEffect(() => { dispatch({type: 'SET_SEARCH', payload: ''}); }); return ( -
-
+
+
-
-

{'Featured Apps'}

- +
+
+

{'Featured Apps'}

+
+ + +
+
+ +
-
+
router.push('/home/community')}