forked from realstoman/react-tailwindcss-portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectsGrid.jsx
128 lines (122 loc) · 3.69 KB
/
ProjectsGrid.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import { useContext } from 'react';
import { FiSearch } from 'react-icons/fi';
import ProjectSingle from './ProjectSingle';
import { ProjectsContext } from '../../context/ProjectsContext';
import ProjectsFilter from './ProjectsFilter';
const ProjectsGrid = () => {
const {
projects,
searchProject,
setSearchProject,
searchProjectsByTitle,
selectProject,
setSelectProject,
selectProjectsByCategory,
} = useContext(ProjectsContext);
return (
<section className="py-5 sm:py-10 mt-5 sm:mt-10">
<div className="text-center">
<p className="font-general-medium text-2xl sm:text-4xl mb-1 text-ternary-dark dark:text-ternary-light">
Projects portfolio
</p>
</div>
<div className="mt-10 sm:mt-16">
<h3
className="font-general-regular
text-center text-secondary-dark
dark:text-ternary-light
text-md
sm:text-xl
mb-3
"
>
Search projects by title or filter by category
</h3>
<div
className="
flex
justify-between
border-b border-primary-light
dark:border-secondary-dark
pb-3
gap-3
"
>
<div className="flex justify-between gap-2">
<span
className="
hidden
sm:block
bg-primary-light
dark:bg-ternary-dark
p-2.5
shadow-sm
rounded-xl
cursor-pointer
"
>
<FiSearch className="text-ternary-dark dark:text-ternary-light w-5 h-5"></FiSearch>
</span>
<input
onChange={(e) => {
setSearchProject(e.target.value);
}}
className="font-general-medium
pl-3
pr-1
sm:px-4
py-2
border
border-gray-200
dark:border-secondary-dark
rounded-lg
text-sm
sm:text-md
bg-secondary-light
dark:bg-ternary-dark
text-primary-dark
dark:text-ternary-light
"
id="name"
name="name"
type="search"
required=""
placeholder="Search Projects"
aria-label="Name"
/>
</div>
<ProjectsFilter setSelectProject={setSelectProject} />
</div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 mt-6 sm:gap-10">
{selectProject
? selectProjectsByCategory.map((project) => (
<ProjectSingle
title={project.title}
category={project.category}
image={project.img}
key={project.id}
/>
))
: searchProject
? searchProjectsByTitle.map((project) => (
<ProjectSingle
title={project.title}
category={project.category}
image={project.img}
key={project.id}
/>
))
: projects.map((project) => (
<ProjectSingle
title={project.title}
category={project.category}
image={project.img}
key={project.id}
/>
))}
</div>
</section>
);
};
export default ProjectsGrid;