Skip to content

Commit af77643

Browse files
committed
fix dropdown arrow and add activity field
1 parent 9413396 commit af77643

File tree

6 files changed

+43
-40
lines changed

6 files changed

+43
-40
lines changed

src/assets/down.png

-5.89 KB
Binary file not shown.

src/assets/up-arrow.png

-2.57 KB
Binary file not shown.

src/components/SortDropdown.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from "react";
22
import "../styles/components/SortDropdown.css";
3-
import downArrow from "../assets/down.png";
4-
import upArrow from "../assets/up-arrow.png";
3+
import { FaChevronDown } from "react-icons/fa";
4+
import { FaChevronUp } from "react-icons/fa6";
55
import { SortDropdownProps } from "../utils/types";
66
const SortDropdown: React.FC<SortDropdownProps> = ({
77
setSortField,
@@ -23,19 +23,17 @@ const SortDropdown: React.FC<SortDropdownProps> = ({
2323

2424
return (
2525
<div className={`dropdown ${showMenu ? "show" : ""}`}>
26-
<div className="sort-button">
27-
<button disabled={window.innerWidth >= 760} onClick={toggleDropdown}>
26+
<div className="sort-container">
27+
<button disabled={window.innerWidth >= 1200} onClick={toggleDropdown} >
2828
Sort by:{" "}{sortField.charAt(0).toUpperCase()+sortField.slice(1)}
2929
</button>
30-
<div className="sort-Arrow-container" onClick={(e) => {
31-
e.stopPropagation();
32-
toggleSort();
33-
}}>
34-
<img src={sortType === "desc" ? downArrow : upArrow} className="sort-Arrow" alt="▼" />
35-
30+
31+
<div className="sort-Arrow-container" onClick={toggleSort}>
32+
{sortType==="desc"?<FaChevronDown/>:<FaChevronUp/>}
3633
</div>
37-
38-
</div>
34+
</div>
35+
36+
3937
<div className={`dropdown-content ${showMenu ? "show" : ""}`}>
4038
<div className={`dropdown-item ${"name" === sortField ? "selected" : ""}`} onClick={() => handleSortField("name")}>
4139
{" "}
@@ -52,7 +50,12 @@ const SortDropdown: React.FC<SortDropdownProps> = ({
5250

5351
Stars
5452
</div>
53+
<div className={`dropdown-item ${"activity" === sortField ? "selected" : ""}`} onClick={() => handleSortField("activity")}>
54+
55+
Activity
56+
</div>
5557

58+
5659
</div>
5760
</div>
5861
);

src/pages/Projects.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import RepoData from '../data/repo_data.json';
66
import SortDropdown from "../components/SortDropdown";
77
const Projects = () => {
88
const repoList: REPO_DATA_TYPE[] = RepoData as REPO_DATA_TYPE[]
9-
const [sortField, setSortField] = useState("name");
10-
const [sortType,setSortType]=useState("asc")
9+
const [sortField, setSortField] = useState("activity");
10+
const [sortType,setSortType]=useState("desc")
1111
const languages = [...new Set(repoList.map(repo => repo.language))];
1212
const [selectedLanguage, setSelectedLanguage] = useState<string[]>([]);
1313
const [FilteredRepos, setFilteredRepos] = useState<REPO_DATA_TYPE[]>(repoList);
@@ -40,6 +40,13 @@ const Projects = () => {
4040
return sortType === "asc" ? cmp : -cmp;
4141
});
4242

43+
}
44+
else if (sortField === "activity") {
45+
if (sortType === "asc") {
46+
result = result.reverse();
47+
}
48+
49+
4350
}
4451
setFilteredRepos(result)
4552

src/styles/components/RepoCard.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
1111
color: #000;
1212
padding: 1rem;
13-
width: 400px;
13+
width: 350px;
1414
text-align: left;
1515
}
1616

@@ -29,7 +29,7 @@
2929
padding: 0.5rem 0;
3030
color: #333;
3131
text-align: left;
32-
width: 100%;
32+
height: 100%;
3333
}
3434

3535
.gh-card-footer {

src/styles/components/SortDropdown.css

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,32 @@ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
1111
background-color: #393737;
1212
border-radius: 0 0 5px 5px;
1313
}
14-
.sort-button {
15-
background-color: #2f2f2f;
16-
color: #fcfcfc;
17-
border: none;
18-
padding: 8px 15px;
19-
font-size: 14px;
14+
.sort-container {
2015
border-radius: 5px;
21-
2216
cursor: pointer;
23-
width: 200px;
2417
transition: background 300ms, color 300ms, scale 300ms;
25-
2618
display: flex;
27-
justify-content: space-between;
28-
2919
}
30-
.sort-button button{
20+
.sort-container button{
3121
color: #fcfcfc;
3222
background-color: #2f2f2f;
33-
width: 100%;
23+
width: 200px;
24+
border-radius: 5px 0 0 5px;
3425
text-align: left;
3526
border: none;
27+
padding: 8px 15px ;
28+
3629
}
3730
.sort-Arrow-container{
3831
display: flex;
32+
justify-content: center;
33+
align-items: center;
34+
background-color: #2f2f2f;
35+
width: 30px;
36+
border-radius: 0 5px 5px 0;
37+
border-left: 1px solid #4e4d4d;
3938
}
4039

41-
.sort-Arrow {
42-
width: 15px;
43-
44-
filter: brightness(0) invert(1);
45-
color: white;
46-
}
4740

4841
.dropdown-content {
4942
opacity: 0;
@@ -52,7 +45,7 @@ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
5245
border-radius: 0 0 5px 5px;
5346
background-color: #2f2f2f;
5447
color: #fcfcfc;
55-
width: 230px;
48+
width: 200px;
5649

5750
z-index: 1;
5851
}
@@ -83,8 +76,8 @@ for large screens toggle on hover */
8376
transform: translateY(0);
8477
}
8578

86-
.dropdown:hover .sort-button{
87-
border-radius: 5px 5px 0 0;
79+
.dropdown:hover .sort-container button{
80+
border-radius: 5px 0 0 0;
8881
}
8982

9083
/*
@@ -94,8 +87,8 @@ for small screens toggling on click */
9487
transform: translateY(0);
9588

9689
}
97-
.dropdown.show .sort-button{
98-
border-radius: 5px 5px 0 0 ;
90+
.dropdown.show .sort-container button{
91+
border-radius: 5px 0 0 0 ;
9992

10093
}
10194

0 commit comments

Comments
 (0)