1
0
mirror of https://gitee.com/vant-contrib/vant.git synced 2025-04-26 19:36:36 +08:00

feat: add DemoHome components

This commit is contained in:
陈嘉涵 2019-11-19 16:26:21 +08:00
parent e23d2a7564
commit 251d3764e4
2 changed files with 163 additions and 0 deletions
packages/vant-cli/site/mobile/components

@ -0,0 +1,78 @@
<template>
<div class="demo-home">
<h1 class="demo-home__title">
<img :src="config.logo">
<span>{{ config.title }}</span>
</h1>
<h2 v-if="config.description" class="demo-home__desc">{{ config.description }}</h2>
<template v-for="(group, index) in config.nav">
<demo-home-nav
:group="group"
:base="$vantLang"
:key="index"
/>
</template>
</div>
</template>
<script>
import { config } from '../../../dist/mobile-config';
import DemoHomeNav from './DemoHomeNav';
export default {
components: {
DemoHomeNav
},
data() {
return {
config
};
}
};
</script>
<style lang="less">
@import '../../common/style/index';
.demo-home {
box-sizing: border-box;
width: 100%;
min-height: 100vh;
padding: 46px 20px 20px;
background: #fff;
&__title,
&__desc {
padding-left: 16px;
font-weight: normal;
user-select: none;
}
&__title {
margin: 0 0 16px;
img,
span {
display: inline-block;
vertical-align: middle;
}
img {
width: 36px;
}
span {
margin-left: 16px;
font-weight: 500;
font-size: 36px;
}
}
&__desc {
margin: 0 0 40px;
color: #7d7e80;
font-size: 14px;
}
}
</style>

@ -0,0 +1,85 @@
<template>
<van-collapse
v-model="active"
:border="false"
class="demo-home-nav"
>
<van-collapse-item
class="demo-home-nav__item"
:title="group.title"
:name="group.title"
>
<van-icon
v-if="group.icon"
:name="group.icon"
slot="right-icon"
class="demo-home-nav__icon"
/>
<template v-for="(navItem, index) in group.items">
<van-cell
:key="index"
:to="'/' + navItem.path"
:title="navItem.title"
is-link
/>
</template>
</van-collapse-item>
</van-collapse>
</template>
<script>
import { Cell, Icon, Collapse, CollapseItem } from 'vant';
export default {
components: {
[Cell.name]: Cell,
[Icon.name]: Icon,
[Collapse.name]: Collapse,
[CollapseItem.name]: CollapseItem
},
props: {
base: String,
group: Object
},
data() {
return {
active: []
};
}
};
</script>
<style lang="less">
@import '../../common/style/index';
.demo-home-nav {
&__item {
margin-bottom: 16px;
overflow: hidden;
border-radius: 6px;
box-shadow: 0 1px 5px #ebedf0;
}
&__icon {
font-size: 24px;
img {
width: 100%;
}
}
.van-collapse-item__content {
padding: 0;
}
.van-collapse-item__title {
align-items: center;
font-weight: 500;
font-size: 16px;
line-height: 40px;
border-radius: 2px;
}
}
</style>