Skip to content

Commit 24a9f8a

Browse files
committed
adding comments
1 parent 0f2ae81 commit 24a9f8a

File tree

7 files changed

+34
-17
lines changed

7 files changed

+34
-17
lines changed

src/components/AlgorithmForm.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { Form, Button } from "react-bootstrap";
2+
import type { FormProps } from "../types/formProps";
23

3-
type Props = {
4-
value: string;
5-
options: string[];
6-
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
7-
onSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
8-
onReset: () => void;
9-
disabled?: boolean;
10-
};
4+
// type Props = {
5+
// value: string;
6+
// options: string[];
7+
// onChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
8+
// onSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
9+
// onReset: () => void;
10+
// disabled?: boolean;
11+
// };
1112

12-
const AlgorithmForm: React.FC<Props> = ({
13+
const AlgorithmForm: React.FC<FormProps> = ({
1314
value,
1415
options,
1516
onChange,

src/components/AlgorithmInfo.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { Card, Col, Row } from "react-bootstrap";
22
import type { Info } from "../types/info";
33

4-
const AlgorithmInfo: React.FC<{ items: Info[] }> = ({ items }) => (
4+
// Algorithm info component to display info on the algorithms.
5+
// takes in props "info" which is a type defined in types.
6+
// since we have sorting and traversal algorithms we can use this
7+
// to load in on each page without having to rewrite this
8+
const AlgorithmInfo: React.FC<{ info: Info[] }> = ({ info }) => (
59
<Row>
6-
{items.map((item, index) => (
10+
{info.map((info, index) => (
711
<Col md={6} key={index} className="mb-4">
812
<Card className="h-100 shadow-sm">
913
<Card.Body>
10-
<Card.Title>{item.name}</Card.Title>
11-
<Card.Text>{item.description}</Card.Text>
12-
{item.link && (
14+
<Card.Title>{info.name}</Card.Title>
15+
<Card.Text>{info.description}</Card.Text>
16+
{info.link && (
1317
<Card.Link
14-
href={item.link}
18+
href={info.link}
1519
target="_blank"
1620
rel="noopener noreferrer"
1721
>

src/components/GraphLegend.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Graph legend component. Only imported in traversal visualiser
12
const GraphLengend = () => {
23
return (
34
<>

src/components/Navigation.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Navbar, Nav, Container } from "react-bootstrap";
22
import { Link } from "react-router-dom";
33

4+
// simple navbar component to be usedon all pages
45
const Navigation = () => {
56
return (
67
<Navbar bg="dark" variant="dark" expand="md" collapseOnSelect>

src/components/SortingVisualizer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const SortingVisualizer: React.FC<ArrayProps> = ({ arraysInfo }) => {
5353
setIsSorting(false);
5454
};
5555

56+
// the sorting visualizer component
5657
return (
5758
<Container className="d-flex flex-column justify-content-center align-items-center min-vh-100">
5859
<div className="array-container mb-4">
@@ -78,7 +79,7 @@ const SortingVisualizer: React.FC<ArrayProps> = ({ arraysInfo }) => {
7879

7980
<Container className="mt-5">
8081
<h2 className="text-center mb-4">About Sorting Algorithms</h2>
81-
<AlgorithmInfo items={arraysInfo} />
82+
<AlgorithmInfo info={arraysInfo} />
8283
</Container>
8384
</Container>
8485
);

src/components/TraversalVisualizer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ const TraversalVisualizer: React.FC<GraphProps> = ({ graphsInfo }) => {
115115
setIsSorting(false);
116116
};
117117

118+
// the traversal visualizer component
118119
return (
119120
<div className="GraphTraversalVisualiser container d-flex flex-column align-items-center py-4">
120121
<div className="matrix-container d-flex flex-column mb-4">
@@ -173,7 +174,7 @@ const TraversalVisualizer: React.FC<GraphProps> = ({ graphsInfo }) => {
173174
/>
174175
<Container className="mt-5">
175176
<h2 className="text-center mb-4">About Traversal Algorithms</h2>
176-
<AlgorithmInfo items={graphsInfo} />
177+
<AlgorithmInfo info={graphsInfo} />
177178
</Container>
178179
</div>
179180
);

src/types/formProps.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export type FormProps = {
2+
value: string;
3+
options: string[];
4+
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
5+
onSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
6+
onReset: () => void;
7+
disabled?: boolean;
8+
};

0 commit comments

Comments
 (0)