primevue-mirror/pages/index.vue

113 lines
3.9 KiB
Vue
Raw Normal View History

2022-02-23 11:42:11 +00:00
<template>
2022-09-06 13:53:29 +00:00
<div :class="landingClass">
2022-02-23 11:42:11 +00:00
<div class="landing-intro">
2022-04-07 12:57:53 +00:00
<AppNews v-if="$appState.newsActive" />
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 />
2022-09-06 13:53:29 +00:00
</div>
2022-02-23 11:42:11 +00:00
</template>
2022-09-06 13:53:29 +00:00
<script>
import EventBus from '@/layouts/AppEventBus';
import HeaderSection from './landing/HeaderSection';
import HeroSection from './landing/HeroSection';
import ComponentSection from './landing/ComponentSection';
import ThemeSection from './landing/ThemeSection';
import BlockSection from './landing/BlockSection';
import DesignerSection from './landing/DesignerSection';
import TemplateSection from './landing/TemplateSection';
import UsersSection from './landing/UsersSection';
import FeaturesSection from './landing/FeaturesSection';
import FooterSection from './landing/FooterSection';
import AppNews from '@/layouts/AppNews';
2022-02-23 11:42:11 +00:00
export default {
2022-09-06 13:53:29 +00:00
props: {
theme: {
type: String,
default: null
}
},
data() {
return {
tableTheme: 'lara-light-blue'
}
},
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-09-06 13:53:29 +00:00
this.replaceTableTheme(this.$appState.darkTheme ? 'lara-dark-blue': 'lara-light-blue');
},
methods: {
onThemeToggle() {
const newTheme = this.$appState.darkTheme ? 'lara-light-blue' : 'lara-dark-blue';
const newTableTheme = this.$appState.darkTheme ? this.tableTheme.replace('dark', 'light') : this.tableTheme.replace('light', 'dark');
2022-02-23 11:42:11 +00:00
2022-09-06 13:53:29 +00:00
EventBus.emit('theme-change', { theme: newTheme, dark: !this.$appState.darkTheme });
this.replaceTableTheme(newTableTheme);
},
onTableThemeChange(value) {
this.replaceTableTheme(value);
},
replaceTableTheme(newTheme) {
const elementId = 'home-table-link';
const linkElement = document.getElementById(elementId);
const tableThemeTokens = linkElement?.getAttribute('href').split('/') || null;
const currentTableTheme = tableThemeTokens ? tableThemeTokens[tableThemeTokens.length - 2] : null;
if (currentTableTheme !== newTheme && tableThemeTokens) {
const newThemeUrl = linkElement.getAttribute('href').replace(currentTableTheme, newTheme);
2022-02-23 11:42:11 +00:00
2022-09-06 13:53:29 +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-09-06 13:53:29 +00:00
this.tableTheme = newTheme;
}
}
},
computed: {
landingClass() {
return ['landing', {'landing-dark': this.$appState.darkTheme, 'landing-light': !this.$appState.darkTheme, 'landing-news-active': this.$appState.newsActive}];
}
},
components: {
HeaderSection,
HeroSection,
ComponentSection,
ThemeSection,
BlockSection,
DesignerSection,
TemplateSection,
UsersSection,
FeaturesSection,
FooterSection,
AppNews
}
2022-02-23 11:42:11 +00:00
}
2022-09-06 13:53:29 +00:00
</script>
2022-02-23 11:42:11 +00:00
<style lang="scss">
2022-09-06 13:53:29 +00:00
@import '@/assets/styles/landing/landing.scss';
2022-02-23 11:42:11 +00:00
</style>