add mobile-banner component and conditional render on window-width
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<banner />
|
||||
<banner v-if="!mobileView"/>
|
||||
<MobileBanner v-if="mobileView" />
|
||||
<router-view />
|
||||
<UpdateToast
|
||||
v-if="showToast"
|
||||
@@ -15,18 +16,23 @@
|
||||
import ServiceWorkerMixin from "@/mixins/ServiceWorkerMixin";
|
||||
import banner from "@/ui/Banner";
|
||||
import UpdateToast from "@/ui/UpdateToast";
|
||||
import MobileBanner from "@/ui/MobileBanner";
|
||||
|
||||
export default {
|
||||
name: "vinlottis",
|
||||
components: { banner, UpdateToast },
|
||||
components: { banner, UpdateToast, MobileBanner },
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
showToast: false,
|
||||
toastText: null,
|
||||
refreshToast: false
|
||||
refreshToast: false,
|
||||
mobileView: false
|
||||
};
|
||||
},
|
||||
beforeMount(){
|
||||
this.handleView()
|
||||
},
|
||||
mounted() {
|
||||
console.log("SNEAKY PETE!");
|
||||
this.$on("service-worker-updated", () => {
|
||||
@@ -45,6 +51,10 @@ export default {
|
||||
methods: {
|
||||
closeToast: function() {
|
||||
this.showToast = false;
|
||||
},
|
||||
handleView(){
|
||||
console.log(window.innerWidth <= 768)
|
||||
this.mobileView = window.innerWidth <= 768;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -174,22 +174,6 @@ export default {
|
||||
.__routes{
|
||||
text-decoration: none;
|
||||
color: #333333;
|
||||
|
||||
@include mobile {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@include mobile {
|
||||
padding: 0px 40px;
|
||||
|
||||
> img {
|
||||
height: 23px;
|
||||
}
|
||||
|
||||
// .__routes{
|
||||
// display: none;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
108
src/ui/MobileBanner.vue
Normal file
108
src/ui/MobileBanner.vue
Normal file
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<main>
|
||||
<div class="top-banner">
|
||||
<span class="burger-menu" @click="toggleShowMenu">
|
||||
<svg viewBox="0 0 100 80" width="40" height="40">
|
||||
<rect width="100" height="14"></rect>
|
||||
<rect y="30" width="100" height="14"></rect>
|
||||
<rect y="60" width="100" height="14"></rect>
|
||||
</svg>
|
||||
</span>
|
||||
<router-link to="/" class="link">
|
||||
<img src="/public/assets/images/knowit.svg" alt="knowit logo" />
|
||||
</router-link>
|
||||
</div>
|
||||
<section v-if="toggleMenu" class="route-container">
|
||||
<div v-for="(route, index) in routes" :key="index" class="__routes">
|
||||
<router-link :to="route.route" class="_specific">
|
||||
{{route.name}}
|
||||
</router-link>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
toggleMenu: false,
|
||||
routes: [
|
||||
{
|
||||
name: "Dagens viner",
|
||||
route: "/dagens/"
|
||||
},
|
||||
{
|
||||
name: "History",
|
||||
route: "/history/"
|
||||
},
|
||||
{
|
||||
name: "Lotteriet",
|
||||
route: "/lottery/game/"
|
||||
},
|
||||
// {
|
||||
// name: "Foreslå vin",
|
||||
// route: "/request"
|
||||
// },
|
||||
// {
|
||||
// name: "Foreslåtte viner",
|
||||
// route: "/all-requested-wines"
|
||||
// },
|
||||
]
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
toggleShowMenu(){
|
||||
this.toggleMenu = this.toggleMenu ? false : true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "../styles/variables.scss";
|
||||
|
||||
.link {
|
||||
text-decoration: none;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.top-banner {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 0px;
|
||||
background-color: $primary;
|
||||
-webkit-box-shadow: 0px 0px 22px -8px rgba(0, 0, 0, 0.65);
|
||||
-moz-box-shadow: 0px 0px 22px -8px rgba(0, 0, 0, 0.65);
|
||||
box-shadow: 0px 0px 22px -8px rgba(0, 0, 0, 0.65);
|
||||
padding: 0px 10px;
|
||||
|
||||
img {
|
||||
height: 23px;
|
||||
}
|
||||
|
||||
.__routes{
|
||||
text-decoration: none;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
.route-container{
|
||||
background-color: $primary;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
|
||||
.__routes{
|
||||
margin: 10px;
|
||||
._specific {
|
||||
text-decoration: none;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user