primevue-mirror/pages/landing/HeaderSection.vue

108 lines
4.3 KiB
Vue
Raw Normal View History

2022-09-06 13:53:29 +00:00
<template>
2022-09-14 14:26:41 +00:00
<section :ref="containerRef" :class="['landing-header pad-section', { 'landing-header-active': menuActive }]">
2022-09-06 13:53:29 +00:00
<span>
<img :src="$config.public.contextPath + 'demo/images/primevue-logo-' + `${$appState.darkTheme ? 'light' : 'dark'}` + '.svg'" alt="primevue logo" class="landing-header-logo" />
2022-09-06 13:53:29 +00:00
</span>
<div class="flex align-items-center">
<nav class="scalein origin-top">
<ol class="list-none m-0 p-0 flex flex-column lg:flex-row flex-wrap lg:flex-nowrap lg:align-items-center font-semibold">
<li class="mr-0 lg:mr-2">
2022-12-08 12:26:57 +00:00
<router-link to="/setup">
2022-12-09 07:52:51 +00:00
<img src="/demo/images/landing/core-icon.svg" alt="primevue core" />
2022-09-06 13:53:29 +00:00
<span>Components</span>
2022-12-08 12:26:57 +00:00
</router-link>
2022-09-06 13:53:29 +00:00
</li>
<li class="mr-0 lg:mr-2">
2023-01-30 22:53:56 +00:00
<a href="https://blocks.primevue.org">
2022-12-09 07:52:51 +00:00
<img src="/demo/images/landing/blocks-icon.svg" alt="primevue templates" />
2022-09-06 13:53:29 +00:00
<span>Blocks</span>
2022-12-08 12:26:57 +00:00
</a>
2022-09-06 13:53:29 +00:00
</li>
<li class="mr-0 lg:mr-2">
2023-01-30 22:55:30 +00:00
<a href="https://designer.primevue.org">
2022-12-09 07:52:51 +00:00
<img src="/demo/images/landing/designer-icon.svg" alt="primevue templates" />
2022-09-06 13:53:29 +00:00
<span>Designer</span>
2022-12-08 12:26:57 +00:00
</a>
2022-09-06 13:53:29 +00:00
</li>
<li class="mr-0 lg:mr-2">
2022-12-08 12:26:57 +00:00
<a href="https://www.primefaces.org/store/templates.xhtml">
2022-12-09 07:52:51 +00:00
<img src="/demo/images/landing/templates-icon.svg" alt="primevue templates" />
2022-09-06 13:53:29 +00:00
<span>Templates</span>
2022-12-08 12:26:57 +00:00
</a>
2022-09-06 13:53:29 +00:00
</li>
</ol>
</nav>
2022-12-08 12:26:57 +00:00
<a href="https://github.com/primefaces/primevue" rel="noopener noreferrer" class="linkbox p-0 header-button mr-2 flex align-items-center justify-content-center flex-shrink-0">
2022-09-06 13:53:29 +00:00
<i class="pi pi-github"></i>
2022-12-08 12:26:57 +00:00
</a>
<a href="https://discord.gg/gzKFYnpmCY" rel="noopener noreferrer" class="linkbox p-0 header-button mr-2 flex align-items-center justify-content-center flex-shrink-0">
2022-09-06 13:53:29 +00:00
<i class="pi pi-discord"></i>
2022-12-08 12:26:57 +00:00
</a>
2022-09-06 13:53:29 +00:00
<button type="button" class="linkbox header-button inline-flex align-items-center justify-content-center" @click="toggleTheme">
2022-09-14 14:26:41 +00:00
<i :class="['pi', { 'pi-sun': isDarkTheme(), 'pi-moon': !isDarkTheme() }]"></i>
2022-09-06 13:53:29 +00:00
</button>
2022-09-14 14:26:41 +00:00
<button type="button" class="linkbox header-button inline-flex align-items-center justify-content-center lg:hidden ml-2 menu-button" @click="toggleMenuActive">
2022-09-06 13:53:29 +00:00
<i class="pi pi-bars"></i>
</button>
</div>
</section>
</template>
<script>
export default {
emits: ['theme-toggle'],
data() {
return {
menuActive: false
2022-09-14 14:26:41 +00:00
};
2022-09-06 13:53:29 +00:00
},
scrollListener: null,
container: null,
2022-12-28 07:34:30 +00:00
mounted() {
this.bindScrollListener();
},
2022-09-06 13:53:29 +00:00
beforeUnmount() {
if (this.scrollListener) {
this.unbindScrollListener();
}
},
updated() {
this.checkSticky();
},
methods: {
isDarkTheme() {
return this.$appState.darkTheme === true;
},
toggleTheme() {
this.$emit('theme-toggle');
},
toggleMenuActive() {
this.menuActive = !this.menuActive;
},
bindScrollListener() {
if (!this.scrollListener && this.container) {
this.scrollListener = () => {
this.checkSticky();
2022-09-14 14:26:41 +00:00
};
2022-09-06 13:53:29 +00:00
}
2022-12-08 12:26:57 +00:00
2022-09-06 13:53:29 +00:00
window.addEventListener('scroll', this.scrollListener);
},
unbindScrollListener() {
if (this.scrollListener) {
window.removeEventListener('scroll', this.scrollListener);
this.scrollListener = null;
}
},
containerRef(el) {
this.container = el;
},
checkSticky() {
2022-09-14 14:26:41 +00:00
if (window.scrollY > 0) this.container.classList.add('landing-header-sticky');
else this.container.classList.remove('landing-header-sticky');
2022-09-06 13:53:29 +00:00
}
}
2022-09-14 14:26:41 +00:00
};
</script>