Skip to content

Commit 7e6e7d1

Browse files
committed
Merge pull request #42 from BearJ/develop
add switch, fix bug
2 parents 2fd9f40 + 81f0859 commit 7e6e7d1

File tree

8 files changed

+60
-20
lines changed

8 files changed

+60
-20
lines changed

example/component/page.less

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11

22
html, body, .container {
33
height: 100%;
4-
overflow: hidden;
54
}
65

76
body {
87
background-color: #FBF9FE;
98
}
109

10+
.container{
11+
overflow: hidden;
12+
}
13+
1114
.page {
1215
position: absolute;
1316
top: 0;
@@ -79,4 +82,4 @@ body {
7982
opacity: 0.01;
8083
transform: translate3d(100%, 0, 0);
8184
}
82-
}
85+
}

example/pages/cell/index.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { ButtonArea,
1919
Icon,
2020
Input,
2121
Label,
22-
TextArea
22+
TextArea,
23+
Switch
2324
} from '../../../src/index';
2425
import Page from '../../component/page';
2526
import iconSrc from './images/icon.png';
@@ -114,6 +115,16 @@ export default class CellDemo extends React.Component {
114115
</Cell>
115116
</Cells>
116117

118+
<CellsTitle>开关</CellsTitle>
119+
<Form>
120+
<FormCell switch>
121+
<CellBody>标题文字</CellBody>
122+
<CellFooter>
123+
<Switch/>
124+
</CellFooter>
125+
</FormCell>
126+
</Form>
127+
117128
<Form>
118129
<FormCell>
119130
<CellHeader>

src/components/form/form_cell.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ export default class FormCell extends React.Component {
1919
};
2020

2121
render() {
22-
const { className, children, vcode, warn, ...others } = this.props;
22+
const { className, children, ...others } = this.props;
2323
const cls = classNames({
2424
weui_cell: true,
25-
weui_vcode: vcode,
26-
weui_cell_warn: warn,
25+
weui_vcode: this.props.vcode,
26+
weui_cell_warn: this.props.warn,
27+
weui_cell_switch: this.props.switch,
2728
[className]: className
2829
});
2930

src/components/form/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
import Form from './form';
99
import FormCell from './form_cell';
1010
import TextArea from './textarea';
11+
import Input from './input';
12+
import Switch from './switch';
1113

1214
export default {
1315
Form,
1416
FormCell,
15-
TextArea
16-
};
17+
TextArea,
18+
Input,
19+
Switch
20+
};
File renamed without changes.

src/components/form/switch.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Created by BearJ on 16/2/18.
3+
*/
4+
5+
6+
7+
import React, { Component, PropTypes } from 'react';
8+
import classNames from 'classnames';
9+
10+
export default class Switch extends React.Component {
11+
static propTypes = {
12+
defaultValue: PropTypes.string
13+
};
14+
15+
static defaultProps = {
16+
defaultValue: undefined
17+
};
18+
19+
render() {
20+
const { className, ...others } = this.props;
21+
const cls = classNames({
22+
weui_switch: true,
23+
[className]: className
24+
});
25+
26+
return (
27+
<input className={cls} type="checkbox" {...others}/>
28+
);
29+
}
30+
};

src/components/input/index.js

-9
This file was deleted.

src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import {Button, ButtonArea} from './components/button/index';
66
import {Cells, CellsTitle, CellsTips, Cell, CellHeader, CellBody, CellFooter} from './components/cell/index';
77
import Mask from './components/mask/index';
8-
import {Form, FormCell, TextArea} from './components/form/index';
9-
import Input from './components/input/index';
8+
import {Form, FormCell, TextArea, Input, Switch} from './components/form/index';
109
import Label from './components/label/index';
1110
import Toast from './components/toast/index';
1211
import Progress from './components/progress/index';
@@ -32,6 +31,7 @@ export default {
3231
FormCell,
3332
Input,
3433
TextArea,
34+
Switch,
3535
Label,
3636
Toast,
3737
Progress,
@@ -44,4 +44,4 @@ export default {
4444
Grid,
4545
GridIcon,
4646
GridLabel
47-
};
47+
};

0 commit comments

Comments
 (0)