[improvement] Radio: add checked-color prop (#2129)

This commit is contained in:
neverland
2018-11-23 20:13:40 +08:00
committed by GitHub
parent 56231d90bc
commit ec159b5e47
7 changed files with 62 additions and 8 deletions
+19 -2
View File
@@ -5,13 +5,16 @@
>
<span :class="b('input')">
<input
:value="name"
v-model="currentValue"
type="radio"
:value="name"
:class="b('control')"
:disabled="isDisabled"
>
<icon :name="currentValue === name ? 'checked' : 'check'" />
<icon
:style="iconStyle"
:name="checked ? 'checked' : 'check'"
/>
</span>
<span
v-if="$slots.default"
@@ -36,6 +39,7 @@ export default create({
name: null,
value: null,
disabled: Boolean,
checkedColor: String,
labelDisabled: Boolean,
labelPosition: Boolean
},
@@ -51,10 +55,23 @@ export default create({
}
},
checked() {
return this.currentValue === this.name;
},
isDisabled() {
return this.parent
? this.parent.disabled || this.disabled
: this.disabled;
},
iconStyle() {
const { checkedColor } = this;
if (checkedColor && this.checked && !this.isDisabled) {
return {
color: checkedColor
};
}
}
},