Skip to content

Commit

Permalink
Merge pull request #11 from CS3219-AY2425S1/jiale/homepage-fix
Browse files Browse the repository at this point in the history
Jiale/homepage fix
  • Loading branch information
yitong241 authored Oct 1, 2024
2 parents 7a07003 + 714fac0 commit 9ec7041
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 84 deletions.
6 changes: 5 additions & 1 deletion frontend/src/components/Footer/Footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
}

&-github {
background: #caff33 !important;
justify-self: start;

&-icon {
background: #caff33 !important;
}
}

&-trademark {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const Footer = (): ReactElement => {
<Typography>LuckyJinx</Typography>
</Container>
<Box className="Footer-bottom">
<a href={gitHubUrl} target="_blank" rel="noreferrer noopener">
<IconButton className="Footer-github">
<a href={gitHubUrl} className="Footer-github" target="_blank" rel="noreferrer noopener">
<IconButton className="Footer-github-icon">
<GitHubIcon />
</IconButton>
</a>
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/QuestionList/QuestionList.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ h1 {
text-decoration: underline !important;
}

.questiontablebody {
padding-top: 10px;
min-height: 20vh;
display: flex;
flex-direction: column;
justify-content: center;
}

@media (max-width: 768px) {
.table th,
.table td {
Expand Down
163 changes: 82 additions & 81 deletions frontend/src/components/QuestionList/QuestionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,6 @@ const QuestionList = (): ReactElement => {
fetchQuestions();
}, []);

if (loading) {
return <Typography variant="h6">Loading questions...</Typography>;
}

if (error) {
return (
<Typography variant="h6" color="error">
{error}
</Typography>
);
}

const handleSort = (key: keyof Question) => {
const order = sortKey === key && sortOrder === "asc" ? "desc" : "asc";
setSortKey(key);
Expand Down Expand Up @@ -153,78 +141,91 @@ const QuestionList = (): ReactElement => {

return (
<div className={styles.container}>
<Typography variant="h4" align="center" gutterBottom>
<Typography variant="h5" gutterBottom>
Question Repository
</Typography>
<table className={styles.table}>
<thead>
<tr>
<th
onClick={() => handleSort("questionId")}
className={`${styles.clickable} ${sortKey === "questionId" ? styles[sortOrder] : ""}`}
>
ID
</th>
<th
onClick={() => handleSort("title")}
className={`${styles.clickable} ${sortKey === "title" ? styles[sortOrder] : ""}`}
<div className={styles.questiontablebody}>
{loading ? (
<Typography align="center">Loading questions...</Typography>
) : error ? (
<Typography align="center" color="error">
{error}
</Typography>
) : (
<div>
<table className={styles.table}>
<thead>
<tr>
<th
onClick={() => handleSort("questionId")}
className={`${styles.clickable} ${sortKey === "questionId" ? styles[sortOrder] : ""}`}
>
ID
</th>
<th
onClick={() => handleSort("title")}
className={`${styles.clickable} ${sortKey === "title" ? styles[sortOrder] : ""}`}
>
Title
</th>
<th>Categories</th>
<th
onClick={() => handleSort("complexity")}
className={`${styles.clickable} ${sortKey === "complexity" ? styles[sortOrder] : ""}`}
>
Complexity
</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{questions.map((question) => (
<tr key={question.questionId}>
<td>{question.questionId}</td>
<td>
<Button className={styles.questiontitle} onClick={showQuestionDetails(question)}>
{question.title}
</Button>
<a href={question.link} target="_blank" rel="noreferrer">
<IconButton>
<OpenInNew className={styles.questionlinkicon} color="primary" />
</IconButton>
</a>
</td>
<td>
<div className={styles.tags}>
{question.categories.map((tag, index) => (
<span key={index} className={styles.tag}>
{tag}
</span>
))}
</div>
</td>
<td className={styles.complexity}>{question.complexity}</td>
<td className={styles.actions}>
<IconButton onClick={() => openQuestionDialog(question)}>
<EditNote className={styles.questionediticon} />
</IconButton>
<IconButton className={styles.questiondeleteicon} onClick={handleDelete(question)}>
<DeleteForever />
</IconButton>
</td>
</tr>
))}
</tbody>
</table>
<Button
className={styles.questionaddicon}
color="primary"
variant="contained"
onClick={() => openQuestionDialog(null)}
>
Title
</th>
<th>Categories</th>
<th
onClick={() => handleSort("complexity")}
className={`${styles.clickable} ${sortKey === "complexity" ? styles[sortOrder] : ""}`}
>
Complexity
</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{questions.map((question) => (
<tr key={question.questionId}>
<td>{question.questionId}</td>
<td>
<Button className={styles.questiontitle} onClick={showQuestionDetails(question)}>
{question.title}
</Button>
<a href={question.link} target="_blank" rel="noreferrer">
<IconButton>
<OpenInNew className={styles.questionlinkicon} color="primary" />
</IconButton>
</a>
</td>
<td>
<div className={styles.tags}>
{question.categories.map((tag, index) => (
<span key={index} className={styles.tag}>
{tag}
</span>
))}
</div>
</td>
<td className={styles.complexity}>{question.complexity}</td>
<td className={styles.actions}>
<IconButton onClick={() => openQuestionDialog(question)}>
<EditNote className={styles.questionediticon} />
</IconButton>
<IconButton className={styles.questiondeleteicon} onClick={handleDelete(question)}>
<DeleteForever />
</IconButton>
</td>
</tr>
))}
</tbody>
</table>
<Button
className={styles.questionaddicon}
color="primary"
variant="contained"
onClick={() => openQuestionDialog(null)}
>
Add question
</Button>
Add question
</Button>
</div>
)}
</div>

<QuestionDialog
isAddNew={isAddNew}
isOpen={isQuestionDialogOpen}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/Home/Home.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.Home {
background: var(--Grey-10, #1a1a1a);
min-height: 100vh;
padding: 40px 80px;
display: flex;
flex-direction: column;
Expand Down

0 comments on commit 9ec7041

Please sign in to comment.