mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Make 'isMobile' aka 'showMobileMenu' a mixin
This commit is contained in:
parent
c26a037007
commit
12663cbf09
@ -1,14 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="layout-default">
|
<div class="layout-default">
|
||||||
<div class="main-navigation">
|
<div class="main-navigation">
|
||||||
<header-menu :showMobileMenu="showMobileMenu" />
|
<header-menu :showMobileMenu="isMobile" />
|
||||||
</div>
|
</div>
|
||||||
<ds-container>
|
<ds-container>
|
||||||
<div class="main-container">
|
<div class="main-container">
|
||||||
<nuxt />
|
<nuxt />
|
||||||
</div>
|
</div>
|
||||||
</ds-container>
|
</ds-container>
|
||||||
<page-footer v-if="!showMobileMenu" />
|
<page-footer v-if="!isMobile" />
|
||||||
<div id="overlay" />
|
<div id="overlay" />
|
||||||
<client-only>
|
<client-only>
|
||||||
<modal />
|
<modal />
|
||||||
@ -17,8 +17,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import HeaderMenu from '~/components/HeaderMenu/HeaderMenu'
|
|
||||||
import seo from '~/mixins/seo'
|
import seo from '~/mixins/seo'
|
||||||
|
import mobile from '~/mixins/mobile'
|
||||||
|
import HeaderMenu from '~/components/HeaderMenu/HeaderMenu'
|
||||||
import Modal from '~/components/Modal'
|
import Modal from '~/components/Modal'
|
||||||
import PageFooter from '~/components/PageFooter/PageFooter'
|
import PageFooter from '~/components/PageFooter/PageFooter'
|
||||||
|
|
||||||
@ -28,27 +29,10 @@ export default {
|
|||||||
Modal,
|
Modal,
|
||||||
PageFooter,
|
PageFooter,
|
||||||
},
|
},
|
||||||
mixins: [seo],
|
mixins: [seo, mobile],
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
windowWidth: null,
|
|
||||||
maxMobileWidth: 810,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
showMobileMenu() {
|
|
||||||
if (!this.windowWidth) return false
|
|
||||||
return this.windowWidth <= this.maxMobileWidth
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.windowWidth = window.innerWidth
|
|
||||||
window.addEventListener('resize', () => {
|
|
||||||
this.windowWidth = window.innerWidth
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.main-navigation {
|
.main-navigation {
|
||||||
background-color: $color-header-background;
|
background-color: $color-header-background;
|
||||||
|
|||||||
22
webapp/mixins/mobile.js
Normal file
22
webapp/mixins/mobile.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
export default (mobileWidth = null) => {
|
||||||
|
return {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
windowWidth: null,
|
||||||
|
maxMobileWidth: mobileWidth || 810, // greater counts as desktop
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
isMobile() {
|
||||||
|
if (!this.windowWidth) return false
|
||||||
|
return this.windowWidth <= this.maxMobileWidth
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.windowWidth = window.innerWidth
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
this.windowWidth = window.innerWidth
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user