Skip to content

Commit 5ddf47d

Browse files
authored
Merge pull request #21 from Dana94/feature/fix-modal-spacing
Remove modal
2 parents 0755c53 + a12e1ed commit 5ddf47d

12 files changed

+166
-154
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The game can be solely accessed through the keyboard alone.
1010

1111
1. Clone the repo: `git clone https://github.com/Dana94/lights-puzzle.git`
1212
1. `cd lights-puzzle`
13-
1. `npm install`
13+
1. `npm install`
1414
1. `npm run dev` to start a local dev server at `http://localhost:8080`
1515

1616
## Build Setup
@@ -27,4 +27,3 @@ npm run build
2727
```
2828
## Notes
2929
- Styled with [Vuetify](https://vuetifyjs.com/en/).
30-
- Modal used is a [SweetModal](https://github.com/adeptoas/sweet-modal-vue).

package-lock.json

-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
1111
},
1212
"dependencies": {
13-
"sweet-modal-vue": "^2.0.0",
1413
"vue": "^2.5.11",
1514
"vuetify": "^1.5.23",
1615
"vuex": "^3.1.1"

src/App.vue

+28-35
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
<template>
22
<div id="app">
3-
<v-container v-if="!levelSelected">
4-
<v-layout align-center column>
5-
<Home />
6-
</v-layout>
3+
<v-container v-if="!levelSelected && !isGameWon">
4+
<Home />
5+
</v-container>
6+
<v-container v-else-if="isGameWon">
7+
<EndGame />
78
</v-container>
89
<v-container v-else>
9-
<v-layout align-center column>
10-
<v-flex xs12>
11-
<Rules />
12-
</v-flex>
13-
</v-layout>
14-
<v-layout align-center column>
15-
<v-flex xs12 class="board-container">
16-
<Board :level="level" :board="board" />
17-
</v-flex>
18-
</v-layout>
19-
<v-layout row wrap> </v-layout>
10+
<Rules />
11+
<Board :level="level" :board="board" />
2012
</v-container>
2113
</div>
2214
</template>
@@ -25,6 +17,7 @@
2517
import Board from "./components/Board.vue";
2618
import Rules from "./components/Rules.vue";
2719
import Home from "./components/Home.vue";
20+
import EndGame from "./components/EndGame.vue";
2821
2922
export default {
3023
name: "app",
@@ -39,6 +32,9 @@ export default {
3932
},
4033
levelSelected() {
4134
return this.level !== 0;
35+
},
36+
isGameWon() {
37+
return this.$store.getters.isGameWon;
4238
}
4339
},
4440
watch: {
@@ -51,7 +47,8 @@ export default {
5147
components: {
5248
Board,
5349
Rules,
54-
Home
50+
Home,
51+
EndGame
5552
}
5653
};
5754
</script>
@@ -69,27 +66,23 @@ export default {
6966
display: flex;
7067
justify-content: center;
7168
72-
.board-container {
73-
position: relative;
74-
75-
// for some reason the stats component button styles aren't displaying when declared in the Stats.vue file
76-
// that's why they are here instead
77-
.stats {
78-
position: absolute;
79-
right: -9rem;
80-
top: 0;
81-
display: flex;
82-
flex-direction: column;
69+
// for some reason the stats component button styles aren't displaying when declared in the Stats.vue file
70+
// that's why they are here instead
71+
.stats {
72+
position: absolute;
73+
right: -9rem;
74+
top: 0;
75+
display: flex;
76+
flex-direction: column;
8377
84-
.reset {
85-
background-color: $purple;
86-
color: $white;
87-
}
78+
.reset {
79+
background-color: $purple;
80+
color: $white;
81+
}
8882
89-
.end {
90-
background-color: $blue;
91-
color: $white;
92-
}
83+
.end {
84+
background-color: $blue;
85+
color: $white;
9386
}
9487
}
9588
}

src/components/Board.vue

+25-15
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,44 @@
11
<template>
2-
<div class="board">
3-
<row v-for="(row, x) in board" :key="x" :row="row" :index_x="x" :level="level"></row>
4-
<modal :showModal="showModal" @closeModal="showModal = false"/>
5-
<stats />
6-
</div>
2+
<v-layout align-center column>
3+
<v-flex xs12 class="board-container">
4+
<div class="board">
5+
<row
6+
v-for="(row, x) in board"
7+
:key="x"
8+
:row="row"
9+
:index_x="x"
10+
:level="level"
11+
></row>
12+
<stats />
13+
</div>
14+
</v-flex>
15+
</v-layout>
716
</template>
817

918
<script>
1019
import Row from "./Row.vue";
11-
import Stats from './Stats.vue';
12-
import Modal from './Modal.vue';
20+
import Stats from "./Stats.vue";
1321
import { eventBus } from "../main";
1422
1523
export default {
16-
props: ['level', 'board'],
24+
props: ["level", "board"],
1725
data() {
1826
return {
19-
checkBoard: false,
20-
gameWon: false,
21-
showModal: false
27+
checkBoard: false
2228
};
2329
},
2430
watch: {
2531
checkBoard() {
2632
if (this.$store.getters.gameWon({ check: this.checkBoard })) {
2733
setTimeout(() => {
28-
this.showModal = true;
34+
this.$store.dispatch("setGameProgress", { gameWon: true });
2935
}, 500);
3036
}
3137
}
3238
},
3339
components: {
3440
Row,
35-
Stats,
36-
Modal
41+
Stats
3742
},
3843
created() {
3944
// check if game is done
@@ -45,11 +50,16 @@ export default {
4550
</script>
4651

4752
<style lang="scss" scoped>
53+
@import "../assets/base.scss";
54+
4855
p {
4956
display: none;
5057
&.show {
5158
display: block;
5259
}
5360
}
54-
</style>
5561
62+
.board-container {
63+
position: relative;
64+
}
65+
</style>

src/components/Column.vue

-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ import store from "../store/store";
2121
2222
export default {
2323
props: ["index_y", "index_x"],
24-
data() {
25-
return {
26-
};
27-
},
2824
methods: {
2925
changeStatus() {
3026
this.$store.dispatch("increaseCount");

src/components/EndGame.vue

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<template>
2+
<v-layout align-center column>
3+
<div>
4+
<h1 class="mb-2">You solved level {{ level }} in {{ moves }} moves!</h1>
5+
<p class="title">What do you want to do next?</p>
6+
<div>
7+
<v-btn class="end" @click="end">Try Another Level</v-btn>
8+
<v-btn class="reset" @click="reset">Play Again</v-btn>
9+
</div>
10+
</div>
11+
</v-layout>
12+
</template>
13+
14+
<script>
15+
export default {
16+
name: "EndGame",
17+
methods: {
18+
end() {
19+
this.$store.dispatch("endGame");
20+
},
21+
reset() {
22+
this.$store.dispatch("reset");
23+
}
24+
},
25+
computed: {
26+
moves() {
27+
return this.$store.getters.getMoves;
28+
},
29+
level() {
30+
return this.$store.getters.getLevel;
31+
}
32+
}
33+
};
34+
</script>
35+
36+
<style lang="scss" scoped>
37+
@import "../assets/base.scss";
38+
39+
.reset {
40+
background-color: $purple !important;
41+
color: $white !important;
42+
}
43+
44+
.end {
45+
background-color: $green !important;
46+
color: $white !important;
47+
}
48+
</style>

src/components/Home.vue

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
<template>
2-
<div>
3-
<h1 class="display-1 mb-3">Choose a Level</h1>
4-
<v-btn class="level1" @click="level = 1">Level 1</v-btn>
5-
<v-btn class="level2" @click="level = 2">Level 2</v-btn>
6-
<v-btn class="level3" @click="level = 3">Level 3</v-btn>
7-
</div>
2+
<v-layout align-center column>
3+
<div>
4+
<h1 class="display-1 mb-3">Choose a Level</h1>
5+
<v-btn class="level1" @click="level = 1">Level 1</v-btn>
6+
<v-btn class="level2" @click="level = 2">Level 2</v-btn>
7+
<v-btn class="level3" @click="level = 3">Level 3</v-btn>
8+
</div>
9+
</v-layout>
810
</template>
911

1012
<script>
1113
export default {
12-
data () {
14+
data() {
1315
return {
1416
level: 0
15-
}
17+
};
1618
},
1719
watch: {
18-
level () {
19-
this.$store.dispatch('setLevel', this.level);
20+
level() {
21+
this.$store.dispatch("setLevel", this.level);
2022
}
2123
}
22-
}
24+
};
2325
</script>
2426

2527
<style lang="scss">

src/components/Modal.vue

-58
This file was deleted.

src/components/Row.vue

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
<template>
2-
<div class="row" :class="{ rowLevel1: level === 1, rowLevel2: level === 2, rowLevel3: level === 3 }">
3-
<column v-for="(col, j) in row" :key="j" :index_y="j" :index_x="index_x"></column>
2+
<div
3+
class="row"
4+
:class="{
5+
rowLevel1: level === 1,
6+
rowLevel2: level === 2,
7+
rowLevel3: level === 3
8+
}"
9+
>
10+
<column
11+
v-for="(col, j) in row"
12+
:key="j"
13+
:index_y="j"
14+
:index_x="index_x"
15+
></column>
416
</div>
517
</template>
618

719
<script>
820
import Column from "./Column.vue";
921
export default {
10-
props: ['row', 'index_x', 'level'],
22+
props: ["row", "index_x", "level"],
1123
components: {
1224
Column
1325
}

0 commit comments

Comments
 (0)