primevue-mirror/src/Home.vue

110 lines
3.9 KiB
Vue
Raw Normal View History

2022-02-23 11:42:11 +00:00
<template>
<div :class="landingClass">
<div class="landing-intro">
2022-02-23 19:52:21 +00:00
<HeaderSection @theme-toggle="onThemeToggle" />
2022-02-23 11:42:11 +00:00
<HeroSection />
</div>
<ComponentSection />
2022-02-23 19:52:21 +00:00
<ThemeSection :theme="tableTheme" @table-theme-change="onTableThemeChange" />
2022-02-23 11:42:11 +00:00
<BlockSection />
<DesignerSection />
<TemplateSection />
<UsersSection />
<FeaturesSection />
<FooterSection />
</div>
</template>
<script>
2022-02-23 13:44:06 +00:00
import EventBus from '@/AppEventBus';
2022-02-23 11:42:11 +00:00
import HeaderSection from './views/landing/HeaderSection';
import HeroSection from './views/landing/HeroSection';
import ComponentSection from './views/landing/ComponentSection';
import ThemeSection from './views/landing/ThemeSection';
import BlockSection from './views/landing/BlockSection';
import DesignerSection from './views/landing/DesignerSection';
import TemplateSection from './views/landing/TemplateSection';
import UsersSection from './views/landing/UsersSection';
import FeaturesSection from './views/landing/FeaturesSection';
import FooterSection from './views/landing/FooterSection';
export default {
props: {
theme: {
type: String,
default: null
}
},
data() {
return {
2022-02-24 09:09:33 +00:00
tableTheme: 'lara-light-blue'
2022-02-23 11:42:11 +00:00
}
},
themeChangeListener: null,
mounted() {
let afId = this.$route.query['af_id'];
if (afId) {
let today = new Date();
let expire = new Date();
expire.setTime(today.getTime() + 3600000*24*7);
document.cookie = 'primeaffiliateid=' + afId + ';expires=' + expire.toUTCString() + ';path=/; domain:primefaces.org';
}
2022-02-23 21:19:22 +00:00
2022-02-24 09:09:33 +00:00
this.replaceTableTheme(this.$appState.darkTheme ? 'lara-dark-blue': 'lara-light-blue');
2022-02-23 11:42:11 +00:00
},
methods: {
2022-02-23 19:52:21 +00:00
onThemeToggle() {
2022-02-23 22:20:45 +00:00
const newTheme = this.$appState.darkTheme ? 'lara-light-blue' : 'lara-dark-blue';
2022-02-23 19:52:21 +00:00
const newTableTheme = this.$appState.darkTheme ? this.tableTheme.replace('dark', 'light') : this.tableTheme.replace('light', 'dark');
2022-02-23 11:42:11 +00:00
2022-02-23 19:52:21 +00:00
EventBus.emit('theme-change', { theme: newTheme, dark: !this.$appState.darkTheme });
this.replaceTableTheme(newTableTheme);
2022-02-23 11:42:11 +00:00
},
2022-02-23 19:52:21 +00:00
onTableThemeChange(value) {
this.replaceTableTheme(value);
2022-02-23 11:42:11 +00:00
},
2022-02-23 19:52:21 +00:00
replaceTableTheme(newTheme) {
const elementId = 'home-table-link';
const linkElement = document.getElementById(elementId);
2022-02-23 21:19:22 +00:00
const tableThemeTokens = linkElement.getAttribute('href').split('/');
const currentTableTheme = tableThemeTokens[tableThemeTokens.length - 2];
if (currentTableTheme !== newTheme) {
const newThemeUrl = linkElement.getAttribute('href').replace(currentTableTheme, newTheme);
2022-02-23 11:42:11 +00:00
2022-02-23 21:19:22 +00:00
const cloneLinkElement = linkElement.cloneNode(true);
cloneLinkElement.setAttribute('id', elementId + '-clone');
cloneLinkElement.setAttribute('href', newThemeUrl);
cloneLinkElement.addEventListener('load', () => {
linkElement.remove();
cloneLinkElement.setAttribute('id', elementId);
});
linkElement.parentNode.insertBefore(cloneLinkElement, linkElement.nextSibling);
2022-02-23 19:52:21 +00:00
2022-02-23 21:19:22 +00:00
this.tableTheme = newTheme;
}
2022-02-23 19:52:21 +00:00
}
2022-02-23 11:42:11 +00:00
},
computed: {
landingClass() {
return ['landing', {'landing-dark': this.$appState.darkTheme, 'landing-light': !this.$appState.darkTheme}];
}
},
components: {
HeaderSection,
HeroSection,
ComponentSection,
ThemeSection,
BlockSection,
DesignerSection,
TemplateSection,
UsersSection,
FeaturesSection,
FooterSection
}
}
</script>
<style lang="scss">
@import './assets/styles/landing/landing.scss';
</style>