1
1
import { Search2Icon } from "@chakra-ui/icons" ;
2
- import { Spacer } from "@chakra-ui/react" ;
2
+ import { SimpleGrid , Spacer } from "@chakra-ui/react" ;
3
3
import Head from "next/head" ;
4
4
import React , { useEffect , useState } from "react" ;
5
+ import ProjectModal from "../components/ProjectModal" ;
5
6
6
7
const Project = ( ) => {
7
- const [ projects , setProjects ] = useState ( [ ] ) ;
8
- const [ filteredProjects , setFilteredProjects ] = useState ( [ ] ) ;
8
+ const [ data , setData ] = useState ( [ ] ) ;
9
+ const [ searchTerm , setSearchTerm ] = useState ( "" ) ;
9
10
const [ searchQuery , setSearchQuery ] = useState ( "" ) ;
10
11
11
12
const getUsers = async ( year ) => {
12
13
let url = `/WoB/projects/project${ year } .json` ;
13
14
const response = await fetch ( url ) ;
14
15
const projectData = await response . json ( ) ;
15
- setProjects ( projectData ) ;
16
- setFilteredProjects ( projectData ) ; // Initialize filtered projects
16
+ setData ( projectData ) ;
17
17
} ;
18
18
19
19
useEffect ( ( ) => {
20
20
getUsers ( "2024" ) ;
21
21
} , [ ] ) ;
22
-
23
- const handleSearch = ( event ) => {
24
- const query = event . target . value . toLowerCase ( ) ;
25
- setSearchQuery ( query ) ;
26
-
27
- const filtered = projects . filter ( ( project ) => {
28
- const titleMatch = project . title ?. toLowerCase ( ) . includes ( query ) ;
29
- const tagsMatch = project . tags . some ( ( tag ) =>
30
- tag . toLowerCase ( ) . includes ( query )
31
- ) ;
32
- return titleMatch || tagsMatch ;
33
- } ) ;
34
-
35
- setFilteredProjects ( filtered ) ;
36
- } ;
37
-
38
22
return (
39
23
< >
40
24
< Head >
@@ -55,61 +39,101 @@ const Project = () => {
55
39
< input
56
40
className = "px-3 py-1 bg-transparent outline-none dark:text-white text-black"
57
41
type = "search"
58
- placeholder = "Search"
59
- value = { searchQuery }
60
- onChange = { handleSearch }
42
+ placeholder = "Search Projects....."
61
43
name = "search"
62
44
id = "search"
45
+ onChange = { ( event ) => setSearchTerm ( event . target . value ) }
63
46
/>
64
47
</ div >
65
48
</ div >
66
49
</ div >
67
50
< Spacer mt = { 16 } />
68
- < div className = "grid grid-cols-1 md:grid-cols-2 gap-8 w-[90%] m-auto md:px-24" >
69
- { filteredProjects . map ( ( project , index ) => (
70
- < div
71
- key = { index }
72
- className = "relative w-full max-w-[537px] h-[550px] bg-cover hover:shadow-xl hover:shadow-[#23A3CD] rounded-[50px] bg-center text-white"
73
- style = { { backgroundImage : "url('/WoB/projects_card.png')" } }
74
- >
75
- < a href = { project . projectUrl } >
76
- < div className = "absolute inset-0 rounded-[50px] bg-black bg-opacity-5 flex items-center justify-center" >
77
- < div className = "p-4 text-left w-[90%] m-auto text-[#00008B]" >
78
- < div className = "m-auto h-1/2" >
79
- < h2 className = "text-2xl text-center md:text-4xl my-6 font-bold" >
80
- { project . title ?. slice ( 0 , 17 ) }
81
- { project . title [ 18 ] && "..." }
82
- </ h2 >
83
- < p className = "text-lg md:text-xl mt-20 font-semibold" >
84
- Project Admin:{ " " }
85
- < span className = "font-medium" >
86
- { project . name ?. slice ( 0 , 15 ) }
87
- { project . name [ 15 ] && "..." }
88
- </ span >
89
- </ p >
90
- < p className = "text-base md:text-lg mt-4 font-normal" >
91
- { project . description ?. slice ( 0 , 120 ) }
92
- { project . description [ 121 ] && "..." }
93
- </ p >
94
- </ div >
95
- < div className = "grid w-[95%] min-w-[235px] overflow-hidden m-auto grid-cols-2 md:grid-cols-3 gap-4 mt-5" >
96
- { project . tags . map (
97
- ( tag , idx ) =>
98
- idx < 6 && (
99
- < p
100
- key = { idx }
101
- className = "w-[110px] h-[40px] text-center pt-[8px] text-white text-sm bg-[#00008B] rounded-tl-full rounded-br-full"
51
+ < div
52
+ className = "flex flex-row justify-center flex-wrap items-center
53
+ gap-x-10 gap-y-10 mt-9"
54
+ >
55
+ { data
56
+ . sort ( ( ) => 0.5 - Math . random ( ) )
57
+ . filter ( ( curElem , i ) => {
58
+ if ( searchTerm == "" ) return curElem ;
59
+ if (
60
+ curElem . tags
61
+ . join ( "," )
62
+ . toLowerCase ( )
63
+ . includes ( searchTerm . toLowerCase ( ) ) ||
64
+ curElem . title . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) )
65
+ )
66
+ return curElem ;
67
+ } )
68
+ . map ( ( curElem , i ) => {
69
+ return (
70
+ < div
71
+ className = "flex rounded-2xl relative bg-gradient-to-b from-[#00008B] to-[#85C6DC] items-center justify-between w-80"
72
+ key = { i }
73
+ data-aos = "flip-up"
74
+ data-aos-duration = "800"
75
+ >
76
+ < img className = "absolute top-5 right-4 w-[66px] h-[63px]" src = "./WoB/snow.png" />
77
+ < img className = "absolute top-24 right-4 w-[51px] h-[44px]" src = "./WoB/snow.png" />
78
+ < img className = "absolute top-36 right-4 w-[34px] h-[34px]" src = "./WoB/snow.png" />
79
+ < img className = "absolute bottom-28 right-4 w-[25px] h-[25px]" src = "./WoB/snow.png" />
80
+ < img className = "absolute bottom-20 right-4 w-[19px] h-[17px]" src = "./WoB/snow.png" />
81
+
82
+ < div className = "shadow dark:bg-black rounded-lg" >
83
+ < div
84
+ className = "overflow-y-clip rounded-lg h-fit md:h-80
85
+ w-80 flex flex-col justify-start
86
+ shadow-lg shadow-black-200 relative"
87
+ >
88
+ < >
89
+ < div className = "flex flex-col justify-start gap-2 px-5 py-3" >
90
+ < div className = "font-bold text-white md:text-xl" >
91
+ < a
92
+ target = "_blank"
93
+ rel = "noreferrer"
94
+ href = { curElem ?. projectUrl }
102
95
>
103
- { tag . split ( " " ) [ 0 ] }
104
- </ p >
105
- )
106
- ) }
96
+ { curElem . title }
97
+ </ a >
98
+ </ div >
99
+ < div className = "mb-3 text-sm text-[#85C6DC] md:text-md md:mb-4" >
100
+ By { curElem . name }
101
+ </ div >
102
+ </ div >
103
+ < SimpleGrid
104
+ columns = { { sm : 2 , md : 3 } }
105
+ spacing = { 2 }
106
+ margin = { 1 }
107
+ className = "px-2"
108
+ >
109
+ { curElem . tags
110
+ . sort ( ( a , b ) => a . length - b . length )
111
+ . map ( ( techStk , k ) => {
112
+ return (
113
+ techStk && (
114
+ < button
115
+ className = "bg-[#E6F6FF] rounded-tl-md rounded-br-md w-full py-1
116
+ text-[#00008B] drop-shadow-md "
117
+ key = { k }
118
+ onClick = { ( ) => {
119
+ setSearchTerm ( techStk . trim ( ) ) ;
120
+ } }
121
+ >
122
+ { techStk . trim ( ) }
123
+ </ button >
124
+ )
125
+ ) ;
126
+ } ) }
127
+ </ SimpleGrid >
128
+ </ >
129
+ < br />
130
+ < br />
131
+ < ProjectModal currProject = { curElem } />
107
132
</ div >
108
133
</ div >
109
134
</ div >
110
- </ a >
111
- </ div >
112
- ) ) }
135
+ ) ;
136
+ } ) }
113
137
</ div >
114
138
< Spacer mt = { 16 } />
115
139
</ section >
0 commit comments