mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
Merge branch 'master' of github.com:ant-design/ant-design
This commit is contained in:
commit
86f219de1c
@ -1,8 +1,8 @@
|
|||||||
# 基本用法
|
# 用法示例
|
||||||
|
|
||||||
- order: 0
|
- order: 0
|
||||||
|
|
||||||
简单的 switch。
|
switch 用法
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -14,5 +14,22 @@ function onChange(checked){
|
|||||||
console.log('switch to ' + checked);
|
console.log('switch to ' + checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
React.render(<Switch defaultChecked={false} onChange={onChange}/>, container);
|
React.render(<div>
|
||||||
|
<p>
|
||||||
|
simple:
|
||||||
|
<Switch defaultChecked={false} onChange={onChange}/><br/>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
disabled:
|
||||||
|
<Switch disabled/><br/>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
children:
|
||||||
|
<Switch checkedChildren="开" unCheckedChildren="关"/><br/>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
icon children:
|
||||||
|
<Switch checkedChildren={<i className="anticon anticon-check"></i>} unCheckedChildren={<i className="anticon anticon-cross"></i>}/>
|
||||||
|
</p>
|
||||||
|
</div>, container);
|
||||||
````
|
````
|
||||||
|
@ -21,3 +21,5 @@
|
|||||||
| checked | 指定当前是否选中 | boolean | | false |
|
| checked | 指定当前是否选中 | boolean | | false |
|
||||||
| defaultChecked | 初始是否选中 | boolean | | false |
|
| defaultChecked | 初始是否选中 | boolean | | false |
|
||||||
| onChange | 变化时回调函数 | Function(checked:boolean) | | |
|
| onChange | 变化时回调函数 | Function(checked:boolean) | | |
|
||||||
|
| checkedChildren | 选中时的内容 | React Node | | |
|
||||||
|
| unCheckedChildren | 非选中时的内容 | React Node | | |
|
@ -11,6 +11,7 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/ant-design/ant-design/issues"
|
"url": "https://github.com/ant-design/ant-design/issues"
|
||||||
},
|
},
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"gregorian-calendar": "~3.0.0",
|
"gregorian-calendar": "~3.0.0",
|
||||||
"gregorian-calendar-format": "~3.0.1",
|
"gregorian-calendar-format": "~3.0.1",
|
||||||
@ -23,7 +24,7 @@
|
|||||||
"rc-progress": "~1.0.0",
|
"rc-progress": "~1.0.0",
|
||||||
"rc-select": "~4.2.1",
|
"rc-select": "~4.2.1",
|
||||||
"rc-steps": "~1.1.3",
|
"rc-steps": "~1.1.3",
|
||||||
"rc-switch": "~1.1.0",
|
"rc-switch": "~1.2.0",
|
||||||
"rc-tabs": "~5.2.0",
|
"rc-tabs": "~5.2.0",
|
||||||
"rc-tooltip": "~2.4.0"
|
"rc-tooltip": "~2.4.0"
|
||||||
},
|
},
|
||||||
@ -47,6 +48,7 @@
|
|||||||
"webpack": "^1.10.1",
|
"webpack": "^1.10.1",
|
||||||
"webpack-dev-middleware": "^1.2.0"
|
"webpack-dev-middleware": "^1.2.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"babel": "babel components --out-dir lib",
|
"babel": "babel components --out-dir lib",
|
||||||
"build": "npm run clean && webpack && nico build",
|
"build": "npm run clean && webpack && nico build",
|
||||||
|
@ -1,34 +1,43 @@
|
|||||||
@switchPrefixCls:ant-switch;
|
@switchPrefixCls:ant-switch;
|
||||||
|
|
||||||
|
@duration:.3s;
|
||||||
|
|
||||||
.@{switchPrefixCls}{
|
.@{switchPrefixCls}{
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 38px;
|
box-sizing: border-box;
|
||||||
height: 20px;
|
width: 44px;
|
||||||
|
height: 22px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
border-radius: 20px 20px;
|
border-radius: 20px 20px;
|
||||||
border: 1px solid #bcbcbc;
|
border: 1px solid #ccc;
|
||||||
background-color: #bcbcbc;
|
background-color: #ccc;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.3s cubic-bezier(0.35, 0, 0.25, 1);
|
transition: all @duration cubic-bezier(0.35, 0, 0.25, 1);
|
||||||
|
|
||||||
|
&-inner {
|
||||||
|
color:#fff;
|
||||||
|
font-size: 12px;
|
||||||
|
position: absolute;
|
||||||
|
left:24px;
|
||||||
|
}
|
||||||
|
|
||||||
&:after{
|
&:after{
|
||||||
display: block;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -1px;
|
width: 18px;
|
||||||
left: -1px;
|
height: 18px;
|
||||||
width: 20px;
|
left: 2px;
|
||||||
height: 20px;
|
top:1px;
|
||||||
border-radius: 50% 50%;
|
border-radius: 50% 50%;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
content: " ";
|
content: " ";
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.26);
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.26);
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
transition: left 0.3s cubic-bezier(0.35, 0, 0.25, 1);
|
transition: left @duration cubic-bezier(0.35, 0, 0.25, 1);
|
||||||
animation-timing-function: cubic-bezier(0.35, 0, 0.25, 1);
|
animation-timing-function: cubic-bezier(0.35, 0, 0.25, 1);
|
||||||
animation-duration: 0.3s;
|
animation-duration: @duration;
|
||||||
animation-name: rcSwitchOff;
|
animation-name: rcSwitchOff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,16 +47,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-checked{
|
&-checked{
|
||||||
border: 1px solid #64b6f7;
|
border: 1px solid #87d068;
|
||||||
background-color: #64b6f7;
|
background-color: #87d068;
|
||||||
|
|
||||||
|
.@{switchPrefixCls}-inner {
|
||||||
|
left:6px;
|
||||||
|
}
|
||||||
|
|
||||||
&:after{
|
&:after{
|
||||||
left: 18px;
|
left: 22px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-disabled{
|
&-disabled{
|
||||||
cursor: no-drop;
|
cursor: no-drop;
|
||||||
|
background: #ccc;
|
||||||
|
border-color:#ccc;
|
||||||
|
|
||||||
&:after{
|
&:after{
|
||||||
background: #9e9e9e;
|
background: #9e9e9e;
|
||||||
|
Loading…
Reference in New Issue
Block a user