From 5818b227ed6ae0801106a4f3e85130204f5b6e55 Mon Sep 17 00:00:00 2001 From: cedoor Date: Thu, 21 Dec 2023 17:35:48 +0100 Subject: [PATCH 1/2] fix(website): fix ui inaccuracies --- apps/website/src/app/learn/page.tsx | 74 +++++++++++--------- apps/website/src/app/page.tsx | 6 +- apps/website/src/components/ArticleCard.tsx | 7 +- apps/website/src/components/Carousel.tsx | 10 +-- apps/website/src/components/Footer.tsx | 9 +-- apps/website/src/components/Navbar.tsx | 4 +- apps/website/src/components/ProjectsList.tsx | 30 ++++---- apps/website/src/components/VideoCard.tsx | 10 +-- apps/website/src/data/projects.json | 57 +++++++++------ 9 files changed, 108 insertions(+), 99 deletions(-) diff --git a/apps/website/src/app/learn/page.tsx b/apps/website/src/app/learn/page.tsx index b7f2dc046..7db0c1be3 100644 --- a/apps/website/src/app/learn/page.tsx +++ b/apps/website/src/app/learn/page.tsx @@ -333,7 +333,7 @@ await verifyProof(verificationKey, fullProof)`, pos="absolute" /> - + - - Videos - - - {sortByDate(videos).map((video) => ( - - + + + + Videos + + + {sortByDate(videos).map((video) => ( + - - ))} - - - Articles - - - {sortByDate(articles).map((article) => ( - - - - ))} - + ))} + + + + + + Articles + + + {sortByDate(articles).map((article) => ( + + + + ))} + + ) diff --git a/apps/website/src/app/page.tsx b/apps/website/src/app/page.tsx index 19da35cf9..02f6cc308 100644 --- a/apps/website/src/app/page.tsx +++ b/apps/website/src/app/page.tsx @@ -1,9 +1,9 @@ -import { Box, Button, Card, CardBody, Heading, HStack, Link, Stack, Text, VStack, Image } from "@chakra-ui/react" +import { Box, Button, Card, CardBody, HStack, Heading, Image, Link, Stack, Text, VStack } from "@chakra-ui/react" import { Sora } from "next/font/google" import Carousel from "../components/Carousel" import ProjectCard from "../components/ProjectCard" import events from "../data/events.json" -import projects from "../data/projects.json" +import allProjects from "../data/projects.json" import IconDiscord from "../icons/IconDiscord" const sora = Sora({ @@ -68,7 +68,7 @@ export default function Home() { - {projects.slice(0, 3).map((project) => ( + {allProjects.slice(0, 3).map((project) => ( - + {title} - + {`${minRead} min read`} diff --git a/apps/website/src/components/Carousel.tsx b/apps/website/src/components/Carousel.tsx index 832ee5466..5b6b6f46a 100644 --- a/apps/website/src/components/Carousel.tsx +++ b/apps/website/src/components/Carousel.tsx @@ -3,8 +3,8 @@ import { Box, HStack, Heading, IconButton, Link, StackProps, VStack, useBreakpointValue } from "@chakra-ui/react" import NextLink from "next/link" import { useCallback, useState } from "react" -import articles from "../data/articles.json" -import projects from "../data/projects.json" +import allArticles from "../data/articles.json" +import allProjects from "../data/projects.json" import videos from "../data/videos.json" import IconArrowLeft from "../icons/IconArrowLeft" import IconArrowRight from "../icons/IconArrowRight" @@ -46,7 +46,7 @@ export default function Carousel({ title, sizes, type, ...props }: CarouselProps }, [index, size]) return ( - + {title} @@ -80,7 +80,7 @@ export default function Carousel({ title, sizes, type, ...props }: CarouselProps align="stretch" > {type === "projects" && - projects.map((project) => ( + allProjects.map((project) => ( ( + sortByDate(allArticles).map((article) => ( @@ -71,17 +71,14 @@ export default function Footer() { - Twitter + X (Twitter) - + diff --git a/apps/website/src/components/Navbar.tsx b/apps/website/src/components/Navbar.tsx index d1bcb3b8a..e54f7edb5 100644 --- a/apps/website/src/components/Navbar.tsx +++ b/apps/website/src/components/Navbar.tsx @@ -83,7 +83,7 @@ export default function Navbar() { - Twitter + X (Twitter) @@ -91,7 +91,7 @@ export default function Navbar() { diff --git a/apps/website/src/components/ProjectsList.tsx b/apps/website/src/components/ProjectsList.tsx index 3e68586c4..d1badf426 100644 --- a/apps/website/src/components/ProjectsList.tsx +++ b/apps/website/src/components/ProjectsList.tsx @@ -11,15 +11,17 @@ import IconPSE from "../icons/IconPSE" import { chunkArray } from "../utils/chunkArray" import { getProjectCategories } from "../utils/getProjectCategories" +const sortedProjects = allProjects.sort((a, b) => a.name.localeCompare(b.name)) + export default function ProjectsList(props: any) { - const [projects, setProjects] = useState<(typeof allProjects)[]>(chunkArray(allProjects)) + const [projects, setProjects] = useState<(typeof allProjects)[]>(chunkArray(sortedProjects)) const [index, setIndex] = useState(0) const [selectedCategories, setSelectedCategories] = useState([]) const [onlyPSE, setOnlyPSE] = useState(null) const viewToScrollRef = useRef(null) const filterProjects = useCallback(() => { - let filteredProjects = allProjects + let filteredProjects = sortedProjects if (selectedCategories.length > 0) { filteredProjects = filteredProjects.filter((project) => @@ -33,26 +35,20 @@ export default function ProjectsList(props: any) { filteredProjects = filteredProjects.filter((project) => !project.pse) } - filteredProjects = filteredProjects.sort((a, b) => a.name.localeCompare(b.name)) - setProjects(chunkArray(filteredProjects)) }, [selectedCategories, onlyPSE]) - useEffect(() => { - filterProjects() - }, [selectedCategories, onlyPSE]) + const changePageIndex = useCallback((newIndex: number) => { + setIndex(newIndex) - useEffect(() => { if (viewToScrollRef.current) { viewToScrollRef.current.scrollIntoView({ behavior: "smooth" }) } - }, [index]) + }, []) useEffect(() => { - if (viewToScrollRef.current) { - viewToScrollRef.current.scrollIntoView({ behavior: "smooth" }) - } - }, [index]) + filterProjects() + }, [selectedCategories, onlyPSE]) return ( @@ -82,7 +78,7 @@ export default function ProjectsList(props: any) { Category - {getProjectCategories(allProjects).map((category) => ( + {getProjectCategories(sortedProjects).map((category) => (