Create settings page

This commit is contained in:
Hamcha 2019-09-18 15:00:53 +02:00
parent 94e1eef91e
commit 00c43b5936
Signed by: hamcha
GPG key ID: 44AD3571EB09A39E
4 changed files with 88 additions and 31 deletions

View file

@ -1,18 +1,36 @@
<template> <template>
<nav> <nav>
<section class="pages">
<router-link <router-link
:class="routeClass(route)" :class="routeClass(route)"
v-for="route in routes" v-for="route in mainRoutes"
:key="route" :key="route"
:to="{ name: route }" :to="{ name: route }"
>{{ prettyTitle(route) }}</router-link >{{ prettyTitle(route) }}</router-link
> >
</section>
<section class="icons">
<router-link
:class="routeClass(route)"
v-for="route in iconRoutes"
:key="route"
:to="{ name: route }"
><b-icon
:icon="prettyTitle(route)"
class="route-icon"
custom-size="mdi-36px"
/></router-link>
</section>
</nav> </nav>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "@/assets/scss/_variables.scss"; @import "@/assets/scss/_variables.scss";
.route-icon {
width: 50px;
}
nav { nav {
margin-bottom: 1rem; margin-bottom: 1rem;
display: flex; display: flex;
@ -22,13 +40,23 @@ nav {
rgba(100, 180, 255, 0.1) rgba(100, 180, 255, 0.1)
); );
.pages {
flex: 1;
display: flex;
}
.icons {
flex-grow: 0;
display: flex;
}
.entry { .entry {
flex: 1; flex: 1;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 50px; height: 50px;
max-width: 300px; max-width: 250px;
text-align: center; text-align: center;
color: $grey-lighter; color: $grey-lighter;
@ -61,17 +89,20 @@ nav {
<script lang="ts"> <script lang="ts">
import { Component, Vue } from "vue-property-decorator"; import { Component, Vue } from "vue-property-decorator";
const routes = ["lobby", "deck-editor"]; const mainRoutes = ["lobby", "deck-editor"];
const iconRoutes = ["settings"];
@Component({ @Component({
components: {} components: {}
}) })
export default class TopNav extends Vue { export default class TopNav extends Vue {
private routes!: string[]; private mainRoutes!: string[];
private iconRoutes!: string[];
private data() { private data() {
return { return {
routes mainRoutes,
iconRoutes
}; };
} }

View file

@ -6,6 +6,7 @@ import GameView from "@/views/Game.vue";
import DraftView from "@/views/Draft.vue"; import DraftView from "@/views/Draft.vue";
import Lobby from "@/views/Lobby.vue"; import Lobby from "@/views/Lobby.vue";
import RoomView from "@/views/Room.vue"; import RoomView from "@/views/Room.vue";
import SettingsView from "@/views/Settings.vue";
Vue.use(Router); Vue.use(Router);
@ -48,6 +49,14 @@ export default new Router({
path: "/room", path: "/room",
name: "room", name: "room",
component: RoomView component: RoomView
},
{
path: "/settings",
name: "settings",
component: SettingsView,
meta: {
topnav: "settings"
}
} }
] ]
}); });

View file

@ -16,30 +16,11 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue } from "vue-property-decorator"; import { Component, Vue } from "vue-property-decorator";
import TopNav from "@/components/Navigation/TopNav.vue"; import TopNav from "@/components/Navigation/TopNav.vue";
import { TaskRunner } from "@/workers";
@Component({ @Component({
components: { components: {
TopNav TopNav
} }
}) })
export default class Lobby extends Vue { export default class Lobby extends Vue {}
private mounted() {
const worker = new TaskRunner("downloadCardImages");
worker.on("dl-progress", progress => {
console.log(
`Download progress: ${progress.progress}/${
progress.total
}b (${Math.round((progress.progress * 100) / progress.total)}%)`
);
});
worker.on("ex-progress", progress => {
console.log(
`Extraction progress: ${progress.progress}/${
progress.total
}b (${Math.round((progress.progress * 100) / progress.total)}%)`
);
});
}
}
</script> </script>

36
src/views/Settings.vue Normal file
View file

@ -0,0 +1,36 @@
<template>
<section class="settings">
<TopNav />
</section>
</template>
<style lang="scss" scoped></style>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import TopNav from "@/components/Navigation/TopNav.vue";
import { TaskRunner } from "@/workers";
@Component({
components: { TopNav }
})
export default class SettingsView extends Vue {
private downloadSets() {
const worker = new TaskRunner("downloadCardImages");
worker.on("dl-progress", progress => {
console.log(
`Download progress: ${progress.progress}/${
progress.total
}b (${Math.round((progress.progress * 100) / progress.total)}%)`
);
});
worker.on("ex-progress", progress => {
console.log(
`Extraction progress: ${progress.progress}/${
progress.total
}b (${Math.round((progress.progress * 100) / progress.total)}%)`
);
});
}
}
</script>