From 545661ed6015291a9fe3a6dcad3b9705b47206ac Mon Sep 17 00:00:00 2001 From: yutent Date: Fri, 24 Nov 2023 14:52:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=A4=B4=E5=83=8F=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E7=AE=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/avatar/index.js | 56 ++++++++++++++------------------------------- src/index.js | 1 + 2 files changed, 18 insertions(+), 39 deletions(-) diff --git a/src/avatar/index.js b/src/avatar/index.js index 9b4c94a..f9d373e 100644 --- a/src/avatar/index.js +++ b/src/avatar/index.js @@ -1,9 +1,9 @@ /** - * {} + * {头像组件} * @author yutent * @date 2023/04/25 09:27:25 */ -import { html, raw, css, Component, nextTick } from 'wkit' +import { html, css, Component } from 'wkit' import '../icon/index.js' class Avatar extends Component { @@ -20,7 +20,9 @@ class Avatar extends Component { display: inline-flex; width: 32px; height: 32px; - border-radius: 4px; + --wc-icon-size: 22px; + font-size: 14px; + border-radius: 3px; } .avatar { @@ -29,11 +31,12 @@ class Avatar extends Component { justify-content: center; width: 100%; height: 100%; - padding: 2px; + padding: 4px; border-radius: inherit; text-align: center; - background: var(--color-grey-3); + background: var(--wc-avatar-color, var(--color-grey-3)); color: #fff; + -webkit-user-select: none; user-select: none; img { @@ -49,43 +52,18 @@ class Avatar extends Component { padding: 0; } } - :host([round]) { + + :host([circle]) { border-radius: 50%; } `, // 尺寸 css` - @use 'sass:map'; - $sizes: ( - s: ( - h: 20px, - f: 12px - ), - m: ( - h: 24px, - f: 12px - ), - l: ( - h: 32px, - f: 14px - ), - xl: ( - h: 36px, - f: 14px - ), - xxl: ( - h: 44px, - f: 14px - ) - ); - - @loop $s, $v in $sizes { - :host([size='#{$s}']) { - width: map.get($v, 'h'); - height: map.get($v, 'h'); - font-size: map.get($v, 'f'); - --wc-icon-size: #{map.get($v, 'h') - 8px}; - } + :host([size='small']) { + width: 24px; + height: 24px; + font-size: 12px; + --wc-icon-size: 14px; } ` ] @@ -98,11 +76,11 @@ class Avatar extends Component { render() { return html` -
+
${this.src ? html`` : html``} -
+ ` } } diff --git a/src/index.js b/src/index.js index f8c7ff4..527984c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,4 @@ +import './avatar/index.js' import './badge/index.js' import './breadcrumb/index.js' import './card/index.js'