-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from AdiletBaimyrza/adilet/canvas-navbar-styling
Adilet/canvas navbar styling
- Loading branch information
Showing
18 changed files
with
151 additions
and
69 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
dijkstra-prim-visualization/src/components/Canvas/Canvas.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
.canvas { | ||
background-color: black; | ||
cursor: crosshair; | ||
height: 100%; | ||
width: 100%; | ||
}/*# sourceMappingURL=Canvas.module.css.map */ |
2 changes: 1 addition & 1 deletion
2
dijkstra-prim-visualization/src/components/Canvas/Canvas.module.css.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
dijkstra-prim-visualization/src/components/Canvas/Canvas.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
.canvas { | ||
background-color: black; | ||
cursor: crosshair; | ||
height: 100%; | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
dijkstra-prim-visualization/src/components/Canvas/Edges/Edge/Edge.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.line { | ||
stroke: #ff0000; | ||
stroke-width: 2; | ||
transition: all 0.5s linear; | ||
}/*# sourceMappingURL=Edge.module.css.map */ |
2 changes: 1 addition & 1 deletion
2
dijkstra-prim-visualization/src/components/Canvas/Edges/Edge/Edge.module.css.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
dijkstra-prim-visualization/src/components/Canvas/Edges/Edge/Edge.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.line { | ||
stroke: #ff0000; | ||
stroke-width: 2; | ||
transition: all 0.5s linear; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
dijkstra-prim-visualization/src/components/Canvas/Nodes/Node/Node.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
.node { | ||
cursor: pointer; | ||
} | ||
|
||
.circle { | ||
stroke: #fff; | ||
stroke-width: 1.5; | ||
cursor: pointer; | ||
stroke-width: 2; | ||
fill: #fff; | ||
transition: all 0.2s linear; | ||
} | ||
|
||
.text { | ||
color: black; | ||
}/*# sourceMappingURL=Node.module.css.map */ |
2 changes: 1 addition & 1 deletion
2
dijkstra-prim-visualization/src/components/Canvas/Nodes/Node/Node.module.css.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
11 changes: 9 additions & 2 deletions
11
dijkstra-prim-visualization/src/components/Canvas/Nodes/Node/Node.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
.node { | ||
cursor: pointer; | ||
} | ||
|
||
.circle { | ||
stroke: #fff; | ||
stroke-width: 1.5; | ||
cursor: pointer; | ||
stroke-width: 2; | ||
fill: #fff; | ||
transition: all 0.2s linear; | ||
} | ||
|
||
.text { | ||
color: black; | ||
} |
36 changes: 11 additions & 25 deletions
36
dijkstra-prim-visualization/src/components/Navbar/Navbar.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
dijkstra-prim-visualization/src/components/Navbar/NavbarUtils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { primWrapper } from "../../algorithms/prim"; | ||
import { dijkstraWrapper } from "../../algorithms/dijkstra"; | ||
|
||
const runPrim = (nodes, edges) => { | ||
const result = primWrapper(nodes, edges); | ||
console.log(result); | ||
const edgeIds = getEdgeIDs(result.steps); | ||
|
||
return edgeIds; | ||
}; | ||
|
||
const runDijkstra = (nodes, edges) => { | ||
const result = dijkstraWrapper(nodes, edges); | ||
console.log(result); | ||
const edgeIds = getEdgeIDs(result.steps); | ||
|
||
return edgeIds; | ||
}; | ||
|
||
/** | ||
* Returns an array of edge IDs based on the given steps. | ||
* @param {Array} steps - The steps array. | ||
* @returns {Array} - The array of edge IDs. | ||
*/ | ||
const getEdgeIDs = (steps) => { | ||
if (!Array.isArray(steps)) { | ||
console.error("Invalid argument: steps must be an array"); | ||
return; | ||
} | ||
|
||
return steps.map((step) => { | ||
const edgeCandidateOne = document.getElementById(`${step.from}-${step.to}`); | ||
|
||
return edgeCandidateOne | ||
? `${step.from}-${step.to}` | ||
: `${step.to}-${step.from}`; // edgeCandidateTwo | ||
}); | ||
}; | ||
|
||
export { runPrim, runDijkstra }; |
38 changes: 38 additions & 0 deletions
38
dijkstra-prim-visualization/src/components/Navbar/animations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
|
||
/** | ||
* Starts the animations for the given edge IDs. | ||
* @param {string[]} edgeIds - The IDs of the edges to animate. | ||
* @returns {Promise<void>} - A promise that resolves when the animations are complete. | ||
*/ | ||
const startAnimations = async (edgeIds) => { | ||
const changeStrokeColor = async (edgeIds) => { | ||
for (const id of edgeIds) { | ||
const edge = document.getElementById(id); | ||
edge.style.stroke = "green"; | ||
edge.style.strokeWidth = "10"; | ||
|
||
await sleep(1000); | ||
} | ||
|
||
for (const id of edgeIds) { | ||
const edge = document.getElementById(id); | ||
edge.style.stroke = "violet"; | ||
} | ||
|
||
await sleep(3000); | ||
}; | ||
|
||
const resetColors = async (edgeIds) => { | ||
for (const id of edgeIds) { | ||
const edge = document.getElementById(id); | ||
edge.style.stroke = "red"; | ||
edge.style.strokeWidth = "2"; | ||
} | ||
}; | ||
|
||
await changeStrokeColor(edgeIds); | ||
await resetColors(edgeIds); | ||
}; | ||
|
||
export { startAnimations }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters