Skip to content

Commit

Permalink
Merge pull request #42 from AkinariHex/nextjs
Browse files Browse the repository at this point in the history
Leaderboard page major fixes
  • Loading branch information
AkinariHex authored Jan 14, 2024
2 parents 18e5fdb + d3f4d2c commit ba509c2
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 44 deletions.
11 changes: 1 addition & 10 deletions app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ export async function resetLeaderboardFilters(string: string) {
}

export async function applyLeaderboardFilters(params: {}) {
/* const { type, rank, rating, matches, winrate, inclTier, exclTier } = params; */

let urlStringObject = {};

Object.keys(params).forEach((key) => {
Expand All @@ -200,7 +198,6 @@ export async function applyLeaderboardFilters(params: {}) {
let string = '';

params[key].forEach((value, index) => {
console.log(value);
string += `${value}${index === 0 ? `&${key}=` : ''}`;
});

Expand Down Expand Up @@ -417,8 +414,6 @@ export async function fetchDashboard() {
export async function paginationParamsToURL(params: {}) {
let url = '';

console.log(params);

if (Object.keys(params).length > 0) {
Object.keys(params).forEach((key, index) => {
if (key === 'page') return;
Expand All @@ -427,20 +422,16 @@ export async function paginationParamsToURL(params: {}) {
let string = `${index !== 0 ? '&' : ''}${key}=`;

params[key].forEach((value, index) => {
console.log(value);
string += `${value}${index === 0 ? `&${key}=` : ''}`;
});

return (url += `${string}${
index === Object.keys(params).length - 1 ? '&' : ''
}`);
return (url += `${string}`);
}

return (url += `${index !== 0 ? '&' : ''}${key}=${params[key]}${
index === Object.keys(params).length - 1 ? '&' : ''
}`);
});
console.log(url);
}

return url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
flex-grow: 1;
}

.filter h2 {
.filterName {
display: flex;
flex-flow: row;
gap: 0 0.5rem;
}

.filter h2,
.filterName {
font-weight: 600;
font-size: 1.8rem;
}
Expand Down
22 changes: 9 additions & 13 deletions components/Collapsible/FiltersCollapsible/FiltersCollapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
applyLeaderboardFilters,
resetLeaderboardFilters,
} from '@/app/actions';
import InfoIcon from '@/components/Form/InfoIcon/InfoIcon';
import RangeSlider from '@/components/Range/RangeSlider';
import TierSelector from '@/components/TierSelector/TierSelector';
import { AnimatePresence, motion } from 'framer-motion';
Expand Down Expand Up @@ -30,18 +31,6 @@ export default function FiltersCollapsible({
return resetLeaderboardFilters(string);
};

/* useEffect(() => {
setParamsToPush({
...params,
inclTier: inclTier != null ? inclTier.split(',') : [],
exclTier: exclTier != null ? exclTier.split(',') : [],
rank: rank != null ? rank.split(',') : [],
rating: rating != null ? rating.split(',') : [],
matches: matches != null ? matches.split(',') : [],
winrate: winrate != null ? winrate.split(',') : [],
});
}, [params]); */

useEffect(() => {
setParamsToPush({
...params,
Expand Down Expand Up @@ -117,7 +106,14 @@ export default function FiltersCollapsible({
>
<motion.div variants={collapsibleContent} className={styles.filters}>
<motion.div className={styles.filter}>
<h2>Rank</h2>
<div className={styles.filterName}>
<h2>Rank</h2>
<InfoIcon
infoText="Filter by the last-known osu! rank of the player"
positionBottom={true}
startLeft={true}
/>
</div>
<RangeSlider
name={'rank'}
max={data.maxRank}
Expand Down
4 changes: 2 additions & 2 deletions components/Dashboard/UserMainCard/UserMainCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default function UserMainCard({ data }: { data: {} }) {
<div className={styles.tierImageContainer}>
<div className={styles.tierImage}>
<Image
src={'http://s.ppy.sh/a/4001304'}
alt={"Player's propic"}
src={`http://s.ppy.sh/a/${data.playerId}`}
alt={"Player's Tier"}
fill
/>
</div>
Expand Down
16 changes: 11 additions & 5 deletions components/Form/InfoIcon/InfoIcon.module.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
.infoIcon {
/* position: absolute;
right: 1rem;
height: 100%;
width: 100%;
aspect-ratio: 1; */
position: relative;
cursor: pointer;
}
Expand Down Expand Up @@ -32,6 +27,17 @@
visibility: hidden;
opacity: 0;
transition: opacity 0.2s ease-out;
z-index: 2;
}

.tooltip.positionBottom {
bottom: inherit;
top: 2.2rem;
}

.tooltip.startLeft {
left: -1rem;
right: inherit;
}

.infoIcon:hover > .tooltip {
Expand Down
18 changes: 14 additions & 4 deletions components/Form/InfoIcon/InfoIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
'use client';
/* import icon from '@/public/icons/info-icon.svg';
import Image from 'next/image'; */
import { faQuestion } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import clsx from 'clsx';
import styles from './InfoIcon.module.css';

export default function InfoIcon({
infoText,
positionBottom,
startLeft,
children,
}: {
infoText?: string;
positionBottom?: boolean;
startLeft?: boolean;
children?: React.ReactNode;
}) {
return (
<div className={styles.infoIcon}>
<FontAwesomeIcon icon={faQuestion} />
{/* <Image src={icon} alt="Info" fill /> */}
<div className={styles.tooltip}>{infoText || children}</div>
<div
className={clsx(
styles.tooltip,
positionBottom === true ? styles.positionBottom : '',
startLeft === true ? styles.startLeft : ''
)}
>
{infoText || children}
</div>
</div>
);
}
6 changes: 3 additions & 3 deletions components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function Pagination({
const onPageChange = async (number: number) => {
let url = await paginationParamsToURL(params);

router.push(`/leaderboards?${url}page=${number}#leaderboard`, {
router.push(`/leaderboards?${url}&page=${number}#leaderboard`, {
scroll: true,
});

Expand All @@ -53,7 +53,7 @@ export default function Pagination({
const onNext = async () => {
if (currentPage < parseInt(lastPage)) {
let url = await paginationParamsToURL(params);
router.push(`/leaderboards?${url}page=${currentPage + 1}#leaderboard`, {
router.push(`/leaderboards?${url}&page=${currentPage + 1}#leaderboard`, {
scroll: true,
});
}
Expand All @@ -62,7 +62,7 @@ export default function Pagination({
const onPrevious = async () => {
if (currentPage > 1) {
let url = await paginationParamsToURL(params);
router.push(`/leaderboards?${url}page=${currentPage - 1}#leaderboard`, {
router.push(`/leaderboards?${url}&page=${currentPage - 1}#leaderboard`, {
scroll: true,
});
}
Expand Down
2 changes: 1 addition & 1 deletion components/Range/RangeSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ export default function RangeSlider({
setParamsToPush((prev: any) => ({
...prev,
[name]: [
values[0],
Math.max(
min - 1,
Math.min(values[1], Number(e.target.value))
) < min
? min
: Math.min(max, Number(e.target.value)),
values[1],
],
}));
}}
Expand Down
2 changes: 1 addition & 1 deletion components/SubmitMatches/Guidelines/Guidelines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function Guidelines() {
return (
<div className={styles.list}>
<Card
title="Submission F.A.Q."
title="Submission Rules"
description="Please read the following before submitting. Our goal is to include matches that do not stray too far from the competitive norm, it's important that bad data remains out of our system."
/>
<Card
Expand Down
7 changes: 3 additions & 4 deletions components/SubmitMatches/MatchForm/MatchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ export default function MatchForm({ userRoles }: { userRoles: Array<string> }) {
<Form action={formAction}>
<div className={styles.section}>
<div className={styles.header}>
<h1>Tournament</h1>
<h1>Tournament Submission</h1>
<p>
We’re currently prioritizing badged tournaments, but you can
submit an unbadged tournament as well as long as it follows the
rules.
Any tournament, regardless of badge status, may be submitted, so
long as it follows our rules.
</p>
</div>
<div className={styles.fields}>
Expand Down

0 comments on commit ba509c2

Please sign in to comment.