Skip to content

Commit 4575fde

Browse files
committed
Add styling and sync with new question struct
Moved styling to css files Set up tailwind.config.ts to define global colour palette Fixed some behaviour when screen size changes Synced up with new question struct Resolves #9, #6
1 parent 727c4b6 commit 4575fde

File tree

10 files changed

+91
-34
lines changed

10 files changed

+91
-34
lines changed

peerprep/app/globals.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ body,
1313
p,
1414
h1,
1515
h2 {
16-
@apply text-gray-100;
16+
@apply text-text-2;
1717
}
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
"use client";
12
import React from "react";
3+
import { useRouter } from "next/navigation";
4+
import PeerprepButton from "../shared/PeerprepButton";
25

36
const Matchmaking = () => {
4-
return <div>Matchmaking</div>;
7+
const router = useRouter();
8+
return (
9+
<div className="p-4">
10+
<PeerprepButton onClick={() => router.push(`questions/new`)}>
11+
Add Question
12+
</PeerprepButton>
13+
</div>
14+
);
515
};
616

717
export default Matchmaking;

peerprep/components/questionpage/QuestionCard.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from "react";
33
import { Question, Difficulty } from "@/api/structs";
44
import PeerprepButton from "../shared/PeerprepButton";
55
import { useRouter } from "next/navigation";
6+
import styles from "@/style/questionCard.module.css";
67

78
type QuestionCardProps = {
89
question: Question;
@@ -14,47 +15,48 @@ const QuestionCard: React.FC<QuestionCardProps> = ({ question }) => {
1415
const getDifficultyColor = (difficulty: Difficulty) => {
1516
switch (difficulty) {
1617
case Difficulty.Easy:
17-
return "text-green-500"; // Green for easy
18+
return "text-difficulty-easy"; // Green for easy
1819
case Difficulty.Medium:
19-
return "text-yellow-500"; // Yellow for medium
20+
return "text-difficulty-med"; // Yellow for medium
2021
case Difficulty.Hard:
21-
return "text-red-500"; // Red for hard
22+
return "text-difficulty-hard"; // Red for hard
2223
default:
23-
return "text-gray-100"; // Default color
24+
return "text-secondary-text"; // Default color
2425
}
2526
};
2627

2728
return (
28-
<div className="flex flex-col sm:flex-row items-center w-full h-auto p-4 bg-gray-700 shadow-md rounded-lg mb-4">
29-
<div className="flex-none w-full sm:w-1/3 overflow-hidden">
30-
<h2 className="text-lg font-bold">{question.title}</h2>
31-
<p className="text-sm">
29+
<div className={styles.container}>
30+
<div className="flex-none w-full sm:w-1/3">
31+
<h2 className={styles.title}>{question.title}</h2>
32+
<p className={styles.bodytext}>
3233
Difficulty:{" "}
3334
<span
34-
className={`capitalize ${getDifficultyColor(question.difficulty)}`}
35+
className={`capitalize font-bold ${getDifficultyColor(
36+
question.difficulty
37+
)}`}
3538
>
3639
{Difficulty[question.difficulty]}
3740
</span>
3841
</p>
39-
<p className="text-sm">
42+
<p className={styles.bodytext}>
4043
Categories:{" "}
4144
<span>
4245
{question.categories ? question.categories.join(", ") : "None"}
4346
</span>
4447
</p>
4548
</div>
4649

47-
<div className="flex-none w-full sm:w-1/2 max-h-16 overflow-hidden">
48-
<p className="text-sm text-wrap truncate text-left">
49-
{question.description}
50-
</p>
50+
<div className="flex-none w-full sm:w-1/2 max-h-16">
51+
<p className={styles.bodytext}>{question.description}</p>
5152
</div>
5253

53-
<div className="flex flex-col sm:flex-row ml-0 sm:ml-10 mr-0 sm:mr-10 w-full sm:w-1/6 items-center space-x-0 sm:space-x-2 space-y-2 sm:space-y-0">
54+
<div className={styles.buttonContainer}>
5455
<PeerprepButton onClick={() => router.push(`questions/${question.id}`)}>
5556
View
5657
</PeerprepButton>
5758
<PeerprepButton
59+
// no functionality here yet
5860
onClick={() => console.log(`Deleting question ${question.id}`)}
5961
>
6062
Delete

peerprep/components/questionpage/QuestionList.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const QuestionList: React.FC = () => {
1717
const [categories, setCategories] = useState<string[]>(["all"]);
1818

1919
useEffect(() => {
20-
// uhhhhh this should be changed to fetch on filter/search change
21-
// make use of gateway.ts later
2220
const fetchQuestions = async () => {
2321
try {
2422
const response = await fetch(

peerprep/components/shared/PeerprepButton.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22
import React from "react";
3+
import styles from "@/style/elements.module.css";
34

45
type PeerprepButtonProps = {
56
onClick: () => void;
@@ -13,10 +14,7 @@ const PeerprepButton: React.FC<PeerprepButtonProps> = ({
1314
className,
1415
}) => {
1516
return (
16-
<button
17-
onClick={onClick}
18-
className={`px-4 py-2 text-white bg-gray-600 rounded hover:bg-gray-500 focus:outline-none focus:ring focus:ring-gray-400 ${className}`}
19-
>
17+
<button onClick={onClick} className={`${styles.button} ${className}`}>
2018
{children}
2119
</button>
2220
);

peerprep/components/shared/PeerprepDropdown.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22
import React from "react";
3+
import styles from "@/style/elements.module.css";
34
type PeerprepDropdownProps<T> = {
45
label: string;
56
value: T;
@@ -21,7 +22,7 @@ const PeerprepDropdown = <T extends string | number>({
2122
<select
2223
value={value}
2324
onChange={onChange}
24-
className={`text-black border rounded p-2 focus:outline-none focus:ring-2 focus:ring-gray-300 ${className}`}
25+
className={`${styles.select} ${className}`}
2526
>
2627
{options
2728
.filter((option) => option)

peerprep/components/shared/PeerprepSearchBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// PeerprepSearchBar.tsx
22
import React from "react";
3+
import styles from "@/style/elements.module.css";
34

45
interface PeerprepSearchBarProps {
56
value: string;
@@ -19,7 +20,7 @@ const PeerprepSearchBar: React.FC<PeerprepSearchBarProps> = ({
1920
placeholder={label}
2021
value={value}
2122
onChange={onChange}
22-
className="border border-gray-300 rounded-md p-2 w-full text-black"
23+
className={styles.input}
2324
/>
2425
</div>
2526
);

peerprep/style/elements.module.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*dropdown*/
2+
.select {
3+
@apply text-text-2 bg-gray-1 rounded p-2 focus:outline-none focus:ring-2 focus:ring-highlight focus:fill-highlight;
4+
}
5+
6+
/*button*/
7+
.button {
8+
@apply px-4 py-2 text-text-1 bg-gray-2 rounded hover:bg-gray-3 focus:outline-none focus:ring focus:ring-highlight;
9+
}
10+
11+
/*search*/
12+
.input {
13+
@apply bg-gray-1 rounded-md p-2 w-full text-text-2;
14+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*flex vert if screen is too small*/
2+
.container {
3+
@apply flex flex-col sm:flex-row space-y-4 sm:space-y-0 space-x-0 sm:space-x-4 items-center w-full h-auto p-4 bg-gray-1 shadow-md rounded-lg mb-4;
4+
}
5+
6+
.title {
7+
@apply text-lg font-bold text-text-1;
8+
}
9+
10+
.bodytext {
11+
@apply text-sm text-text-2;
12+
}
13+
14+
.description {
15+
@apply text-sm text-wrap truncate text-left max-h-16 overflow-ellipsis;
16+
}
17+
18+
/*turbo scuff must rewrite!!!!*/
19+
.buttonContainer {
20+
@apply flex flex-col lg:flex-row ml-0 lg:ml-10 mr-0 lg:mr-10 w-full items-center space-x-0 lg:space-x-2 space-y-2 lg:space-y-0 lg:overflow-hidden;
21+
}

peerprep/tailwind.config.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
1-
import type { Config } from 'tailwindcss'
1+
import type { Config } from "tailwindcss";
22

33
const config: Config = {
44
content: [
5-
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
6-
'./components/**/*.{js,ts,jsx,tsx,mdx}',
7-
'./app/**/*.{js,ts,jsx,tsx,mdx}',
5+
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
6+
"./components/**/*.{js,ts,jsx,tsx,mdx}",
7+
"./app/**/*.{js,ts,jsx,tsx,mdx}",
88
],
99
theme: {
1010
extend: {
1111
backgroundImage: {
12-
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
13-
'gradient-conic':
14-
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
12+
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
13+
"gradient-conic":
14+
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
15+
},
16+
/*global theme colors*/
17+
colors: {
18+
"gray-1": "#1e293b",
19+
"gray-2": "#334155",
20+
"gray-3": "#475569",
21+
highlight: "#f8fafc",
22+
"text-1": "#f8fafc",
23+
"text-2": "#e2e8f0",
24+
"difficulty-easy": "#34d399",
25+
"difficulty-med": "#f59e0b",
26+
"difficulty-hard": "#f43f5e",
1527
},
1628
},
1729
},
1830
plugins: [],
19-
}
20-
export default config
31+
};
32+
export default config;

0 commit comments

Comments
 (0)