This commit is contained in:
alvis
2020-07-16 14:12:31 +08:00
parent 1c159a7bad
commit f746aef851
2140 changed files with 7218 additions and 4689 deletions

View File

@@ -0,0 +1,56 @@
const prefixCls = 'i-radio';
Component({
externalClasses: ['i-class'],
relations: {
'../radio-group/index': {
type: 'parent'
}
},
properties: {
value: {
type: String,
value: ''
},
checked: {
type: Boolean,
value: false
},
disabled: {
type: Boolean,
value: false
},
color: {
type: String,
value: '#2d8cf0'
},
position: {
type: String,
value: 'left', //left right
observer: 'setPosition'
}
},
data: {
checked: true,
positionCls: `${prefixCls}-radio-left`,
},
attached() {
this.setPosition();
},
methods: {
changeCurrent(current) {
this.setData({ checked: current });
},
radioChange() {
if (this.data.disabled) return;
const item = { current: !this.data.checked, value: this.data.value };
const parent = this.getRelationNodes('../radio-group/index')[0];
parent ? parent.emitEvent(item) : this.triggerEvent('change', item);
},
setPosition() {
this.setData({
positionCls: this.data.position.indexOf('left') !== -1 ? `${prefixCls}-radio-left` : `${prefixCls}-radio-right`,
});
}
}
});

View File

@@ -0,0 +1,7 @@
{
"component": true,
"usingComponents":
{
"i-cell": "../cell/index"
}
}

View File

@@ -0,0 +1,8 @@
<view class="i-class i-radio" catchtap="radioChange">
<i-cell i-class="i-radio-cell">
<label>
<radio value="{{value}}" checked="{{checked}}" color="{{checked?color:''}}" disabled="{{disabled}}" class="i-radio-radio {{positionCls}}" />
<view class="i-radio-title">{{value}}</view>
</label>
</i-cell>
</view>

View File

@@ -0,0 +1 @@
.i-radio-cell::after{display:block}.i-radio-radio-left{float:left}.i-radio-radio-right{float:right}.i-radio-radio{vertical-align:middle}.i-radio-title{display:inline-block;vertical-align:middle}