Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filters modal popup #395

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d8f8e47
Initial commit.
gorDaChris Sep 24, 2024
58fd351
Fixed no-show preview on hover.
gorDaChris Oct 1, 2024
a513fe0
Prettify Code: src/web/src/Constants.ts
actions-user Oct 1, 2024
b4bb54c
Update Constants.ts
Kagiri2 Oct 1, 2024
3f78cec
Created filters popup on button press.
gorDaChris Oct 11, 2024
da48024
Merge branch 'admin-edit-posts' of https://github.com/shimupan/lineup…
gorDaChris Oct 11, 2024
6f9531e
Update to valid filter options.
gorDaChris Oct 15, 2024
1afc069
Filters are now set conditionally (Valorant vs CS2)
gorDaChris Oct 20, 2024
2649df1
Bring filters from Popup to ProfilePage.
gorDaChris Oct 20, 2024
0019dd3
Profile posts now update on submission of filters. Posts displayed va…
gorDaChris Oct 29, 2024
ca4372f
Update posts based on selected game. Fixed bugs with filter list comp…
gorDaChris Nov 1, 2024
2c32059
Updated filters UI, moved to same div as Valorant and CS2.
gorDaChris Nov 8, 2024
4465187
fixed merge conflicts
Kagiri2 Nov 12, 2024
e452ab2
Prettify Code: src/web/src/Components/auth/FiltersPopup.tsx
actions-user Nov 12, 2024
046b9ed
fixed merge conflicts
Kagiri2 Nov 12, 2024
af11467
fixed merge conflicts
Kagiri2 Nov 12, 2024
887f39a
Slight touch up to filters modal popup. Added primitive ProfileSearch…
gorDaChris Nov 15, 2024
5596aec
Merge branch 'admin-edit-posts' of https://github.com/shimupan/lineup…
gorDaChris Nov 15, 2024
a3bd6c6
Prettify Code: src/web/src/Components.ts
actions-user Nov 15, 2024
5b506c8
Added profile banner and image to pfp.
gorDaChris Dec 6, 2024
16d2ee3
Merge branch 'admin-edit-posts' of https://github.com/shimupan/lineup…
gorDaChris Dec 6, 2024
2662460
Prettify Code: src/web/src/Pages/user/ProfileSearch.tsx
actions-user Dec 6, 2024
88c41bc
Added nav bar under profile banner. Added hover animations.
gorDaChris Dec 6, 2024
c556118
Merge branch 'admin-edit-posts' of https://github.com/shimupan/lineup…
gorDaChris Dec 6, 2024
3d0a7b7
Prettify Code: src/web/src/Constants.ts
actions-user Dec 6, 2024
1860388
Update to layout of page. Changed text size, adding padding and weights.
gorDaChris Dec 7, 2024
4c431ed
Updated layout for Current Rating section to be more accurate.
gorDaChris Dec 7, 2024
6b14d65
Prettify Code: src/web/src/Pages/user/ProfileSearch.tsx
actions-user Dec 7, 2024
4f371c9
Update to Overview section with vertical lines and more stats.
gorDaChris Dec 7, 2024
5daf658
Prettify Code: src/web/src/Pages/user/ProfileSearch.tsx
actions-user Dec 7, 2024
f5f30b1
Added second line of stats for Overview section.
gorDaChris Dec 7, 2024
e96bcd2
Merge branch 'admin-edit-posts' of https://github.com/shimupan/lineup…
gorDaChris Dec 7, 2024
67a3fed
Prettify Code: src/web/src/Pages/user/ProfileSearch.tsx
actions-user Dec 7, 2024
f5363c1
Finalized Competitive Overview section.
gorDaChris Dec 7, 2024
b44b99e
Prettify Code: src/web/src/Pages/user/ProfileSearch.tsx
actions-user Dec 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
ScrollToTop,
GuestPage,
PrivatePolicy,
ProfileSearch,
TOS,
ManagePosts,
EditPosts,
Expand Down Expand Up @@ -214,6 +215,7 @@ function App() {
></Route>
<Route path="/resetpassword" element={<ResetPassword />}></Route>
<Route path="/privatepolicy" element={<PrivatePolicy />}></Route>
<Route path="/profilesearch" element={<ProfileSearch />}></Route>
{role === 'admin' && Verified && (
<Route element={<RequireAuth allowedRoles={['admin']} />}>
<Route path="/admin" element={<AdminHome />}></Route>
Expand Down
2 changes: 2 additions & 0 deletions src/web/src/Components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@ export { default as FollowingSideNav } from './Components/global/sidebar/Followi
export { default as PostPageSkeleton } from './Components/post/PostPageSkeleton';
export { default as LeaderboardPosition } from './Components/profile/LeaderboardPosition';
export { default as VerificationMessage } from './Components/profile/VerificationMessage';
export { default as FiltersPopup } from './Components/auth/FiltersPopup';
export { default as ProfileSearch } from './Pages/user/ProfileSearch';
export { default as MobileComments } from './Components/post/MobileComments';
export { default as ZoomableImage } from './Components/post/ZoomableImage';
198 changes: 198 additions & 0 deletions src/web/src/Components/auth/FiltersPopup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
import React, { useState } from 'react';

interface FiltersPopupProps {
onClose: () => void;
selectedGame: string;
onSubmit: (filters: Filters) => void;
}

interface Filters {
[key: string]: string[];
}

type FilterCategories =
| 'mapName'
| 'teamSide'
| 'grenadeType'
| 'jumpThrow'
| 'valorantAgent';

const initialFilters: Filters = {
teamSide: [],
mapName: [],
grenadeType: [],
jumpThrow: [],
valorantAgent: [],
};

const FiltersPopup: React.FC<FiltersPopupProps> = ({
onClose,
selectedGame,
onSubmit,
}) => {
const [filters, setFilters] = useState<Filters>(initialFilters);

// Add value in FilterCategory only if it is not yet toggled
const toggleCheckbox = (category: FilterCategories, value: string) => {
setFilters((prevFilters) => {
const currVal = prevFilters[category];
if (currVal.includes(value)) {
return {
...prevFilters,
[category]: currVal.filter((v) => v !== value),
};
} else {
return {
...prevFilters,
[category]: [...currVal, value],
};
}
});
};

// Format each checkbox - e.g. hover effects
const renderCheckboxes = (
title: string,
category: FilterCategories,
options: string[],
) => (
<div>
<h3 className="text-base/loose font-semibold">{title}</h3>
{options.map((option) => (
<label
key={option}
className="flex items-center mb-2 cursor-pointer"
>
<input
type="checkbox"
checked={filters[category].includes(option)}
onChange={() => toggleCheckbox(category, option)}
className="appearance-none h-4 w-4 border border-gray-300 rounded checked:bg-blue-500 checked:border-transparent focus:outline-none mr-2 cursor-pointer hover:border-blue-500"
/>
<span className="text-white">{option}</span>
</label>
))}
</div>
);

const pressedSubmit = () => {
onSubmit(filters);
onClose();
};

return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50 rounded-xl">
<div className="bg-gray-900 rounded-md shadow-lg ring-1 ring-black ring-opacity-5 divide-y divide-gray-800 text-white w-full md:w-96">
<div className="flex items-center justify-between p-4 border-b">
<h2 className="text-lg font-medium">Filters</h2>
<button
className="p-2 rounded-full hover:bg-gray-200"
onClick={onClose}
>
<svg
className="w-5 h-5 text-gray-600"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</button>
</div>
<div className="max-h-96 overflow-y-auto p-4">
{selectedGame === 'Valorant' && (
<>
{renderCheckboxes('Side', 'teamSide', [
'Attacker',
'Defender',
])}
{renderCheckboxes('Map', 'mapName', [
'abyss',
'ascent',
'bind',
'breeze',
'fracture',
'haven',
'icebox',
'lotus',
'pearl',
'split',
'sunset',
])}
{renderCheckboxes('Agent', 'valorantAgent', [
'Brimstone',
'Phoenix',
'Sage',
'Sova',
'Viper',
'Cypher',
'Reyna',
'Killjoy',
'Breach',
'Omen',
'Jett',
'Raze',
'Skye',
'Yoru',
'Astra',
'KAY/O',
'Chamber',
'Neon',
'Fade',
'Harbor',
'Gekko',
'Deadlock',
'Iso',
'Clove',
'Vyse',
])}
</>
)}
{selectedGame === 'CS2' && (
<>
{renderCheckboxes('Side', 'teamSide', ['T', 'CT'])}
{renderCheckboxes('Map', 'mapName', [
'mirage',
'inferno',
'nuke',
'overpass',
'vertigo',
'ancient',
'anubis',
'dust2',
])}
{renderCheckboxes('Grenade', 'grenadeType', [
'he',
'smoke',
'flashbangs',
'decoy',
'molotov',
'incendiary',
])}
{renderCheckboxes('Jumpthrow?', 'jumpThrow', [
'YES',
'NO',
])}
</>
)}
</div>
<div className="p-4 border-t">
<button
onClick={pressedSubmit}
className="w-full p-2 bg-blue-500 text-white rounded hover:bg-blue-600"
>
Submit
</button>
</div>
</div>
</div>
);
};

export default FiltersPopup;
Loading