Skip to content

Commit

Permalink
Merge pull request #40 from BearJ/develop
Browse files Browse the repository at this point in the history
代码优化
  • Loading branch information
progrape committed Feb 17, 2016
2 parents 7c334ef + 3dab534 commit 3917311
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 28 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
language: node_js
node_js:
- "stable"
- stable
script:
- npm test
- npm test
- npm run coverage
after_script:
npm install coveralls && cat ./coverage/lcov.info | coveralls
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WeUI 为微信Web服务量身设计 [![Build Status](https://travis-ci.org/weui/react-weui.svg?branch=master)](https://travis-ci.org/weui/react-weui) [![npm version](https://img.shields.io/npm/v/react-weui.svg)](https://www.npmjs.org/package/react-weui)
WeUI 为微信Web服务量身设计 [![Build Status](https://travis-ci.org/weui/react-weui.svg?branch=master)](https://travis-ci.org/weui/react-weui) [![npm version](https://img.shields.io/npm/v/react-weui.svg)](https://www.npmjs.org/package/react-weui) [![Coverage Status](https://coveralls.io/repos/github/weui/react-weui/badge.svg?branch=master)](https://coveralls.io/github/weui/react-weui?branch=master)
====


Expand Down
3 changes: 1 addition & 2 deletions docs/cell.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
属性名|类型|默认值|可选值|备注
------|----|------|------|----|
access|bool|false | true, false| 控制Cell是否显示小箭头以及点击的Active态
form |bool|false | true, false| 当Cell内有表单元素时使用

#### CellsTitle

Expand Down Expand Up @@ -100,4 +99,4 @@ body{
text-overflow: ellipsis;
}
}
```
```
10 changes: 6 additions & 4 deletions example/component/page.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ body{
padding: 0 15px;
}
}
}

.page.cell .bd {
padding-bottom: 30px;
}
&.cell{
.bd{
padding-bottom: 15px;
}
}
}
6 changes: 4 additions & 2 deletions example/pages/cell/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ export default class CellDemo extends React.Component {
<CellsTitle>文本域</CellsTitle>
<Form>
<FormCell>
<TextArea placeholder="请输入评论" rows="3" maxlength="200"></TextArea>
<CellBody>
<TextArea placeholder="请输入评论" rows="3" maxlength="200"></TextArea>
</CellBody>
</FormCell>
</Form>
</Page>
);
}
};
};
17 changes: 14 additions & 3 deletions src/components/cell/cells.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,28 @@ import React from 'react';
import classNames from 'classnames';

export default class Cells extends React.Component {
static propTypes = {
access: React.PropTypes.bool,
radio: React.PropTypes.bool,
checkbox: React.PropTypes.bool
};

static defaultProps = {
access: false,
radio: false,
checkbox: false
};

render() {
const {children, className, access, radio, checkbox, form, ...others} = this.props;
const {children, className, access, radio, checkbox, ...others} = this.props;
const cls = classNames({
weui_cells: true,
weui_cells_access: access,
weui_cells_form: form,
[className]: className
});

return (
<div className={cls} {...others}>{children}</div>
);
}
};
};
25 changes: 13 additions & 12 deletions src/components/form/textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,43 @@
*/



import React, { Component, PropTypes } from 'react';
import CellBody from '../cell/cell_body';
import classNames from 'classnames';

export default class TextArea extends React.Component {
static propTypes = {
showCounter: PropTypes.bool,
showCounter: PropTypes.bool
};

static defaultProps = {
showCounter: true,
showCounter: true
};

state = {
textCounter: 0
};

handleChange(e){
this.setState({textCounter: e.target.value.length});
//forward event to props if any
if(this.props.onChange) this.props.onChange(e);
this.setState({textCounter: e.target.value.length});

//forward event to props if any
if(this.props.onChange) this.props.onChange(e);
}

render() {
render(){
const { className, children, showCounter, maxlength, ...others } = this.props;
const cls = classNames({
weui_textarea: true,
[className]: className
});

return (
<CellBody>
<textarea className={cls} maxLength={maxlength} onChange={this.handleChange.bind(this)} {...others}>{children}</textarea>
{showCounter ? <div className="weui_textarea_counter"><span>{this.state.textCounter}</span>/{maxlength ? maxlength : '∞'}</div> : false}
</CellBody>
<div>
<textarea className={cls} maxLength={maxlength}
onChange={this.handleChange.bind(this)} {...others}>{children}</textarea>
{showCounter ? <div className="weui_textarea_counter">
<span>{this.state.textCounter}</span>{maxlength ? '/' + maxlength : false}</div> : false}
</div>
);
}
};
4 changes: 2 additions & 2 deletions src/components/input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ export default class Input extends React.Component {
};

render() {
const { className, defaultValue, ...others } = this.props;
const { className, ...others } = this.props;
const cls = classNames({
weui_input: true,
[className]: className
});

return (
<input className={cls} defaultValue={defaultValue} {...others}/>
<input className={cls} {...others}/>
);
}
};

0 comments on commit 3917311

Please sign in to comment.