From d2f1c0a3c31d0474424402dee14426a74fe8a3d4 Mon Sep 17 00:00:00 2001 From: yutent Date: Tue, 21 Nov 2023 12:16:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96star=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/form/star.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/form/star.js b/src/form/star.js index a950f54..b41d62f 100644 --- a/src/form/star.js +++ b/src/form/star.js @@ -9,7 +9,7 @@ import '../icon/index.js' class Star extends Component { static props = { - value: 0, + value: 'num!0', text: [], allowHalf: false, showValue: false, @@ -23,9 +23,10 @@ class Star extends Component { display: flex; font-size: 14px; cursor: pointer; + -webkit-user-select: none; user-select: none; } - label { + main { display: flex; align-items: center; line-height: 1; @@ -44,7 +45,7 @@ class Star extends Component { &:nth-child(#{$i}) { &[name='star-full'], &[name='star-half'] { - color: var(--star-active-#{$i}, var(--color-teal-1)); + color: var(--wc-star-active-#{$i}, var(--color-teal-1)); } } } @@ -82,6 +83,13 @@ class Star extends Component { font-size: map.get($v, 'f'); } } + `, + // 状态 + css` + :host([disabled]) { + cursor: not-allowed; + opacity: 0.6; + } ` ] @@ -134,7 +142,7 @@ class Star extends Component { this.#value = { i, f } } - handleMove(ev) { + #handleMove(ev) { if (this.disabled) { return } @@ -145,14 +153,14 @@ class Star extends Component { } } - handleLeave() { + #handleLeave() { if (this.disabled) { return } this.#updateDraw(-1) } - handleClick(ev) { + #handleClick(ev) { let tmp = this.#value if (this.disabled) { return @@ -184,11 +192,11 @@ class Star extends Component { val = val || '' } return html` - + ` } }