Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static height for project Grid #471

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions apps/website/src/components/ProjectsList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client"

import { Button, Grid, GridItem, HStack, IconButton, Text, VStack } from "@chakra-ui/react"
import { useCallback, useEffect, useState } from "react"
import { useCallback, useEffect, useRef, useState } from "react"
import ProjectCard from "../components/ProjectCard"
import allProjects from "../data/projects.json"
import IconChevronLeft from "../icons/IconChevronLeft"
Expand All @@ -16,6 +16,7 @@ export default function ProjectsList(props: any) {
const [index, setIndex] = useState<number>(0)
const [selectedCategory, setSelectedCategory] = useState<string | null>(null)
const [onlyPSE, setOnlyPSE] = useState<boolean | null>(null)
const viewToScrollRef = useRef<HTMLDivElement>(null)

const filterProjects = useCallback(() => {
let filteredProjects = allProjects
Expand All @@ -39,6 +40,12 @@ export default function ProjectsList(props: any) {
filterProjects()
}, [selectedCategory, onlyPSE])

useEffect(() => {
if (viewToScrollRef.current) {
viewToScrollRef.current.scrollIntoView({ behavior: "smooth" })
}
}, [index])

return (
<VStack {...props}>
<VStack align="left" spacing="6">
Expand Down Expand Up @@ -66,9 +73,8 @@ export default function ProjectsList(props: any) {
</HStack>
</VStack>

<VStack align="left" spacing="6">
<VStack align="left" spacing="6" ref={viewToScrollRef}>
<Text fontSize="20">Category</Text>

<HStack spacing="3" flexWrap="wrap">
{getProjectCategories(allProjects).map((category) => (
<Button
Expand Down
Loading