add Switch UI

add Switch UI
This commit is contained in:
梁灏 2016-09-21 14:59:57 +08:00
parent 6c5fbd8b04
commit 07aa688e3c
8 changed files with 133 additions and 10 deletions

View file

@ -18,7 +18,7 @@
v-model="checked"
@change="change">
</span>
<slot>{{ value }}</slot>
<slot><span>{{ value }}</span></slot>
</label>
</template>
<script>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -102,9 +102,23 @@
<Checkbox value="苹果" disabled></Checkbox>
<Checkbox value="西瓜"></Checkbox>
</Checkbox-group>
<br><br>
<Switch @on-change="change"></Switch>
<br><br>
<Switch>
<span slot="open"></span>
<span slot="close"></span>
</Switch>
<br><br>
<Switch>
<Icon type="android-done" slot="open"></Icon>
<Icon type="android-close" slot="close"></Icon>
</Switch>
<Switch disabled></Switch>
<Switch size="small"></Switch>
</template>
<script>
import { Radio, Alert, Icon, Collapse, Button, Checkbox } from 'iview';
import { Radio, Alert, Icon, Collapse, Button, Checkbox, Switch } from 'iview';
const RadioGroup = Radio.Group;
const Panel = Collapse.Panel;
@ -120,7 +134,8 @@
Panel,
Button,
Checkbox,
CheckboxGroup
CheckboxGroup,
Switch
},
props: {
@ -146,6 +161,9 @@
},
closed (data) {
console.log(data)
},
change (status) {
console.log(status);
}
}
}

View file

@ -1,6 +1,6 @@
{
"name": "iview",
"version": "0.0.13",
"version": "0.0.14",
"title": "iView",
"description": "A high quality UI components Library with Vue.js",
"homepage": "http://www.iviewui.com",

View file

@ -10,4 +10,5 @@
@import "message";
@import "notice";
@import "radio";
@import "checkbox";
@import "checkbox";
@import "switch";

View file

@ -0,0 +1,104 @@
@switch-prefix-cls: ~"@{css-prefix}switch";
.@{switch-prefix-cls} {
display: inline-block;
width: 44px;
height: 24px;
line-height: 22px;
border-radius: 22px;
vertical-align: middle;
border: 1px solid #ccc;
background-color: #ccc;
position: relative;
cursor: pointer;
user-select: none;
.transition(all @transition-time @ease-in-out);
&-inner {
color: #fff;
font-size: 12px;
position: absolute;
left: 24px;
}
&:after {
content: '';
width: 22px;
height: 22px;
border-radius: 50%;
background-color: #fff;
position: absolute;
left: 0;
top: 0;
cursor: pointer;
.transition2(left @transition-time @ease-in-out, width @transition-time @ease-in-out);
}
&:active:after {
width: 26px;
}
&:focus {
box-shadow: 0 0 0 2px fade(@primary-color, 20%);
outline: 0;
}
&:focus:hover {
box-shadow: none;
}
&-small {
height: 14px;
line-height: 12px;
width: 28px;
&:after {
width: 12px;
height: 12px;
top: 0;
left: 0;
}
&:active:after {
width: 16px;
}
}
&-small&-checked:after {
left: 14px;
}
&-small:active&-checked:after {
left: 10px;
}
&-checked {
border-color: @primary-color;
background-color: @primary-color;
.@{switch-prefix-cls}-inner {
left: 6px;
}
&:after {
left: 20px;
}
&:active:after {
left: 16px;
}
}
&-disabled {
cursor: @cursor-disabled;
background: #f3f3f3;
border-color: #f3f3f3;
&:after {
background: #ccc;
cursor: not-allowed;
}
.@{switch-prefix-cls}-inner {
color: #ccc;
}
}
}

View file

@ -84,7 +84,7 @@
border-top: 0;
border-left: 0;
.transform(rotate(45deg) scale(1));
.transition(all @transition-time @ease-in-out .1s);
.transition(all @transition-time @ease-in-out);
}
}
}
@ -145,8 +145,8 @@
.@{checkbox-prefix-cls}-wrapper + span,
.@{checkbox-prefix-cls} + span {
margin-left: 8px;
margin-right: 8px;
margin-left: 4px;
margin-right: 4px;
}
.@{checkbox-prefix-cls}-group {