component nav

pull/2/head
baiyaaaaa 2016-08-23 17:39:58 +08:00
parent 0d6fdd2bd6
commit 4247932988
5 changed files with 362 additions and 300 deletions

View File

@ -1,40 +1,86 @@
<style> <style>
.side-nav {
width: 100%;
box-sizing: border-box;
border-right: 1px solid #eaeefa;
li {
list-style: none;
}
ul {
padding: 0;
}
.nav-item {
a {
font-size:18px;
color:#5e6d82;
line-height: 32px;
height: 32px;
margin: 10px 0;
padding: 0 0 0 10px;
text-decoration: none;
border-left: 2px solid transparent;
display: block;
&.active {
color: #20a0ff;
border-left-color: #20a0ff;
}
}
.nav-item {
a {
font-size: 14px;
padding-left: 20px;
&:hover {
background-color: #eee;
}
}
}
}
.nav-group__title {
color: #99a9bf;
padding-left: 15px;
line-height: 32px;
}
}
</style> </style>
<template> <template>
<div class="side-nav"> <div class="side-nav">
<ul> <ul>
<li v-for="item in data"> <li class="nav-item" v-for="item in data">
<a href="">{{item.name}}</a> <a>{{item.name}}</a>
<ul class="pure-menu-list sub-nav" v-if="item.children">
<li class="nav-item" v-for="navItem in item.children">
<router-link
class=""
active-class="active"
:to="'/component' + navItem.path"
exact
v-text="navItem.title || item.name">
</router-link>
</li> </li>
</ul> </ul>
<template v-for="(nav, key) in navs"> <template v-if="item.groups">
<a <div class="nav-group" v-for="group in item.groups">
href="#" <div class="nav-group__title">{{group.groupName}}</div>
@click.prevent="navState.$set(key, !navState[key] || false)" <ul class="pure-menu-list">
class="pure-menu-heading app__menu__label"
:class="{ 'unfold': !navState[key] }"
v-text="nav.group"></a>
<ul
class="pure-menu-list"
transition="slidedown"
v-show="!navState[key]"
:style="{
maxHeight: nav.list.length * 44 + 'px'
}">
<li <li
class="pure-menu-item app__menu__item" class="nav-item"
v-for="item in nav.list" v-for="item in group.list"
v-if="!item.disabled"> v-if="!item.disabled">
<router-link <router-link
class="pure-menu-link app__menu__link"
active-class="active" active-class="active"
:to="'/component' + item.path" :to="'/component' + item.path"
exact exact
v-text="item.name"></router-link> v-text="item.title"></router-link>
</li> </li>
</ul> </ul>
</div>
</template> </template>
</li>
</ul>
</div> </div>
</template> </template>
<script> <script>

0
examples/docs/layout.md Normal file
View File

View File

@ -1,12 +1,14 @@
[ [
{ {
"group": "Basic", "name": "基础组件",
"groups": [{
"groupName": "Basic",
"list": [ "list": [
{ {
"path": "/button", "path": "/layout",
"name": "按钮 (button)", "name": "按钮 (button)",
"title": "Button 按钮", "title": "Layout 布局",
"description": "常用的操作按钮" "description": ""
}, },
{ {
"path": "/icon", "path": "/icon",
@ -14,10 +16,10 @@
"title": "Icon 图标" "title": "Icon 图标"
}, },
{ {
"path": "/tag", "path": "/button",
"name": "标签 (tag)", "name": "按钮 (button)",
"title": "Tag 标签", "title": "Button 按钮",
"description": "Tag 标签" "description": "常用的操作按钮"
}, },
{ {
"path": "/dialog", "path": "/dialog",
@ -30,18 +32,6 @@
"name": "弹框 (message-box)", "name": "弹框 (message-box)",
"title": "message-box 弹框" "title": "message-box 弹框"
}, },
{
"path": "/popover",
"name": "弹出框 (popover)",
"title": "popover 弹出框",
"description": "收纳具体内容和相关操作, 激活后弹出展现"
},
{
"path": "/tooltip",
"name": "文字提示 (tooltip)",
"title": "tooltip 文字提示",
"description": "优雅地展示文字提示信息"
},
{ {
"path": "/alert", "path": "/alert",
"name": "警告 (alert)", "name": "警告 (alert)",
@ -75,18 +65,13 @@
] ]
}, },
{ {
"group": "Form", "groupName": "Form",
"list": [ "list": [
{ {
"path": "/autocomplete", "path": "/radio",
"name": "自动完成 (autocomplete)", "name": "单选框 (radio)",
"title": "Autocomplete 自动完成" "title": "Radio 单选框",
}, "description": "用于在多个备选项选中单个选项。"
{
"path": "/select",
"name": "选择器 (select)",
"title": "Select 选择器",
"description": "当选项过多时, 使用下拉菜单展示并选择内容"
}, },
{ {
"path": "/checkbox", "path": "/checkbox",
@ -94,12 +79,6 @@
"title": "Checkbox 多选框", "title": "Checkbox 多选框",
"description": "用于在多个可选项中进行多项选择。" "description": "用于在多个可选项中进行多项选择。"
}, },
{
"path": "/radio",
"name": "单选框 (radio)",
"title": "Radio 单选框",
"description": "用于在多个备选项选中单个选项。"
},
{ {
"path": "/input", "path": "/input",
"name": "输入框 (input)", "name": "输入框 (input)",
@ -110,68 +89,131 @@
"name": "计数器 (input-number)", "name": "计数器 (input-number)",
"title": "Input Number 计数器" "title": "Input Number 计数器"
}, },
{
"path": "/select",
"name": "选择器 (select)",
"title": "Select 选择器",
"description": "当选项过多时, 使用下拉菜单展示并选择内容"
},
{ {
"path": "/switch", "path": "/switch",
"name": "开关 (switch)", "name": "开关 (switch)",
"title": "Switch 开关", "title": "Switch 开关",
"description": "用于两种对立状态的切换。" "description": "用于两种对立状态的切换。"
}, },
{
"path": "/slider",
"name": "滑块 (slider)",
"title": "Slider 滑块",
"description": "通过拖动滑块在一个固定区间内进行选择"
},
{ {
"path": "/time-picker", "path": "/time-picker",
"name": "时间选择器time-picker", "name": "时间选择器time-picker",
"title": "时间选择器", "title": "TimePicker 时间选择器",
"description": "用于选择或输入时间" "description": "用于选择或输入时间"
}, },
{ {
"path": "/date-picker", "path": "/date-picker",
"name": "日期选择器date-picker", "name": "日期选择器date-picker",
"title": "日期选择器", "title": "DatePicker",
"description": "用于选择或输入时间" "description": "用于选择或输入时间"
}, },
{ {
"path": "/datetime-picker", "path": "/datetime-picker",
"name": "日期时间选择器", "name": "日期时间选择器",
"title": "日期时间选择器", "title": "DatetimePicker",
"description": "用于选择或输入日期时间" "description": "用于选择或输入日期时间"
}, },
{ {
"path": "/upload", "path": "/upload",
"name": "上传 (upload)", "name": "上传 (upload)",
"title": "upload 上传", "title": "Upload 上传",
"description": "文件上传组件" "description": "文件上传组件"
}, },
{ {
"path": "/form", "path": "/form",
"name": "表单 (form)", "name": "表单 (form)",
"title": "form 表单", "title": "Form 表单",
"description": "一个多功能的并带有字段验证的表单组件" "description": "一个多功能的并带有字段验证的表单组件"
}, },
{ {
"path": "/slider", "path": "/autocomplete",
"name": "滑块 (slider)", "name": "自动完成 (autocomplete)",
"title": "slider 滑块", "title": "Autocomplete 自动完成"
"description": "通过拖动滑块在一个固定区间内进行选择"
}, },
{ {
"path": "/rate", "path": "/rate",
"name": "评分 (rate)", "name": "评分 (rate)",
"title": "评分组件" "title": "Rate 评分组件"
} }
] ]
}, },
{ {
"group": "Nav", "groupName": "Data",
"list": [
{
"path": "/table",
"name": "表格 (table)",
"title": "Table 表格",
"description": "用于展示多条结构类似的数据, 可对数据进行排序、筛选、对比或其他自定义操作。"
},
{
"path": "/tag",
"name": "标签 (tag)",
"title": "Tag 标签",
"description": "Tag 标签"
},
{
"path": "/tooltip",
"name": "文字提示 (tooltip)",
"title": "Tooltip 文字提示",
"description": "优雅地展示文字提示信息"
},
{
"path": "/popover",
"name": "弹出框 (popover)",
"title": "Popover 弹出框",
"description": "收纳具体内容和相关操作, 激活后弹出展现"
},
{
"path": "/progress",
"name": "进度条 (progress)",
"title": "Progress 进度条",
"description": ""
},
{
"path": "/tree",
"name": "tree (tree)",
"title": "Tree 树形控件"
},
{
"path": "/pagination",
"name": "分页 (pagination)",
"title": "Pagination 分页",
"description": "当数据量过多时, 使用分页分解数据"
},
{
"path": "/badge",
"name": "标记 (badge)",
"title": " Badge 标记",
"description": "出现在按钮、图标旁的数字或状态标记"
}
]
},
{
"groupName": "Nav",
"list": [ "list": [
{ {
"path": "/tabs", "path": "/tabs",
"name": "标签页 (tabs)", "name": "标签页 (tabs)",
"title": "tabs 标签页", "title": "Tabs 标签页",
"description": "富展现的标签页" "description": "富展现的标签页"
}, },
{ {
"path": "/breadcrumb", "path": "/breadcrumb",
"name": "面包屑 (breadcrumb)", "name": "面包屑 (breadcrumb)",
"title": "breadcrumb 面包屑", "title": "Breadcrumb 面包屑",
"description": "" "description": ""
}, },
{ {
@ -186,52 +228,16 @@
"description": "引导用户按照流程完成任务的分步导航条,可根据实际应用场景设定步骤,步骤不得少于 2 步。" "description": "引导用户按照流程完成任务的分步导航条,可根据实际应用场景设定步骤,步骤不得少于 2 步。"
} }
] ]
}]
}, },
{ {
"group": "Data", "name": "安装指南",
"list": [ "children": [{
{
"path": "/table",
"name": "表格 (table)",
"title": "Table 表格",
"description": "用于展示多条结构类似的数据, 可对数据进行排序、筛选、对比或其他自定义操作。"
},
{
"path": "/progress",
"name": "进度条 (progress)",
"title": "progress 进度条",
"description": ""
},
{
"path": "/pagination",
"name": "分页 (pagination)",
"title": "Pagination 分页",
"description": "当数据量过多时, 使用分页分解数据"
},
{
"path": "/tree",
"name": "tree (tree)",
"title": "tree"
},
{
"path": "/badge",
"name": "标记 (badge)",
"title": " Badge 标记",
"description": "出现在按钮、图标旁的数字或状态标记"
}
]
},
{
"group": "使用说明",
"list": [
{
"path": "/quickstart", "path": "/quickstart",
"name": "快速上手" "name": "快速上手"
}, }, {
{
"path": "/development", "path": "/development",
"name": "开发指南" "name": "开发指南"
} }]
]
} }
] ]

View File

@ -1,13 +1,20 @@
<style>
.el-col {
box-sizing: border-box;
}
</style>
<template> <template>
<div class="container"> <div class="container">
<el-col :span="5"> <el-row :gutter="25">
<el-col :span="6">
<side-nav :data="navsData"></side-nav> <side-nav :data="navsData"></side-nav>
</el-col> </el-col>
<el-col :span="19"> <el-col :span="18">
<div class="content"> <div class="content">
<router-view></router-view> <router-view></router-view>
</div> </div>
</el-col> </el-col>
</el-row>
</div> </div>
</template> </template>
<script> <script>
@ -15,23 +22,8 @@
export default { export default {
data() { data() {
return { return {
navsData: [{ navsData: navs
name: '组件',
children: []
}, {
name: '安装指南',
children: [{
path: '/component/quickstart',
name: '快速上手'
}, {
path: '/component/dev',
name: '开发指南'
}]
}]
}; };
},
created() {
this.navsData[0].children = navs;
}
} }
};
</script> </script>

View File

@ -6,9 +6,7 @@ const registerRoute = (config) => {
component: require('./pages/component.vue'), component: require('./pages/component.vue'),
children: [] children: []
}]; }];
config function addRoute(page) {
.map(nav =>
nav.list.map(page => {
const component = require(`./docs${page.path}.md`); const component = require(`./docs${page.path}.md`);
route[0].children.push({ route[0].children.push({
@ -19,8 +17,22 @@ const registerRoute = (config) => {
}, },
component: component.default || component component: component.default || component
}); });
}
config
.map(nav => {
if (nav.groups) {
nav.groups.map(group => {
group.list.map(page => {
addRoute(page);
}) })
); });
}
if (nav.children) {
nav.children.map(page => {
addRoute(page);
});
}
});
return { route, navs: config }; return { route, navs: config };
}; };
@ -48,12 +60,18 @@ let resourceRoute = {
component: require('./pages/resource.vue') component: require('./pages/resource.vue')
}; };
let indexRoute = {
path: '/',
name: '首页',
component: require('./pages/index.vue')
};
let changeLogRoute = { let changeLogRoute = {
path: '/changelog', path: '/changelog',
component: require('./pages/changelog.vue') component: require('./pages/changelog.vue')
}; };
route.route = route.route.concat([guideRoute, resourceRoute, changeLogRoute]); route.route = route.route.concat([indexRoute, guideRoute, resourceRoute, changeLogRoute]);
route.route.push({ route.route.push({
path: '*', path: '*',