Checkbox add size prop
This commit is contained in:
parent
3485243a4d
commit
77f1cc2e34
5 changed files with 99 additions and 7 deletions
|
@ -1,14 +1,28 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<Checkbox
|
||||||
|
:indeterminate="true"
|
||||||
|
:value="false"
|
||||||
|
size="large">全选</Checkbox>
|
||||||
|
<Checkbox
|
||||||
|
:indeterminate="true"
|
||||||
|
:value="false"
|
||||||
|
size="default">全选</Checkbox>
|
||||||
|
<Checkbox
|
||||||
|
:indeterminate="true"
|
||||||
|
:value="false"
|
||||||
|
size="small">全选</Checkbox>
|
||||||
<div>
|
<div>
|
||||||
<Checkbox true-value="true" false-value="false" v-model="testValue1">test string</Checkbox>
|
<Checkbox size="large" true-value="true" false-value="false" v-model="testValue1">Apple</Checkbox>
|
||||||
|
<Checkbox true-value="true" false-value="false" v-model="testValue1">Apple</Checkbox>
|
||||||
|
<Checkbox size="small" true-value="true" false-value="false" v-model="testValue1">Apple</Checkbox>
|
||||||
{{ testValue1 }}
|
{{ testValue1 }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Checkbox :true-value="0" :false-value="1" v-model="testValue2">test number</Checkbox>
|
<Checkbox :true-value="0" :false-value="1" v-model="testValue2">test number</Checkbox>
|
||||||
{{ testValue2 }}
|
{{ testValue2 }}
|
||||||
</div>
|
</div>
|
||||||
<Checkbox-group v-model="fruit">
|
<Checkbox-group v-model="fruit" size="large">
|
||||||
<Checkbox v-for="item in tags" :label="item.label" :key="item.label" true-value="true"></Checkbox>
|
<Checkbox v-for="item in tags" :label="item.label" :key="item.label" true-value="true"></Checkbox>
|
||||||
</Checkbox-group>
|
</Checkbox-group>
|
||||||
<div>{{ fruit }}</div>
|
<div>{{ fruit }}</div>
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
validator (value) {
|
validator (value) {
|
||||||
return oneOf(value, ['small', 'large']);
|
return oneOf(value, ['small', 'large', 'default']);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loading: Boolean,
|
loading: Boolean,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { findComponentsDownward } from '../../utils/assist';
|
import { findComponentsDownward, oneOf } from '../../utils/assist';
|
||||||
import Emitter from '../../mixins/emitter';
|
import Emitter from '../../mixins/emitter';
|
||||||
const prefixCls = 'ivu-checkbox-group';
|
const prefixCls = 'ivu-checkbox-group';
|
||||||
|
|
||||||
|
@ -17,6 +17,11 @@
|
||||||
default () {
|
default () {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
validator (value) {
|
||||||
|
return oneOf(value, ['small', 'large', 'default']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -27,7 +32,12 @@
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
classes () {
|
classes () {
|
||||||
return `${prefixCls}`;
|
return [
|
||||||
|
`${prefixCls}`,
|
||||||
|
{
|
||||||
|
[`ivu-checkbox-${this.size}`]: !!this.size
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
</label>
|
</label>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { findComponentUpward } from '../../utils/assist';
|
import { findComponentUpward, oneOf } from '../../utils/assist';
|
||||||
import Emitter from '../../mixins/emitter';
|
import Emitter from '../../mixins/emitter';
|
||||||
|
|
||||||
const prefixCls = 'ivu-checkbox';
|
const prefixCls = 'ivu-checkbox';
|
||||||
|
@ -53,6 +53,11 @@
|
||||||
indeterminate: {
|
indeterminate: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
validator (value) {
|
||||||
|
return oneOf(value, ['small', 'large', 'default']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -71,7 +76,8 @@
|
||||||
{
|
{
|
||||||
[`${prefixCls}-group-item`]: this.group,
|
[`${prefixCls}-group-item`]: this.group,
|
||||||
[`${prefixCls}-wrapper-checked`]: this.currentValue,
|
[`${prefixCls}-wrapper-checked`]: this.currentValue,
|
||||||
[`${prefixCls}-wrapper-disabled`]: this.disabled
|
[`${prefixCls}-wrapper-disabled`]: this.disabled,
|
||||||
|
[`${prefixCls}-${this.size}`]: !!this.size
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
|
@ -48,6 +48,28 @@
|
||||||
transition: all @transition-time @ease-in-out;
|
transition: all @transition-time @ease-in-out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&-large{
|
||||||
|
font-size: 16px;
|
||||||
|
& .@{checkbox-inner-prefix-cls} {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
&:after{
|
||||||
|
width: 5px;
|
||||||
|
height: 9px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-small{
|
||||||
|
font-size: 12px;
|
||||||
|
& .@{checkbox-inner-prefix-cls} {
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
&:after{
|
||||||
|
top: 0;
|
||||||
|
left: 3px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&-input {
|
&-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -96,6 +118,26 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.@{checkbox-prefix-cls}-large{
|
||||||
|
.@{checkbox-prefix-cls}-checked{
|
||||||
|
.@{checkbox-inner-prefix-cls} {
|
||||||
|
&:after{
|
||||||
|
width: 5px;
|
||||||
|
height: 9px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.@{checkbox-prefix-cls}-small{
|
||||||
|
.@{checkbox-prefix-cls}-checked{
|
||||||
|
.@{checkbox-inner-prefix-cls} {
|
||||||
|
&:after{
|
||||||
|
top: 0;
|
||||||
|
left: 3px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 禁用
|
// 禁用
|
||||||
.@{checkbox-prefix-cls}-disabled {
|
.@{checkbox-prefix-cls}-disabled {
|
||||||
|
@ -164,6 +206,22 @@
|
||||||
border-color: @primary-color;
|
border-color: @primary-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.@{checkbox-prefix-cls}-large {
|
||||||
|
.@{checkbox-prefix-cls}-indeterminate{
|
||||||
|
.@{checkbox-inner-prefix-cls}:after{
|
||||||
|
width: 10px;
|
||||||
|
top: 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.@{checkbox-prefix-cls}-small {
|
||||||
|
.@{checkbox-prefix-cls}-indeterminate{
|
||||||
|
.@{checkbox-inner-prefix-cls}:after{
|
||||||
|
width: 6px;
|
||||||
|
top: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.@{checkbox-prefix-cls}-wrapper {
|
.@{checkbox-prefix-cls}-wrapper {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -173,6 +231,10 @@
|
||||||
&-disabled{
|
&-disabled{
|
||||||
cursor: @cursor-disabled;
|
cursor: @cursor-disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.@{checkbox-prefix-cls}-large{
|
||||||
|
font-size: @font-size-base;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.@{checkbox-prefix-cls}-wrapper + span,
|
.@{checkbox-prefix-cls}-wrapper + span,
|
||||||
|
|
Loading…
Add table
Reference in a new issue