This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

优化样式及事件触发

old
yutent 2023-02-27 19:19:13 +08:00
parent 94e38eb83f
commit c8f99088ff
5 changed files with 14 additions and 7 deletions

View File

@ -229,7 +229,7 @@ export default class Radio {
this.checked = true
this.parentNode.dispatchEvent(new CustomEvent('child-picked', { detail: this.value }))
$.fire(this.parentNode, 'child-picked', { value: this.value })
}
mounted() {

View File

@ -100,7 +100,8 @@ export default class RadioGroup {
mounted() {
this._pickedFn = $.bind(this, 'child-picked', ev => {
this.value = ev.detail
this.dispatchEvent(new CustomEvent('input'))
$.fire(this, 'input')
$.fire(this, 'change')
})
this.__observer = new MutationObserver(_ => {

View File

@ -193,7 +193,8 @@ export default class Star {
}
if (ev.target.tagName === 'WC-ICON') {
this.props.value = tmp.i + tmp.f
this.dispatchEvent(new CustomEvent('input'))
$.fire(this, 'input', { value: this.value })
$.fire(this, 'change', { value: this.value })
}
})

View File

@ -3,7 +3,7 @@
<label>
<span class="dot"></span>
</label>
<slot></slot>
<slot />
</section>
</template>
@ -11,13 +11,15 @@
:host {
display: inline-flex;
align-items: center;
height: 32px;
color: var(--color-dark-1);
section {
display: flex;
justify-content: center;
align-items: center;
line-height: 1;
white-space: nowrap;
user-select: none;
}
label {
display: flex;
@ -28,6 +30,7 @@
margin: 5px;
border-radius: 21px;
background: var(--color-plain-3);
transition: background 0.2s linear;
cursor: inherit;
&.checked {
@ -182,7 +185,8 @@ export default class Switch {
this.checked = !this.checked
this._updateStat()
this.dispatchEvent(new CustomEvent('input'))
$.fire(this, 'input')
$.fire(this, 'change')
})
}

View File

@ -234,7 +234,7 @@ export default class Textarea {
}
this.stamp = now
this.dispatchEvent(new CustomEvent('submit', { detail: this.value }))
$.fire(this, 'submit', { value: this.value })
}
})
@ -244,6 +244,7 @@ export default class Textarea {
maxlength = maxlength || '∞'
this.__STAT__.textContent = `${len}/${maxlength}`
$.fire(this, ev.type, { value: this.value })
})
}