Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 2 additions & 70 deletions src/.vuepress/theme/layouts/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
@touchstart="onTouchStart"
@touchend="onTouchEnd"
>
<VueMasteryBanner
v-if="isBannerOpen"
@close-banner="closeBanner"
ref="vueMasteryBanner"
/>
<Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar" />

<div class="sidebar-mask" @click="toggleSidebar(false)" />
Expand Down Expand Up @@ -53,7 +48,6 @@ import Home from '@theme/components/Home.vue'
import Navbar from '@theme/components/Navbar.vue'
import Page from '@theme/components/Page.vue'
import Sidebar from '@theme/components/Sidebar.vue'
import VueMasteryBanner from '@theme/components/sponsors/VueMasteryBanner.vue'
import BuySellAds from '@theme/components/BuySellAds.vue'
import CarbonAds from '@theme/components/CarbonAds.vue'
import { resolveSidebarItems } from '../util'
Expand All @@ -66,18 +60,13 @@ export default {
Page,
Sidebar,
Navbar,
VueMasteryBanner,
BuySellAds,
CarbonAds
},

data() {
return {
isSidebarOpen: false,
isBannerOpen: true,
isMenuFixed: false,
nameStorage: 'vuemastery-black-firday-2020-banner',
menuPosition: 0
isSidebarOpen: false
}
},

Expand Down Expand Up @@ -121,9 +110,7 @@ export default {
{
'no-navbar': !this.shouldShowNavbar,
'sidebar-open': this.isSidebarOpen,
'no-sidebar': !this.shouldShowSidebar,
'vuemastery-menu-fixed': this.isMenuFixed,
'vuemastery-promo': this.isBannerOpen
'no-sidebar': !this.shouldShowSidebar
},
userPageClass
]
Expand All @@ -138,13 +125,6 @@ export default {
this.$router.afterEach(() => {
this.isSidebarOpen = false
})

// Load component according to user preferences
if (!localStorage.getItem(this.nameStorage)) {
this.initBanner()
} else {
this.isBannerOpen = false
}
},

methods: {
Expand All @@ -171,54 +151,6 @@ export default {
this.toggleSidebar(false)
}
}
},

// Vue Mastery Banner
initBanner() {
// Add event listeners
this.toggleBannerEvents(true)
// Add class to the body to push fixed elements
this.isBannerOpen = true
// Get the menu position
this.getMenuPosition()
// Check current page offset position
this.isMenuFixed = this.isUnderBanner()
},

closeBanner(e) {
// Remove events
this.toggleBannerEvents(false)
// Hide the banner
this.isBannerOpen = false
// Save action in the local storage
localStorage.setItem(this.nameStorage, true)
},

getMenuPosition() {
this.menuPosition = this.$refs.vueMasteryBanner.$el.clientHeight
},

isUnderBanner() {
return window.pageYOffset > this.menuPosition
},

fixMenuAfterBanner() {
if (this.isUnderBanner()) {
if (!this.isMenuFixed) {
// The menu will be fixed
this.isMenuFixed = true
}
} else if (this.isMenuFixed) {
// The menu stay under the banner
this.isMenuFixed = false
}
},

toggleBannerEvents(on) {
// Add or remove event listerners attached to the DOM
let method = on ? 'addEventListener' : 'removeEventListener'
window[method]('resize', this.getMenuPosition)
window[method]('scroll', this.fixMenuAfterBanner)
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/.vuepress/theme/styles/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
@require './arrow'
@require './wrapper'
@require './toc'
@require './vuemastery-banner'

html, body
padding 0
Expand Down Expand Up @@ -252,5 +251,3 @@ th, td
img
max-width: 140px;
max-height: 60px;