Skip to content

Commit

Permalink
New component divider (ant-design#7261)
Browse files Browse the repository at this point in the history
* Add Divider

* use Divider in table demos

* update demo instruction

* upgrade snapshots
  • Loading branch information
afc163 authored Aug 19, 2017
1 parent c28c2f6 commit 3b59a03
Show file tree
Hide file tree
Showing 17 changed files with 298 additions and 81 deletions.
1 change: 1 addition & 0 deletions components/__tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Array [
"Checkbox",
"Col",
"DatePicker",
"Divider",
"Dropdown",
"Form",
"Icon",
Expand Down
49 changes: 49 additions & 0 deletions components/divider/__tests__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders ./components/divider/demo/horizontal.md correctly 1`] = `
<div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
</p>
<div
class="ant-divider ant-divider-horizontal"
/>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
</p>
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text"
>
<span
class="ant-divider-inner-text"
>
With Text
</span>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.
</p>
</div>
`;

exports[`renders ./components/divider/demo/vertical.md correctly 1`] = `
<div>
Text
<div
class="ant-divider ant-divider-vertical"
/>
<a
href="#"
>
Link
</a>
<div
class="ant-divider ant-divider-vertical"
/>
<a
href="#"
>
Link
</a>
</div>
`;
3 changes: 3 additions & 0 deletions components/divider/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('divider');
28 changes: 28 additions & 0 deletions components/divider/demo/horizontal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
order: 0
title:
zh-CN: 水平分割线
en-US: Horizontal
---

## zh-CN

默认为水平分割线,可在中间加入文字。

## en-US

Divider default type is `horizontal`. Support inner text inside Divider.

````jsx
import { Divider } from 'antd';

ReactDOM.render(
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p>
<Divider />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p>
<Divider>With Text</Divider>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, quo modo.</p>
</div>
, mountNode);
````
28 changes: 28 additions & 0 deletions components/divider/demo/vertical.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
order: 1
title:
zh-CN: 垂直分割线
en-US: Vertical
---

## zh-CN

使用 `type="vertical"` 设置为行内的垂直分割线。

## en-US

Use `type="vertical"` make it vertical.

````jsx
import { Divider } from 'antd';

ReactDOM.render(
<div>
Text
<Divider type="vertical" />
<a href="#">Link</a>
<Divider type="vertical" />
<a href="#">Link</a>
</div>
, mountNode);
````
21 changes: 21 additions & 0 deletions components/divider/index.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
category: Components
type: Other
title: Divider
cols: 1
---

A divider line separates different content.

## When To Use

- Divide sections of article.
- Divide inline text and links such as the operation column of table.

## API

### Divider

Property | Description | Type | Default
---------|-------------|------|--------
type | direction type of divider | enum: `horizontal` `vertical` | `horizontal`
20 changes: 20 additions & 0 deletions components/divider/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import classNames from 'classnames';

export default function Divider({
prefixCls = 'ant',
type = 'horizontal',
className,
children,
...restProps,
}) {
const classString = classNames(className, `${prefixCls}-divider`, {
[`${prefixCls}-divider-${type}`]: true,
[`${prefixCls}-divider-with-text`]: children,
});
return (
<div className={classString} {...restProps}>
{children && <span className={`${prefixCls}-divider-inner-text`}>{children}</span>}
</div>
);
}
19 changes: 19 additions & 0 deletions components/divider/index.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
category: Components
type: Other
title: Divider
subtitle: 分割线
---

区隔内容的分割线。

## 何时使用

- 对不同章节的文本段落进行分割。
- 对行内文字/链接进行分割,例如表格的操作列。

## API

参数 | 说明 | 类型 | 默认值
----|-----|------|------
type | 水平还是垂直类型 | enum: `horizontal` `vertical` | `horizontal`
51 changes: 51 additions & 0 deletions components/divider/style/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@import "../../style/themes/default";
@import "../../style/mixins/index";

@divider-prefix-cls: ~"@{ant-prefix}-divider";

.@{divider-prefix-cls} {
background: @border-color-split;

&, // for compatiable
&-vertical {
margin: 0 8px;
display: inline-block;
height: 0.9em;
width: 1px;
vertical-align: middle;
position: relative;
top: -0.06em;
}
&-horizontal {
display: block;
height: 1px;
width: 100%;
margin: 24px 0;
}
&-horizontal&-with-text {
display: table;
white-space: nowrap;
text-align: center;
background: transparent;
font-weight: 500;
color: @heading-color;
font-size: 16px;
margin: 16px 0;

&:before,
&:after {
content: '';
display: table-cell;
position: relative;
top: 50%;
width: 50%;
border-top: 1px solid @border-color-split;
transform: translateY(50%);
}
}

&-inner-text {
display: inline-block;
padding: 0 24px;
}
}
2 changes: 2 additions & 0 deletions components/divider/style/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../../style/index.less';
import './index.less';
2 changes: 2 additions & 0 deletions components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export { default as Col } from './col';

export { default as DatePicker } from './date-picker';

export { default as Divider } from './divider';

export { default as Dropdown } from './dropdown';

export { default as Form } from './form';
Expand Down
8 changes: 0 additions & 8 deletions components/style/core/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ a {
}
}

.@{ant-prefix}-divider {
margin: 0 6px;
display: inline-block;
height: 8px;
width: 1px;
background: #ccc;
}

code,
kbd,
pre,
Expand Down
Loading

0 comments on commit 3b59a03

Please sign in to comment.