Skip to content

Commit db8081f

Browse files
committed
add tutorial and fixing dropdown
1 parent 1e05180 commit db8081f

File tree

13 files changed

+297
-26
lines changed

13 files changed

+297
-26
lines changed

src/App.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
<Navbar />
44
<pathfinding-visualizer />
55
<Aboutme />
6+
<Tutorial />
67
</div>
78
</template>
89

910
<script>
1011
import PathfindingVisualizer from "./components/PathfindingVisualizer.vue";
1112
import Navbar from "./components/Navbar.vue";
1213
import Aboutme from "./components/Aboutme.vue";
14+
import Tutorial from "./components/Tutorial";
1315
export default {
14-
components: { PathfindingVisualizer, Navbar, Aboutme },
16+
components: { PathfindingVisualizer, Navbar, Aboutme, Tutorial },
1517
};
1618
</script>
1719
<style lang="scss">
@@ -27,4 +29,8 @@ export default {
2729
box-sizing: border-box;
2830
font-family: "Poppins", sans-serif;
2931
}
32+
33+
body {
34+
overflow-x: hidden;
35+
}
3036
</style>

src/assets/addWall.gif

400 KB
Loading

src/assets/navbar.jpg

65.5 KB
Loading

src/assets/navbar.png

20.5 KB
Loading

src/assets/navigation.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/welcome.svg

Lines changed: 1 addition & 0 deletions
Loading

src/components/Aboutme.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export default {};
2929
justify-content: center;
3030
margin-top: 1rem;
3131
font-size: 2rem;
32-
opacity: 0.6;
3332
3433
.twitter a:hover:before {
3534
opacity: 1;
@@ -90,6 +89,11 @@ export default {};
9089
9190
.sign {
9291
margin-right: 2rem;
92+
opacity: 0.6;
93+
94+
&:hover {
95+
opacity: 1;
96+
}
9397
9498
a {
9599
color: #313131;

src/components/Navbar.vue

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
<nav class="navbar">
44
<div class="select-algo">
55
<span>Algorithm : </span>
6-
<select name="algorithm" id="algorithm" @change="changeSelectedAlgo">
7-
<option value="dijkstra" selected>Dijkstra</option>
8-
<option value="astar">A*</option>
9-
</select>
6+
<span class="box">
7+
<span class="result" @click="openAlgoList">
8+
<p>{{ selectedAlgorithm }}</p>
9+
<span class="triangle" ref="triangle"></span>
10+
</span>
11+
<ul class="ul-list" v-if="isShowingAlgoList">
12+
<li @click="changeSelectedAlgo('A* Search')">A* Search</li>
13+
<li @click="changeSelectedAlgo('Dijkstra')">Dijkstra</li>
14+
</ul>
15+
</span>
1016
</div>
1117
<button ref="visualize" class="run-btn start">Visualize !</button>
1218
<button ref="clear" class="clear-btn start">Clear Board !</button>
@@ -42,16 +48,24 @@
4248
export default {
4349
data() {
4450
return {
45-
selectedAlgorithm: "dijkstra",
51+
selectedAlgorithm: "Dijkstra",
52+
isShowingAlgoList: false,
4653
};
4754
},
4855
mounted() {
4956
this.$store.state.runBtn = this.$refs.visualize;
5057
this.$store.state.clearBtn = this.$refs.clear;
5158
},
5259
methods: {
53-
changeSelectedAlgo(e) {
54-
this.$store.state.selectedAlgorithm = e.target.value;
60+
changeSelectedAlgo(val) {
61+
this.$store.state.selectedAlgorithm = val;
62+
this.selectedAlgorithm = val;
63+
this.isShowingAlgoList = false;
64+
this.$refs.triangle.classList.remove("flip");
65+
},
66+
openAlgoList() {
67+
this.isShowingAlgoList = true;
68+
this.$refs.triangle.classList.add("flip");
5569
},
5670
},
5771
};

src/components/PathfindingVisualizer.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ export default {
6464
];
6565
let test = bidirectionalDijkstra(this.grid, startNode, finishNode);
6666
console.log(test);
67+
console.log(this.$store.state.selectedAlgorithm.toLowerCase());
6768
this.resetVisitedGrid();
68-
if (this.$store.state.selectedAlgorithm === "astar") {
69+
if (this.$store.state.selectedAlgorithm.toLowerCase() === "a* search") {
6970
this.runAstarAlgo();
70-
} else if (this.$store.state.selectedAlgorithm === "dijkstra") {
71+
} else if (
72+
this.$store.state.selectedAlgorithm.toLowerCase() === "dijkstra"
73+
) {
7174
this.runDijkstraAlgo();
7275
}
7376
},
@@ -210,7 +213,7 @@ export default {
210213
// flex-wrap: wrap;
211214
justify-content: center;
212215
align-items: center;
213-
min-width: 1000px;
216+
// border: 1px solid red;
214217
}
215218
216219
.container {
@@ -220,6 +223,9 @@ export default {
220223
justify-content: center;
221224
align-items: center;
222225
margin-top: 2rem;
226+
max-width: 1000px;
227+
min-width: 800px;
228+
margin: 2rem auto 0 auto;
223229
224230
&.active {
225231
pointer-events: none;

src/components/Tutorial.vue

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<template>
2+
<div>
3+
<div class="container" v-if="isShowTutorial">
4+
<div class="tutorial">
5+
<h1 class="title">{{ setPagesData.Title }}</h1>
6+
<p class="description">{{ setPagesData.description }}</p>
7+
8+
<img
9+
:src="require(`../assets/${setPagesData.img}`)"
10+
class="img"
11+
alt=""
12+
/>
13+
14+
<div class="buttons">
15+
<div class="left-side">
16+
<button class="Skip btn" @click="isShowTutorial = false">
17+
Skip tutorial
18+
</button>
19+
</div>
20+
<div class="right-side">
21+
<button
22+
class="btn previous"
23+
@click="currentPage--"
24+
:disabled="currentPage > 0 ? false : true"
25+
>
26+
Back
27+
</button>
28+
<button
29+
class="btn next"
30+
@click="currentPage++"
31+
:disabled="currentPage < pagesData.length - 1 ? false : true"
32+
>
33+
Next
34+
</button>
35+
</div>
36+
</div>
37+
</div>
38+
</div>
39+
<div
40+
class="tutorial-icon"
41+
v-if="!isShowTutorial"
42+
@click="isShowTutorial = true"
43+
>
44+
<div class="icon">
45+
<i class="fas fa-lightbulb"></i>
46+
</div>
47+
<p>Tutorial</p>
48+
</div>
49+
</div>
50+
</template>
51+
52+
<script>
53+
export default {
54+
data() {
55+
return {
56+
currentPage: 0,
57+
isShowTutorial: true,
58+
pagesData: [
59+
{
60+
Title: "Welcome to Pathfinding Visualizer !",
61+
description:
62+
'If you want to dive right in, feel free to press the "Skip Tutorial" button below. Otherwise, press "Next"!',
63+
imgLink: "https://storyset.com/people",
64+
img: "welcome.svg",
65+
},
66+
{
67+
Title: "What is a pathfinding algorithm?",
68+
description:
69+
"Pathfinding algorithm is an algorithm that used to find shortest path between two points.",
70+
imgLink: "https://storyset.com/city",
71+
img: "navigation.svg",
72+
},
73+
{
74+
Title: "Using the Navigation bar",
75+
description:
76+
"You can pick the type of the algorithm and start visualizing the algorithm from the navigation bar. You can clear the board like previous path and wall by clicking the clear board button.",
77+
img: "navbar.jpg",
78+
},
79+
{
80+
Title: "Adding Walls",
81+
description:
82+
"Click the grid to add a wall, hold the click and move your mouse to add more wall. Walls are impenetrable, meaning that a path cannot cross through them.",
83+
img: "addWall.gif",
84+
},
85+
],
86+
};
87+
},
88+
89+
computed: {
90+
setPagesData() {
91+
return this.pagesData[this.currentPage];
92+
},
93+
},
94+
};
95+
</script>
96+
97+
<style scoped lang="scss" src="../scss/Tutorial.scss"></style>

0 commit comments

Comments
 (0)