add Switch UI
add Switch UI
This commit is contained in:
parent
6c5fbd8b04
commit
07aa688e3c
8 changed files with 133 additions and 10 deletions
|
@ -18,7 +18,7 @@
|
|||
v-model="checked"
|
||||
@change="change">
|
||||
</span>
|
||||
<slot>{{ value }}</slot>
|
||||
<slot><span>{{ value }}</span></slot>
|
||||
</label>
|
||||
</template>
|
||||
<script>
|
||||
|
|
2
dist/styles/iview.all.css
vendored
2
dist/styles/iview.all.css
vendored
File diff suppressed because one or more lines are too long
2
dist/styles/iview.css
vendored
2
dist/styles/iview.css
vendored
File diff suppressed because one or more lines are too long
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -10,4 +10,5 @@
|
|||
@import "message";
|
||||
@import "notice";
|
||||
@import "radio";
|
||||
@import "checkbox";
|
||||
@import "checkbox";
|
||||
@import "switch";
|
104
styles/components/switch.less
Normal file
104
styles/components/switch.less
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue