Skip to content

Commit 3d172dc

Browse files
committed
cleaned up fronten
1 parent 1ff7cd9 commit 3d172dc

File tree

6 files changed

+43
-43
lines changed

6 files changed

+43
-43
lines changed

src/components/AlgorithmForm.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ const AlgorithmForm: React.FC<FormProps> = ({
88
onReset,
99
disabled,
1010
}) => (
11-
<form onSubmit={onSubmit} className="">
11+
<form
12+
onSubmit={onSubmit}
13+
className="mt-4 flex flex-wrap gap-2 justify-center "
14+
>
1215
<div className="mb-4 flex items-center">
1316
<label className="font-bold" htmlFor="algorithm">
1417
Algorithms

src/components/AlgorithmInfo.tsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,33 @@ import type { Info } from "../types/info";
44
// takes in props "info" which is a type defined in types.
55
// since we have sorting and traversal algorithms we can use this
66
// to load in on each page without having to rewrite this
7-
const AlgorithmInfo: React.FC<{ info: Info[] }> = ({ info }) => (
8-
<div className="">
9-
{info.map((info, index) => (
10-
<div key={index} className="w-1/3 p-4">
11-
<h2 className=" text-lg font-bold mb-2">{info.name}</h2>
12-
<p>{info.description}</p>
13-
{info.link && (
14-
<a
15-
href={info.link}
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
className="text-blue-500 hover:text-blue-700"
19-
>
20-
Learn more
21-
</a>
22-
)}
23-
</div>
24-
))}
25-
</div>
7+
const AlgorithmInfo: React.FC<{ info: Info[]; name: string }> = ({
8+
info,
9+
name,
10+
}) => (
11+
<>
12+
<div className="mt-5 w-1/2 mx-auto">
13+
<h2 className="text-center font-bold text-2xl">
14+
About {name} Algorithms
15+
</h2>
16+
{info.map((info, index) => (
17+
<div key={index} className="p-2 m-2 ">
18+
<h2 className=" text-lg font-bold mb-2">{info.name}</h2>
19+
<p>{info.description}</p>
20+
{info.link && (
21+
<a
22+
href={info.link}
23+
target="_blank"
24+
rel="noopener noreferrer"
25+
className="text-blue-500 hover:text-blue-700"
26+
>
27+
Learn more
28+
</a>
29+
)}
30+
</div>
31+
))}
32+
</div>
33+
</>
2634
);
2735

2836
export default AlgorithmInfo;

src/components/Navigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Link } from "react-router-dom";
33
// simple navbar component to be usedon all pages
44
const Navigation = () => {
55
return (
6-
<div className=" p-3 border-b border-gray-300">
6+
<div className="border-b border-gray-300">
77
<div className="flex p-2 mx-auto space-x-4">
88
<Link
99
to="/"

src/components/SortingVisualizer.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ const SortingVisualizer: React.FC<ArrayProps> = ({ arraysInfo }) => {
5858

5959
// the sorting visualizer component
6060
return (
61-
<div className="min-h-screen flex flex-col justify-center items-center">
62-
<div className="array-container mb-4">
61+
<div className="">
62+
<div className="array-container">
6363
{array.map((value, idx) => (
6464
<div
6565
key={idx}
@@ -79,13 +79,8 @@ const SortingVisualizer: React.FC<ArrayProps> = ({ arraysInfo }) => {
7979
disabled={isSorting}
8080
/>
8181

82-
<div className="mt-5">
83-
<h2 className="text-center font-bold text-2xl">
84-
About Sorting Algorithms
85-
</h2>
86-
{/* importing algorithm form component with sorting specific values */}
87-
<AlgorithmInfo info={arraysInfo} />
88-
</div>
82+
{/* importing algorithm form component with sorting specific values */}
83+
<AlgorithmInfo info={arraysInfo} name="Sorting" />
8984
</div>
9085
);
9186
};

src/components/TraversalVisualizer.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ const TraversalVisualizer: React.FC<GraphProps> = ({ graphsInfo }) => {
122122

123123
// the traversal visualizer component
124124
return (
125-
<div className="min-h-screen ">
126-
<div className=" d-flex flex-column mb-4">
125+
<div className=" ">
126+
<div className="">
127127
{matrix.map((row, rowIndex) => (
128128
<div key={rowIndex} className={"matrix-row matrix-row-" + rowIndex}>
129129
{row.map((cell, colIndex) => (
@@ -179,13 +179,8 @@ const TraversalVisualizer: React.FC<GraphProps> = ({ graphsInfo }) => {
179179
onReset={resetMatrix}
180180
disabled={isSorting}
181181
/>
182-
<div className="mt-5">
183-
<h2 className="text-center font-bold text-2xl">
184-
About Traversal Algorithms
185-
</h2>
186-
{/* importing algorithm info component with traversal specific values */}
187-
<AlgorithmInfo info={graphsInfo} />
188-
</div>
182+
{/* importing algorithm info component with traversal specific values */}
183+
<AlgorithmInfo info={graphsInfo} name="Traversal" />
189184
</div>
190185
);
191186
};

src/pages/Visualiser.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const VisualizersPage: React.FC = () => {
88
const [selected, setSelected] = useState<"sorting" | "graph">("sorting"); // declare the default state as string
99

1010
return (
11-
<>
11+
<div className="max-w-6xl mx-auto p-8 px-2">
1212
{/* the selection options for sorting options */}
13-
<div className="flex justify-center m-5 text-white">
13+
<div className="flex mb-6 text-white">
1414
<button
1515
className={`rounded px-4 py-2 ${
1616
selected === "sorting" ? "bg-blue-500" : "bg-gray-500"
@@ -28,7 +28,6 @@ const VisualizersPage: React.FC = () => {
2828
Graph Visualizer
2929
</button>
3030
</div>
31-
3231
{/* if the current state of our variable selected=sorting then we load the
3332
sorting component with its info, otherwise we will load the traversal
3433
visualiser component
@@ -38,7 +37,7 @@ const VisualizersPage: React.FC = () => {
3837
) : (
3938
<TraversalVisualizer graphsInfo={graphsInfo} />
4039
)}
41-
</>
40+
</div>
4241
);
4342
};
4443

0 commit comments

Comments
 (0)