Skip to content

Commit 8d43e4a

Browse files
committed
add layout demo and doc
1 parent 4adc7a8 commit 8d43e4a

File tree

18 files changed

+763
-128
lines changed

18 files changed

+763
-128
lines changed

components/layout/Sider.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export default {
206206
const triggerDom = (
207207
trigger !== null
208208
? zeroWidthTrigger || (
209-
<div className={`${prefixCls}-trigger`} onClick={this.toggle} style={{ width: `${siderWidth}px` }}>
209+
<div class={`${prefixCls}-trigger`} onClick={this.toggle} style={{ width: `${siderWidth}px` }}>
210210
{trigger || defaultTrigger}
211211
</div>
212212
) : null

components/layout/demo/custom-trigger.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ If you want to use a customized trigger, you can hide the default one by setting
1717
v-model="collapsed"
1818
>
1919
<div class="logo" />
20-
<a-menu theme="dark" mode="inline" defaultSelectedKeys={['1']}>
20+
<a-menu theme="dark" mode="inline" :defaultSelectedKeys="['1']">
2121
<a-menu-item key="1">
2222
<a-icon type="user" />
2323
<span>nav 1</span>
@@ -33,13 +33,13 @@ If you want to use a customized trigger, you can hide the default one by setting
3333
</a-menu>
3434
</a-layout-sider>
3535
<a-layout>
36-
<a-header style="background: #fff; padding: 0">
36+
<a-layout-header style="background: #fff; padding: 0">
3737
<a-icon
3838
class="trigger"
3939
:type="collapsed ? 'menu-unfold' : 'menu-fold'"
4040
@click="()=> collapsed = !collapsed"
4141
/>
42-
</a-header>
42+
</a-layout-header>
4343
<a-layout-content :style="{ margin: '24px 16px', padding: '24px', background: '#fff', minHeight: '280px' }">
4444
Content
4545
</a-layout-content>

components/layout/demo/fixed-sider.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<cn>
2+
#### 固定侧边栏
3+
当内容较长时,使用固定侧边栏可以提供更好的体验。
4+
</cn>
5+
6+
<us>
7+
#### Fixed Sider
8+
When dealing with long content, a fixed sider can provide a better user experience.
9+
</us>
10+
11+
```html
12+
<template>
13+
<a-layout id="components-layout-demo-fixed-sider">
14+
<a-layout-sider :style="{ overflow: 'auto', height: '100vh', position: 'fixed', left: 0 }">
15+
<div class="logo" />
16+
<a-menu theme="dark" mode="inline" :defaultSelectedKeys="['4']">
17+
<a-menu-item key="1">
18+
<a-icon type="user" />
19+
<span class="nav-text">nav 1</span>
20+
</a-menu-item>
21+
<a-menu-item key="2">
22+
<a-icon type="video-camera" />
23+
<span class="nav-text">nav 2</span>
24+
</a-menu-item>
25+
<a-menu-item key="3">
26+
<a-icon type="upload" />
27+
<span class="nav-text">nav 3</span>
28+
</a-menu-item>
29+
<a-menu-item key="4">
30+
<a-icon type="bar-chart" />
31+
<span class="nav-text">nav 4</span>
32+
</a-menu-item>
33+
<a-menu-item key="5">
34+
<a-icon type="cloud-o" />
35+
<span class="nav-text">nav 5</span>
36+
</a-menu-item>
37+
<a-menu-item key="6">
38+
<a-icon type="appstore-o" />
39+
<span class="nav-text">nav 6</span>
40+
</a-menu-item>
41+
<a-menu-item key="7">
42+
<a-icon type="team" />
43+
<span class="nav-text">nav 7</span>
44+
</a-menu-item>
45+
<a-menu-item key="8">
46+
<a-icon type="shop" />
47+
<span class="nav-text">nav 8</span>
48+
</a-menu-item>
49+
</a-menu>
50+
</a-layout-sider>
51+
<a-layout :style="{ marginLeft: '200px' }">
52+
<a-layout-header :style="{ background: '#fff', padding: 0 }" />
53+
<a-layout-content :style="{ margin: '24px 16px 0', overflow: 'initial' }">
54+
<div :style="{ padding: '24px', background: '#fff', textAlign: 'center' }">
55+
...
56+
<br />
57+
Really
58+
<br />...<br />...<br />...<br />
59+
long
60+
<br />...<br />...<br />...<br />...<br />...<br />...
61+
<br />...<br />...<br />...<br />...<br />...<br />...
62+
<br />...<br />...<br />...<br />...<br />...<br />...
63+
<br />...<br />...<br />...<br />...<br />...<br />...
64+
<br />...<br />...<br />...<br />...<br />...<br />...
65+
<br />...<br />...<br />...<br />...<br />...<br />...
66+
<br />...<br />...<br />...<br />...<br />...<br />
67+
content
68+
</div>
69+
</a-layout-content>
70+
<a-layout-footer :style="{ textAlign: 'center' }">
71+
Ant Design ©2016 Created by Ant UED
72+
</a-layout-footer>
73+
</a-layout>
74+
</a-layout>
75+
<template>
76+
<style>
77+
#components-layout-demo-fixed-sider .logo {
78+
height: 32px;
79+
background: rgba(255,255,255,.2);
80+
margin: 16px;
81+
}
82+
</style>
83+
```

components/layout/demo/fixed.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<cn>
2+
#### 固定头部
3+
一般用于固定顶部导航,方便页面切换。
4+
</cn>
5+
6+
<us>
7+
#### Fixed Header
8+
Fixed Header is generally used to fix the top navigation to facilitate page switching.
9+
</us>
10+
11+
```html
12+
<template>
13+
<a-layout id="components-layout-demo-fixed">
14+
<a-layout-header :style="{ position: 'fixed', width: '100%' }">
15+
<div class="logo" />
16+
<a-menu
17+
theme="dark"
18+
mode="horizontal"
19+
:defaultSelectedKeys="['2']"
20+
:style="{ lineHeight: '64px' }"
21+
>
22+
<a-menu-item key="1">nav 1</a-menu-item>
23+
<a-menu-item key="2">nav 2</a-menu-item>
24+
<a-menu-item key="3">nav 3</a-menu-item>
25+
</Menu>
26+
</a-layout-header>
27+
<a-layout-content :style="{ padding: '0 50px', marginTop: '64px' }">
28+
<a-breadcrumb :style="{ margin: '16px 0' }">
29+
<a-breadcrumb-item>Home</a-breadcrumb-item>
30+
<a-breadcrumb-item>List</a-breadcrumb-item>
31+
<a-breadcrumb-item>App</a-breadcrumb-item>
32+
</a-breadcrumb>
33+
<div :style="{ background: '#fff', padding: '24px', minHeight: '380px' }">Content</div>
34+
</a-layout-content>
35+
<a-layout-footer :style="{ textAlign: 'center' }">
36+
Ant Design ©2016 Created by Ant UED
37+
</a-layout-footer>
38+
</a-layout>
39+
<template>
40+
<style>
41+
#components-layout-demo-fixed .logo {
42+
width: 120px;
43+
height: 31px;
44+
background: rgba(255,255,255,.2);
45+
margin: 16px 24px 16px 0;
46+
float: left;
47+
}
48+
</style>
49+
```

components/layout/demo/index.vue

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<script>
2+
import Basic from './basic'
3+
import CustomTrigger from './custom-trigger'
4+
import FixedSider from './fixed-sider'
5+
import Fixed from './fixed'
6+
import Responsive from './responsive'
7+
import Side from './side'
8+
import TopSide2 from './top-side-2'
9+
import TopSide from './top-side'
10+
import Top from './top'
11+
12+
import CN from '../index.zh-CN.md'
13+
import US from '../index.en-US.md'
14+
15+
const md = {
16+
cn: `# 布局
17+
协助进行页面级整体布局。
18+
19+
## 设计规则
20+
21+
### 尺寸
22+
23+
一级导航项偏左靠近 logo 放置,辅助菜单偏右放置。
24+
25+
- 顶部导航(大部分系统):一级导航高度 \`64px\`,二级导航 \`48px\`
26+
- 顶部导航(展示类页面):一级导航高度 \`80px\`,二级导航 \`56px\`
27+
- 顶部导航高度的范围计算公式为:\`48+8n\`
28+
- 侧边导航宽度的范围计算公式:\`200+8n\`
29+
30+
### 交互
31+
32+
- 一级导航和末级的导航需要在可视化的层面被强调出来;
33+
- 当前项应该在呈现上优先级最高;
34+
- 当导航收起的时候,当前项的样式自动赋予给它的上一个层级;
35+
- 左侧导航栏的收放交互同时支持手风琴和全展开的样式,根据业务的要求进行适当的选择。
36+
37+
### 视觉
38+
39+
导航样式上需要根据信息层级合理的选择样式:
40+
41+
- **大色块强调**
42+
43+
建议用于底色为深色系时,当前页面父级的导航项。
44+
45+
- **高亮火柴棍**
46+
47+
当导航栏底色为浅色系时使用,可用于当前页面对应导航项,建议尽量在导航路径的最终项使用。
48+
49+
- **字体高亮变色**
50+
51+
从可视化层面,字体高亮的视觉强化力度低于大色块,通常在当前项的上一级使用。
52+
53+
- **字体放大**
54+
55+
\`12px\`\`14px\` 是导航的标准字号,14 号字体用在一、二级导航中。字号可以考虑导航项的等级做相应选择。
56+
57+
## 组件概述
58+
59+
- \`Layout\`:布局容器,其下可嵌套 \`Header\` \`Sider\` \`Content\` \`Footer\`\`Layout\` 本身,可以放在任何父容器中。
60+
- \`Header\`:顶部布局,自带默认样式,其下可嵌套任何元素,只能放在 \`Layout\` 中。
61+
- \`Sider\`:侧边栏,自带默认样式及基本功能,其下可嵌套任何元素,只能放在 \`Layout\` 中。
62+
- \`Content\`:内容部分,自带默认样式,其下可嵌套任何元素,只能放在 \`Layout\` 中。
63+
- \`Footer\`:底部布局,自带默认样式,其下可嵌套任何元素,只能放在 \`Layout\` 中。
64+
65+
> 注意:采用 flex 布局实现,请注意[浏览器兼容性](http://caniuse.com/#search=flex)问题。
66+
67+
## 代码演示`,
68+
us: `# Layout
69+
Handling the overall layout of a page.
70+
71+
## Specification
72+
73+
### Size
74+
75+
The first level navigation is inclined left near a logo, and the secondary menu is inclined right.
76+
77+
- Top Navigation (almost systems): the height of the first level navigation \`64px\`, the second level navigation \`48px\`.
78+
- Top Navigation(contents page): the height of the first level navigation \`80px\`, the second level navigation \`56px\`.
79+
- Calculation formula of a top navigation: \`48+8n\`.
80+
- Calculation formula of an aside navigation: \`200+8n\`.
81+
82+
### Interaction rules
83+
84+
- The first level navigation and the last level navigation should be distincted by visualization;
85+
- The current item should have the highest priority of visualization;
86+
- When the current navigation item is collapsed, the stlye of the current navigation item will be applied to its parent level;
87+
- The left side navigation bar has support for both the accordion and expanding styles, you can choose the one that fits your case best.
88+
89+
## Visualization rules
90+
91+
Style of a navigation should conform to its level.
92+
93+
- **Emphasis by colorblock**
94+
95+
When background color is a deep color, you can use this pattern for the parent level navigation item of current page.
96+
97+
- **The highlight match stick**
98+
99+
When background color is a light color, you can use this pattern for the current page navigation item, we recommed using it for the last item of the navigation path.
100+
101+
- **Hightlighted font**
102+
103+
From the visualization aspect, hightlighted font is stronger than colorblock, this pattern is often used for the parent level of the current item.
104+
105+
- **Enlarge the size of the font**
106+
107+
\`12px\`\`14px\` is a standard font size of navigations,\`14px\` is used for the first and the second level of the navigation. You can choose a appropriate font size in terms of the level of your navigation.
108+
109+
## Component Overview
110+
111+
- \`Layout\`: The layout wrapper, in which \`Header\` \`Sider\` \`Content\` \`Footer\` or \`Layout\` itself can be nested, and can be placed in any parent container.
112+
- \`Header\`: The top layout with default style, in which any element can be nested, and must be placed in \`Layout\`.
113+
- \`Sider\`: The sidebar with default style and basic functions, in which any element can be nested, and must be placed in \`Layout\`.
114+
- \`Content\`: The content layout with default style, in which any element can be nested, and must be placed in \`Layout\`.
115+
- \`Footer\`: The bottom layout with default style, in which any element can be nested, and must be placed in \`Layout\`.
116+
117+
> Based on \`flex layout\`, please pay attention to the [compatibility](http://caniuse.com/#search=flex).
118+
119+
## Examples
120+
`,
121+
}
122+
export default {
123+
category: 'Components',
124+
subtitle: '布局',
125+
type: 'Layout',
126+
cols: 1,
127+
title: 'Layout',
128+
props: {
129+
iframeName: String,
130+
},
131+
provide () {
132+
return {
133+
iframeDemo: !this.iframeName ? {
134+
'fixed-sider': '/ant-design/iframe/layout/#fixed-sider',
135+
'fixed-header': '/ant-design/iframe/layout/#fixed-header',
136+
'sider': '/ant-design/iframe/layout/#sider',
137+
} : {},
138+
}
139+
},
140+
render () {
141+
const iframeName = this.iframeName
142+
if (iframeName === 'fixed-sider') {
143+
return <FixedSider/>
144+
} else if (iframeName === 'fixed-header') {
145+
return <Fixed />
146+
} else if (iframeName === 'sider') {
147+
return <Side />
148+
}
149+
return (
150+
<div>
151+
<md cn={md.cn} us={md.us}/>
152+
<Basic />
153+
<CustomTrigger />
154+
<TopSide2/>
155+
<TopSide/>
156+
<Top/>
157+
<Responsive />
158+
<FixedSider />
159+
<Fixed />
160+
<Side/>
161+
<api>
162+
<template slot='cn'>
163+
<CN/>
164+
</template>
165+
<US/>
166+
</api>
167+
</div>
168+
)
169+
},
170+
}
171+
</script>

0 commit comments

Comments
 (0)