1- import { Box , Container , SimpleGrid , Text } from '@chakra-ui/react'
1+ import { Box , Container , Grid , GridItem , Text } from '@chakra-ui/react'
22import React from 'react'
33
44import { Heading } from '@/components/mdx'
@@ -7,6 +7,23 @@ import { Projects as ProjectsData } from '@/data/projects'
77
88export 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