Skip to content

Commit

Permalink
Pannel API break change
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeLin committed Sep 7, 2017
1 parent 9daa684 commit 7f3bfbd
Show file tree
Hide file tree
Showing 35 changed files with 235 additions and 295 deletions.
5 changes: 2 additions & 3 deletions components/Panel/Panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import classnames from 'classnames';

class Panel extends PureComponent {
render() {
const { prefixCls, className, children, ...others } = this.props;
const { prefixCls, className, children } = this.props;

const cls = classnames({
[`${prefixCls}`]: true,
[className]: !!className,
});

return <div {...others} className={cls}>{children}</div>;
return <div className={cls}>{children}</div>;
}
}

Expand All @@ -22,7 +22,6 @@ Panel.propTypes = {

Panel.defaultProps = {
prefixCls: 'za-panel',
className: null,
};

export default Panel;
14 changes: 9 additions & 5 deletions components/Panel/PanelFooter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import classnames from 'classnames';

class PanelFooter extends PureComponent {
render() {
const { prefixCls, className, children, ...others } = this.props;
const { prefixCls, className, title, more } = this.props;

const cls = classnames({
[`${prefixCls}`]: true,
[`${prefixCls}-footer`]: true,
[className]: !!className,
});

return <div {...others} className={cls}>{children}</div>;
return (
<div className={cls}>
{ title && <div className={`${prefixCls}-title`}>{title}</div> }
{ more && <div className={`${prefixCls}-more`}>{more}</div> }
</div>
);
}
}

Expand All @@ -21,8 +26,7 @@ PanelFooter.propTypes = {
};

PanelFooter.defaultProps = {
prefixCls: 'za-panel-footer',
className: null,
prefixCls: 'za-panel',
};

export default PanelFooter;
14 changes: 9 additions & 5 deletions components/Panel/PanelHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import classnames from 'classnames';

class PanelHeader extends PureComponent {
render() {
const { prefixCls, className, children, ...others } = this.props;
const { prefixCls, className, title, more } = this.props;

const cls = classnames({
[`${prefixCls}`]: true,
[`${prefixCls}-header`]: true,
[className]: !!className,
});

return <div {...others} className={cls}>{children}</div>;
return (
<div className={cls}>
{ title && <div className={`${prefixCls}-title`}>{title}</div> }
{ more && <div className={`${prefixCls}-more`}>{more}</div> }
</div>
);
}
}

Expand All @@ -21,8 +26,7 @@ PanelHeader.propTypes = {
};

PanelHeader.defaultProps = {
prefixCls: 'za-panel-header',
className: null,
prefixCls: 'za-panel',
};

export default PanelHeader;
28 changes: 0 additions & 28 deletions components/Panel/PanelMore.jsx

This file was deleted.

28 changes: 0 additions & 28 deletions components/Panel/PanelTitle.jsx

This file was deleted.

13 changes: 12 additions & 1 deletion components/Panel/__tests__/__snapshots__/index.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ exports[`Panel renders correctly 1`] = `
</div>
<div
class="za-panel-footer"
/>
>
<div
class="za-panel-title"
>
title
</div>
<div
class="za-panel-more"
>
more
</div>
</div>
</div>
`;
7 changes: 2 additions & 5 deletions components/Panel/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ describe('Panel', () => {
it('renders correctly', () => {
const wrapper = render(
<Panel>
<Panel.Header>
<Panel.Title>title</Panel.Title>
<Panel.More>more</Panel.More>
</Panel.Header>
<Panel.Header title="title" more="more" />
<Panel.Body>body</Panel.Body>
<Panel.Footer />
<Panel.Footer title="title" more="more" />
</Panel>
);
expect(toJson(wrapper)).toMatchSnapshot();
Expand Down
4 changes: 0 additions & 4 deletions components/Panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import Panel from './Panel';
import PanelHeader from './PanelHeader';
import PanelBody from './PanelBody';
import PanelFooter from './PanelFooter';
import PanelTitle from './PanelTitle';
import PanelMore from './PanelMore';

Panel.Header = PanelHeader;
Panel.Body = PanelBody;
Panel.Footer = PanelFooter;
Panel.Title = PanelTitle;
Panel.More = PanelMore;

export default Panel;
73 changes: 73 additions & 0 deletions docs/zh-cn/components/Panel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 面板 Panel

[demo页面](https://zhongantecheng.github.io/zarm/#/panel)

### 引入

```js
import { Panel } from 'zarm';
```

### 代码演示

#### 基本用法

###### 普通
```jsx
<Panel>
<Panel.Header title="普通" />
<Panel.Body>body</Panel.Body>
</Panel>
```

###### 带更多按钮
```jsx
<Panel>
<Panel.Header title="带更多按钮" more={<a onClick={() => alert('click more')}>更多</a>} />
<Panel.Body>body</Panel.Body>
</Panel>
```

###### 带底部
```jsx
<Panel>
<Panel.Header title="带底部" />
<Panel.Body>body</Panel.Body>
<Panel.Footer title="左侧文案" more="右侧文案" />
</Panel>
```


### API

#### Panel

| 属性 | 类型 | 默认值 | 可选值/参数 | 说明 |
| :--- | :--- | :--- | :--- | :--- |
| prefixCls | string | za-panel | | 类名前缀 |
| className | string | | | 追加类名 |
| children | React.element | | | 内容 |


#### Panel.Header

| 属性 | 类型 | 默认值 | 可选值/参数 | 说明 |
| :--- | :--- | :--- | :--- | :--- |
| prefixCls | string | za-panel | | 类名前缀 |
| className | string | | | 追加类名 |
| title | React.element | | | 标题 |
| more | React.element | | | 更多 |


#### Panel.Footer

| 属性 | 类型 | 默认值 | 可选值/参数 | 说明 |
| :--- | :--- | :--- | :--- | :--- |
| prefixCls | string | za-panel | | 类名前缀 |
| className | string | | | 追加类名 |
| title | React.element | | | 标题 |
| more | React.element | | | 更多 |




8 changes: 8 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ const rootRoute = {
});
},
},
{
path: 'panel',
getComponent(location, cb) {
require.ensure([], (require) => {
cb(null, require('./pages/PanelPage'));
});
},
},
{
path: 'progress',
getComponent(location, cb) {
Expand Down
File renamed without changes.
4 changes: 1 addition & 3 deletions examples/pages/ActionSheetPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class Page extends Component {
<Header title="动作面板 ActionSheet" />
<main>
<Panel>
<Panel.Header>
<Panel.Title>提示信息</Panel.Title>
</Panel.Header>
<Panel.Header title="提示信息" />
<Panel.Body>

<Cell
Expand Down
8 changes: 2 additions & 6 deletions examples/pages/BadgePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class Page extends Component {
<Header title="徽标 Badge" />
<main>
<Panel>
<Panel.Header>
<Panel.Title>基本</Panel.Title>
</Panel.Header>
<Panel.Header title="基本" />
<Panel.Body>
<Cell hasArrow title="点状" description={<Badge shape="dot" />} onClick={() => {}} />
<Cell hasArrow title="直角" description={<Badge text="免费" />} onClick={() => {}} />
Expand All @@ -26,9 +24,7 @@ class Page extends Component {
</Panel>

<Panel>
<Panel.Header>
<Panel.Title>上标位置</Panel.Title>
</Panel.Header>
<Panel.Header title="上标位置" />
<Panel.Body className="custom-panel">
<div className="box">
<Badge sup shape="dot"><div className="box-item" /></Badge>
Expand Down
24 changes: 6 additions & 18 deletions examples/pages/ButtonPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class Page extends Component {
<Header title="按钮 Button" />
<main>
<Panel>
<Panel.Header>
<Panel.Title>基本</Panel.Title>
</Panel.Header>
<Panel.Header title="基本" />
<Panel.Body>
<Button theme="primary">普通按钮</Button>
<Button theme="primary" block>块级按钮</Button>
Expand All @@ -25,9 +23,7 @@ class Page extends Component {
</Panel>

<Panel>
<Panel.Header>
<Panel.Title>幽灵按钮</Panel.Title>
</Panel.Header>
<Panel.Header title="幽灵按钮" />
<Panel.Body>
<Button block bordered>幽灵按钮</Button>
<Button block bordered active>激活状态的按钮</Button>
Expand All @@ -39,9 +35,7 @@ class Page extends Component {
</Panel>

<Panel>
<Panel.Header>
<Panel.Title>多主题</Panel.Title>
</Panel.Header>
<Panel.Header title="主题" />
<Panel.Body>
<Button>default</Button>
<Button theme="primary">primary</Button>
Expand All @@ -53,9 +47,7 @@ class Page extends Component {
</Panel>

<Panel>
<Panel.Header>
<Panel.Title>按钮大小</Panel.Title>
</Panel.Header>
<Panel.Header title="大小" />
<Panel.Body>
<Button theme="primary" size="xl">xl</Button>
<Button theme="primary" size="lg">lg</Button>
Expand All @@ -66,9 +58,7 @@ class Page extends Component {
</Panel>

<Panel>
<Panel.Header>
<Panel.Title>多形状</Panel.Title>
</Panel.Header>
<Panel.Header title="形状" />
<Panel.Body>
<Button bordered shape="radius">圆角按钮</Button>
<Button bordered shape="round">椭圆角按钮</Button>
Expand All @@ -78,9 +68,7 @@ class Page extends Component {
</Panel>

<Panel>
<Panel.Header>
<Panel.Title>带icon的按钮</Panel.Title>
</Panel.Header>
<Panel.Header title="带Icon" />
<Panel.Body>
<Button bordered shape="radius" icon={<Icon type="right-round" theme="success" />}>正确</Button>
<Button bordered shape="radius" icon={<Icon type="wrong-round" theme="error" />}>错误</Button>
Expand Down
Loading

0 comments on commit 7f3bfbd

Please sign in to comment.