Skip to content

Commit 754cc7c

Browse files
Update cards to be centered
1 parent e7f22b8 commit 754cc7c

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed

src/components/project-card.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const ProjectCard = ({
1515
as={Link}
1616
href={repo || homepage}
1717
p={4}
18+
h='full'
1819
rounded='lg'
1920
transitionProperty='all'
2021
transitionDuration='slower'
@@ -27,11 +28,12 @@ export const ProjectCard = ({
2728
textDecoration: 'none',
2829
}}
2930
>
30-
<CardBody p={0}>
31+
<CardBody p={0} h='full'>
3132
<Stack
3233
spacing={2}
3334
direction={'column'}
3435
justify={'space-between'}
36+
h='full'
3537
gap={0}
3638
>
3739
<Box>

src/components/projects.js

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Container, SimpleGrid, Text } from '@chakra-ui/react'
1+
import { Box, Container, Grid, GridItem, Text } from '@chakra-ui/react'
22
import React from 'react'
33

44
import { Heading } from '@/components/mdx'
@@ -7,6 +7,23 @@ import { Projects as ProjectsData } from '@/data/projects'
77

88
export const Projects = () => {
99
const projects = React.useMemo(() => ProjectsData, [])
10+
const projectsPerRowLg = 3
11+
const remainderLg = projects.length % projectsPerRowLg
12+
const lastRowStartIndexLg = projects.length - remainderLg
13+
14+
const getLgColStart = (index) => {
15+
if (remainderLg === 1 && index === lastRowStartIndexLg) {
16+
return 3
17+
}
18+
19+
if (remainderLg === 2) {
20+
if (index === lastRowStartIndexLg) return 2
21+
if (index === lastRowStartIndexLg + 1) return 4
22+
}
23+
24+
return undefined
25+
}
26+
1027
return (
1128
<Box id={'projects'} as='section'>
1229
<Container maxW='container.lg' centerContent>
@@ -20,24 +37,35 @@ export const Projects = () => {
2037
developed with Parcels.
2138
</Text>
2239

23-
<SimpleGrid
40+
<Grid
2441
my={8}
25-
columns={{ base: 1, md: 2, lg: 3 }}
26-
spacing={8}
27-
justifyContent={'space-between'}
42+
templateColumns={{
43+
base: 'repeat(1, minmax(0, 1fr))',
44+
md: 'repeat(2, minmax(0, 1fr))',
45+
lg: 'repeat(6, minmax(0, 1fr))',
46+
}}
47+
gap={8}
48+
w='full'
49+
alignItems='stretch'
2850
>
2951
{projects.map((project, index) => (
30-
<ProjectCard
52+
<GridItem
3153
key={index}
32-
name={project.name}
33-
logo_light={project.logo_light}
34-
logo_dark={project.logo_dark}
35-
description={project.description}
36-
repo={project.repo}
37-
homepage={project.homepage}
38-
></ProjectCard>
54+
colSpan={{ base: 1, md: 1, lg: 2 }}
55+
colStart={{ lg: getLgColStart(index) }}
56+
h='full'
57+
>
58+
<ProjectCard
59+
name={project.name}
60+
logo_light={project.logo_light}
61+
logo_dark={project.logo_dark}
62+
description={project.description}
63+
repo={project.repo}
64+
homepage={project.homepage}
65+
></ProjectCard>
66+
</GridItem>
3967
))}
40-
</SimpleGrid>
68+
</Grid>
4169
</Box>
4270
</Container>
4371
</Box>

0 commit comments

Comments
 (0)