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

212 lines
4.5 KiB
Vue
Raw Normal View History

2020-02-27 18:09:23 +08:00
<template>
2021-05-26 14:39:33 +08:00
<n-layout
:native-scrollbar="false"
:position="isXs ? 'static' : 'absolute'"
2021-06-02 16:17:13 +08:00
:style="isXs ? undefined : 'top: var(--header-height);'"
2021-05-26 14:39:33 +08:00
>
<div class="banner" style="overflow: hidden">
2021-05-04 02:27:16 +08:00
<right-image class="right-image" v-if="!isS" />
2021-04-05 17:59:04 +08:00
<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>
2021-05-04 02:27:16 +08:00
<n-p style="font-size: 16px; margin-top: 0; margin-bottom: 0">
2021-01-13 12:01:02 +08:00
{{ 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>
2021-05-04 02:27:16 +08:00
<n-layout-footer>
<landing-footer centered />
</n-layout-footer>
2021-05-26 14:39:33 +08:00
</n-layout>
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-05-04 02:27:16 +08:00
import { i18n, useIsXs, useIsS } 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-06 01:31:09 +08:00
const isXsRef = useIsXs()
2020-10-07 20:45:51 +08:00
return {
2021-04-06 01:31:09 +08:00
isXs: isXsRef,
2021-05-04 02:27:16 +08:00
isS: useIsS(),
2021-01-13 12:01:02 +08:00
theme: useThemeName(),
2021-04-05 17:59:04 +08:00
titleStyle: computed(() => {
2021-04-06 01:31:09 +08:00
if (isXsRef.value) {
2021-04-05 17:59:04 +08:00
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: '开始使用',
2021-05-25 13:21:43 +08:00
intro1: '一个 Vue 3 组件库',
2021-04-19 21:47:29 +08:00
intro2: '比较完整,主题可调,使用 Typescript不算太慢',
2020-11-03 15:10:29 +08:00
intro3: '有点意思',
intro4: '换个主题'
2020-10-07 20:45:51 +08:00
},
'en-US': {
2020-11-03 15:10:29 +08:00
start: 'Get Started',
2021-05-25 13:21:43 +08:00
intro1: 'A Vue 3 Component Library',
2021-04-19 21:47:29 +08:00
intro2: 'Rather Complete, Themeable, With Typescript, Not Too 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 {
2021-05-04 02:27:16 +08:00
height: calc(100vh - 64px);
display: flex;
flex-direction: column;
position: relative;
2020-02-27 18:09:23 +08:00
text-align: center;
2021-05-04 02:27:16 +08:00
justify-content: center;
}
.banner::after {
content: '';
width: 100%;
height: 64px;
2020-02-27 18:09:23 +08:00
}
.naive-title {
2021-05-04 02:27:16 +08:00
line-height: 1;
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
2021-05-04 02:27:16 +08:00
@media only screen and (max-width: 1023px) {
2021-04-05 17:59:04 +08:00
.banner {
position: static;
2021-04-05 17:59:04 +08:00
text-align: left;
2021-05-26 14:39:33 +08:00
padding-left: 16px;
transform: none;
2021-05-26 14:39:33 +08:00
padding-top: 60px;
padding-right: 16px;
min-height: 550px;
2021-05-04 02:27:16 +08:00
height: calc(100vh - 124px);
2021-04-05 17:59:04 +08:00
}
.left-image {
position: relative;
left: -16px;
min-width: unset;
width: 300px;
2021-04-05 17:59:04 +08:00
top: 8px;
transform: none;
}
}
2020-02-27 18:09:23 +08:00
</style>