diff --git a/apps/website/src/app/learn/page.tsx b/apps/website/src/app/learn/page.tsx index 9fe060a6..a827b522 100644 --- a/apps/website/src/app/learn/page.tsx +++ b/apps/website/src/app/learn/page.tsx @@ -279,11 +279,13 @@ await verifyProof(verificationKey, fullProof)`, ))} - - + + + - + + diff --git a/apps/website/src/components/ArticlesCarousel.tsx b/apps/website/src/components/ArticlesCarousel.tsx index acddc278..f364c603 100644 --- a/apps/website/src/components/ArticlesCarousel.tsx +++ b/apps/website/src/components/ArticlesCarousel.tsx @@ -1,44 +1,45 @@ "use client" -import { HStack, IconButton, Stack, useBreakpointValue } from "@chakra-ui/react" -import { useCallback, useEffect, useState } from "react" -import allArticles from "../data/articles.json" +import { Box, HStack, IconButton, VStack, useBreakpointValue, Text } from "@chakra-ui/react" +import { useCallback, useState } from "react" +import articles from "../data/articles.json" import IconArrowLeft from "../icons/IconArrowLeft" import IconArrowRight from "../icons/IconArrowRight" -import { circularSlice } from "../utils/circularSlice" import ArticleCard from "./ArticleCard" -export default function ArticlesCarousel() { - const variant = useBreakpointValue( - { - base: 3, - sm: 3, - md: 2, - lg: 4 - }, - { - fallback: "md" - } - ) - - const [articles, setArticles] = useState() +export default function VideosCarousel() { const [index, setIndex] = useState(0) - - useEffect(() => { - setArticles(circularSlice(allArticles, index, variant!)) - }, [index, variant]) + const numberOfItems = useBreakpointValue({ + base: 1, + md: 2, + lg: 4 + }) const nextProject = useCallback(() => { - setIndex((i) => (i + 1) % allArticles.length) - }, [index]) + if (index + 1 === Math.ceil(articles.length / numberOfItems!)) { + setIndex(0) + } else { + setIndex((prevIndex) => prevIndex + 1) + } + }, [index, numberOfItems]) const previousProject = useCallback(() => { - setIndex((i) => (i === 0 ? allArticles.length - 1 : i - 1)) + if (index === 0) { + setIndex(Math.ceil(articles.length / numberOfItems!) - 1) + } else { + setIndex((prevIndex) => prevIndex - 1) + } }, [index]) return ( <> - + + + + Articles + + + - - {articles && - articles.map((article, i) => ( - + + + {articles.map((article, i) => ( + + + + + ))} - + + ) } diff --git a/apps/website/src/components/CodeBlock.tsx b/apps/website/src/components/CodeBlock.tsx index bf4e71c1..03b2f015 100644 --- a/apps/website/src/components/CodeBlock.tsx +++ b/apps/website/src/components/CodeBlock.tsx @@ -1,5 +1,3 @@ -"use client" - import { Flex, useClipboard, Button } from "@chakra-ui/react" import { CodeBlock, ocean } from "react-code-blocks" diff --git a/apps/website/src/components/VideosCarousel.tsx b/apps/website/src/components/VideosCarousel.tsx index 028968cd..ac5ae7be 100644 --- a/apps/website/src/components/VideosCarousel.tsx +++ b/apps/website/src/components/VideosCarousel.tsx @@ -1,44 +1,45 @@ "use client" -import { HStack, IconButton, Stack, useBreakpointValue } from "@chakra-ui/react" -import { useCallback, useEffect, useState } from "react" -import allVideos from "../data/videos.json" +import { Box, HStack, IconButton, VStack, useBreakpointValue, Text } from "@chakra-ui/react" +import { useCallback, useState } from "react" +import videos from "../data/videos.json" import IconArrowLeft from "../icons/IconArrowLeft" import IconArrowRight from "../icons/IconArrowRight" -import { circularSlice } from "../utils/circularSlice" import VideoCard from "./VideoCard" export default function VideosCarousel() { - const variant = useBreakpointValue( - { - base: 3, - sm: 3, - md: 2, - lg: 4 - }, - { - fallback: "md" - } - ) - - const [videos, setVideos] = useState() const [index, setIndex] = useState(0) - - useEffect(() => { - setVideos(circularSlice(allVideos, index, variant!)) - }, [index, variant]) + const numberOfItems = useBreakpointValue({ + base: 1, + md: 2, + lg: 4 + }) const nextProject = useCallback(() => { - setIndex((i) => (i + 1) % allVideos.length) - }, [index]) + if (index + 1 === Math.ceil(videos.length / numberOfItems!)) { + setIndex(0) + } else { + setIndex((prevIndex) => prevIndex + 1) + } + }, [index, numberOfItems]) const previousProject = useCallback(() => { - setIndex((i) => (i === 0 ? allVideos.length - 1 : i - 1)) + if (index === 0) { + setIndex(Math.ceil(videos.length / numberOfItems!) - 1) + } else { + setIndex((prevIndex) => prevIndex - 1) + } }, [index]) return ( <> - + + + + Videos + + + - - {videos && - videos.map((video, i) => ( - + + + {videos.map((video, i) => ( + + + + + ))} - + + ) } diff --git a/apps/website/src/data/videos.json b/apps/website/src/data/videos.json index 7f901b5f..4376da23 100644 --- a/apps/website/src/data/videos.json +++ b/apps/website/src/data/videos.json @@ -3,7 +3,7 @@ "title": "Snarks for mixing, signaling and scaling", "eventName": "Devcon4", "date": "Dec 10, 2018", - "speakerss": ["Barry Whitehat"], + "speakers": ["Barry Whitehat"], "url": "https://youtu.be/lv6iK9qezBY", "embeddedUrl": "https://www.youtube.com/embed/lv6iK9qezBY?si=3HDxcxjELRCjrLJo" }, @@ -11,7 +11,7 @@ "title": "Succinct Proofs in Ethereum", "eventName": "2nd ZKProof Workshop", "date": "Apr 30, 2019", - "speakerss": ["Barry Whitehat"], + "speakers": ["Barry Whitehat"], "url": "https://youtu.be/TtsDNneTDDY", "embeddedUrl": "https://www.youtube.com/embed/TtsDNneTDDY?si=UmRq7i4B0gm7bvfx" },