naive-ui/demo/pages/home/index.vue

196 lines
4.1 KiB
Vue
Raw Normal View History

2020-02-27 18:09:23 +08:00
<template>
2021-01-13 12:01:02 +08:00
<div>
<n-layout-footer position="absolute" style="z-index: auto">
<landing-footer style="max-width: 1200px; margin: auto" />
</n-layout-footer>
<div class="banner">
2021-04-05 17:59:04 +08:00
<right-image class="right-image" v-if="!isMobile" />
<n-h1 :style="titleStyle" class="naive-title">
2021-01-13 12:01:02 +08:00
<span
@mouseenter="handleTitleMouseEnter"
@mouseleave="handleTitleMouseLeave"
2021-02-14 14:52:14 +08:00
>Na{{ hover ? 'ï' : 'i' }}ve UI</span
>
2021-01-13 12:01:02 +08:00
</n-h1>
<n-p style="font-size: 16px; margin-bottom: 0">
{{ t('intro1') }}
</n-p>
<n-p
style="
font-size: 16px;
margin-bottom: 4px;
margin-top: 4px;
font-weight: 500;
"
>
{{ t('intro2') }}
</n-p>
<n-p style="font-size: 16px; margin-top: 0">
{{ t('intro3') }}
</n-p>
2020-02-27 18:09:23 +08:00
<div>
2021-01-13 12:01:02 +08:00
<n-button
type="default"
size="large"
style="margin-right: 12px"
@click="handleThemeChangeClick"
>
{{ t('intro4') }}
</n-button>
<n-button
type="primary"
:ghost="theme === 'dark'"
size="large"
@click="handleStartClick"
>
{{ t('start') }}
</n-button>
2020-02-27 18:09:23 +08:00
</div>
2021-04-05 17:59:04 +08:00
<left-image class="left-image" />
2021-01-13 12:01:02 +08:00
</div>
</div>
2020-02-27 18:09:23 +08:00
</template>
<script>
2021-04-05 17:59:04 +08:00
import { computed } from 'vue'
import LandingFooter from './Footer.vue'
import leftImage from './Left.vue'
import rightImage from './Right.vue'
2021-04-05 17:59:04 +08:00
import { i18n, useIsMobile } from '../../utils/composables'
2021-01-13 12:01:02 +08:00
import { useThemeName } from '../../store'
2020-02-27 18:09:23 +08:00
export default {
components: {
LandingFooter,
leftImage,
rightImage
},
2020-10-07 20:45:51 +08:00
setup () {
2021-04-05 17:59:04 +08:00
const isMobileRef = useIsMobile()
2020-10-07 20:45:51 +08:00
return {
2021-04-05 17:59:04 +08:00
isMobile: isMobileRef,
2021-01-13 12:01:02 +08:00
theme: useThemeName(),
2021-04-05 17:59:04 +08:00
titleStyle: computed(() => {
if (isMobileRef.value) {
return 'margin-top: 0; font-size: 64px !important'
} else {
return 'margin-top: 0; font-size: 80px !important'
}
}),
2020-12-12 13:51:22 +08:00
...i18n({
2020-10-07 20:45:51 +08:00
'zh-CN': {
2020-11-03 15:10:29 +08:00
start: '开始使用',
intro1: '一个 Vue UI 框架',
intro2: '在意样式,带主题,比较完整,不算太慢',
intro3: '有点意思',
intro4: '换个主题'
2020-10-07 20:45:51 +08:00
},
'en-US': {
2020-11-03 15:10:29 +08:00
start: 'Get Started',
intro1: 'A Vue UI Framework',
2020-12-12 13:51:22 +08:00
intro2:
'Caring About Styles, Themed, Batteries Included, Not Rather Slow',
2020-11-03 15:10:29 +08:00
intro3: 'Interesting Somehow',
intro4: 'Change Theme'
2020-10-07 20:45:51 +08:00
}
2020-12-12 13:51:22 +08:00
})
2020-10-07 20:45:51 +08:00
}
},
2020-02-29 14:55:52 +08:00
data () {
return {
2020-03-02 23:44:05 +08:00
hover: false,
themeOptions: {
dark: {
next: 'light'
},
light: {
next: 'dark'
}
}
}
},
2020-02-27 18:09:23 +08:00
methods: {
handleStartClick () {
2021-02-18 22:52:54 +08:00
this.$router.push(this.$route.path + '/docs/installation')
2020-02-29 14:55:52 +08:00
},
handleTitleMouseEnter () {
this.hover = true
},
handleTitleMouseLeave () {
this.hover = false
2020-03-02 23:44:05 +08:00
},
handleThemeChangeClick () {
this.theme = this.themeOptions[this.theme].next
2020-02-27 18:09:23 +08:00
}
}
}
</script>
<style scoped>
.banner {
text-align: center;
position: absolute;
2020-02-27 23:03:15 +08:00
top: calc(50% - 36px);
2020-02-27 18:09:23 +08:00
left: 0;
right: 0;
2020-02-27 23:03:15 +08:00
transform: translateY(-50%);
2020-02-27 18:09:23 +08:00
}
.naive-title {
2020-10-07 21:03:23 +08:00
font-family: Metropolis, sans-serif;
2020-08-06 01:51:45 +08:00
margin-bottom: 18px !important;
2020-02-27 18:09:23 +08:00
}
@media only screen and (max-width: 1920px) {
.left-image {
2020-02-27 23:03:15 +08:00
right: calc(50% + 270px);
width: calc(50% - 270px);
min-width: 440px;
2020-02-27 18:09:23 +08:00
}
.right-image {
2020-02-27 23:03:15 +08:00
left: calc(50% + 270px);
width: calc(50% - 270px);
min-width: 440px;
2020-02-27 18:09:23 +08:00
}
}
@media only screen and (min-width: 1920px) {
.left-image {
left: 0;
width: 700px;
}
.right-image {
right: 0;
width: 700px;
}
}
.left-image {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.right-image {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
2021-04-05 17:59:04 +08:00
@media only screen and (max-width: 600px) {
.banner {
text-align: left;
margin-left: 16px;
top: calc(50vh - 64px);
}
.left-image {
position: relative;
left: -16px;
min-width: unset;
width: 72vw;
top: 8px;
transform: none;
}
}
2020-02-27 18:09:23 +08:00
</style>