File tree Expand file tree Collapse file tree 7 files changed +34
-17
lines changed Expand file tree Collapse file tree 7 files changed +34
-17
lines changed Original file line number Diff line number Diff line change 11import { 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,
Original file line number Diff line number Diff line change 11import { Card , Col , Row } from "react-bootstrap" ;
22import 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 >
Original file line number Diff line number Diff line change 1+ // Graph legend component. Only imported in traversal visualiser
12const GraphLengend = ( ) => {
23 return (
34 < >
Original file line number Diff line number Diff line change 11import { Navbar , Nav , Container } from "react-bootstrap" ;
22import { Link } from "react-router-dom" ;
33
4+ // simple navbar component to be usedon all pages
45const Navigation = ( ) => {
56 return (
67 < Navbar bg = "dark" variant = "dark" expand = "md" collapseOnSelect >
Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff line change 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+ } ;
You can’t perform that action at this time.
0 commit comments