vuepress-theme-reco/components/Home.vue

246 lines
5.1 KiB
Vue
Raw Normal View History

2019-04-15 10:35:40 +08:00
<template>
<div class="home">
2019-04-15 10:35:40 +08:00
<div class="hero">
<ModuleTransition>
<img
2019-12-09 11:33:55 +08:00
v-if="recoShowModule && $frontmatter.heroImage"
:style="heroImageStyle || {}"
:src="$withBase($frontmatter.heroImage)"
alt="hero">
</ModuleTransition>
2019-12-09 11:33:55 +08:00
<ModuleTransition delay="0.04">
2019-12-06 19:40:21 +08:00
<h1 v-if="recoShowModule && $frontmatter.isShowTitleInHome !== false">{{ $frontmatter.heroText || $title || '午后南杂' }}</h1>
</ModuleTransition>
2019-12-09 11:33:55 +08:00
<ModuleTransition delay="0.08">
2019-12-15 13:19:22 +08:00
<p v-show="recoShowModule" class="description">{{ $description || 'Welcome to your vuePress-theme-reco site' }}</p>
</ModuleTransition>
2019-12-09 11:33:55 +08:00
<ModuleTransition delay="0.16">
2019-12-06 19:40:21 +08:00
<p class="huawei" v-if="recoShowModule && $themeConfig.huawei === true">
<i class="iconfont reco-huawei" style="color: #fc2d38"></i>
&nbsp;&nbsp;&nbsp;华为为中华而为之
</p>
</ModuleTransition>
2019-12-09 11:33:55 +08:00
<ModuleTransition delay="0.24">
2019-12-06 19:40:21 +08:00
<p class="action" v-if="recoShowModule && $frontmatter.actionText && $frontmatter.actionLink">
<NavLink class="action-button" :item="actionLink"/>
</p>
</ModuleTransition>
2019-04-15 10:35:40 +08:00
</div>
2019-12-09 11:33:55 +08:00
<ModuleTransition delay="0.32">
2019-12-06 19:40:21 +08:00
<div class="features" v-if="recoShowModule && $frontmatter.features && $frontmatter.features.length">
<div v-for="(feature, index) in $frontmatter.features" :key="index" class="feature">
<h2>{{ feature.title }}</h2>
<p>{{ feature.details }}</p>
</div>
2019-04-15 10:35:40 +08:00
</div>
</ModuleTransition>
2019-12-09 11:33:55 +08:00
<ModuleTransition delay="0.4">
2019-12-15 13:19:22 +08:00
<Content class="home-center" v-show="recoShowModule" custom/>
</ModuleTransition>
2019-04-15 10:35:40 +08:00
</div>
</template>
<script>
import NavLink from '@theme/components/NavLink'
import ModuleTransition from '@theme/components/ModuleTransition'
import moduleTransitonMixin from '@theme/mixins/moduleTransiton'
2019-04-15 10:35:40 +08:00
export default {
mixins: [moduleTransitonMixin],
components: { NavLink, ModuleTransition },
2019-04-15 10:35:40 +08:00
computed: {
2019-09-20 13:54:13 +08:00
actionLink () {
2019-04-15 10:35:40 +08:00
return {
2019-12-06 19:40:21 +08:00
link: this.$frontmatter.actionLink,
text: this.$frontmatter.actionText
2019-09-20 13:54:13 +08:00
}
2019-04-15 10:35:40 +08:00
},
heroImageStyle () {
2019-12-06 19:40:21 +08:00
return this.$frontmatter.heroImageStyle || {
2019-04-15 10:35:40 +08:00
maxHeight: '200px',
margin: '6rem auto 1.5rem'
}
}
}
2019-09-20 13:54:13 +08:00
}
2019-04-15 10:35:40 +08:00
</script>
<style lang="stylus">
@require '../styles/mode.styl'
2019-04-15 10:35:40 +08:00
.home {
padding: $navbarHeight 2rem 0;
max-width: 960px;
margin: 0px auto;
.hero {
text-align: center;
h1 {
font-size: 2.5rem;
color: var(--text-color);
2019-04-15 10:35:40 +08:00
}
h1, .description, .action {
margin: 1.8rem auto;
}
.description {
font-size: 1.6rem;
line-height: 1.3;
color: var(--text-color);
2019-04-15 10:35:40 +08:00
}
.action-button {
display: inline-block;
font-size: 1.2rem;
color: #fff;
background-color: $accentColor;
padding: 0.6rem 1.2rem;
border-radius: $borderRadius
2019-04-15 10:35:40 +08:00
transition: background-color 0.1s ease;
box-sizing: border-box;
load-start()
&:hover {
background-color: lighten($accentColor, 10%);
}
}
}
.features {
border-top: 1px solid var(--border-color);;
2019-04-15 10:35:40 +08:00
padding: 1.2rem 0;
margin-top: 2.5rem;
display: flex;
flex-wrap: wrap;
align-items: flex-start;
align-content: stretch;
justify-content: space-between;
}
.feature {
flex-grow: 1;
flex-basis: 30%;
max-width: 30%;
transition: all .5s
color: var(--text-color);
2019-04-15 10:35:40 +08:00
h2 {
font-size: 1.6rem;
font-weight: 500;
border-bottom: none;
padding-bottom: 0;
}
&:hover {
transform scale(1.05)
}
}
// &.reco-hide {
// .hero {
// img {
// load-start()
// }
// .h1 {
// load-start()
// }
// .description {
// load-start()
// }
// .huawei {
// load-start()
// }
// .action-button {
// load-start()
// }
// }
// .features {
// load-start()
// }
// .home-center {
// load-start()
// padding 0
// }
// }
// &.reco-show {
// .hero {
// img {
// load-end(0.08s)
// }
// .h1 {
// load-end(0.16s)
// }
// .description {
// load-end(0.24s)
// }
// .huawei {
// load-end(0.32s)
// }
// .action-button {
// load-end(0.4s)
// }
// }
// .features {
// load-end(0.40s)
// }
// .home-center {
// load-end(0.48s)
// }
// }
2019-04-15 10:35:40 +08:00
}
@media (max-width: $MQMobile) {
.home {
.features {
flex-direction: column;
}
.feature {
max-width: 100%;
padding: 0 2.5rem;
}
}
}
@media (max-width: $MQMobileNarrow) {
.home {
padding-left: 1.5rem;
padding-right: 1.5rem;
.hero {
img {
max-height: 210px;
margin: 2rem auto 1.2rem;
}
h1 {
font-size: 2rem;
}
h1, .description, .action {
margin: 1.2rem auto;
}
.description {
font-size: 1.2rem;
}
.action-button {
font-size: 1rem;
padding: 0.6rem 1.2rem;
}
}
.feature {
h2 {
font-size: 1.25rem;
}
}
}
}
</style>