From 2bafdc42ce0010a46f1743ce51958642d10e4748 Mon Sep 17 00:00:00 2001 From: yutent Date: Sat, 6 May 2023 19:48:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Readme.md | 2 +- src/chatbubble/index.js | 81 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index 67df885..6e32594 100644 --- a/Readme.md +++ b/Readme.md @@ -16,7 +16,7 @@ - @bd/core 针对`web components`的核心封装库, 以数据驱动, 可以更方便的开发 wc 组件 -### 开发进度 && 计划 (37/54) +### 开发进度 && 计划 (37/55) - [x] `wc-card` 卡片组件 - [x] `wc-space` 间隔组件 diff --git a/src/chatbubble/index.js b/src/chatbubble/index.js index 2b2c289..873803e 100644 --- a/src/chatbubble/index.js +++ b/src/chatbubble/index.js @@ -3,7 +3,7 @@ * @author yutent * @date 2023/05/05 14:56:34 */ -import { css, html, Component } from '@bd/core' +import { css, html, Component, classMap } from '@bd/core' import '../avatar/index.js' @@ -11,7 +11,9 @@ class Bubble extends Component { static props = { type: 'text', content: '', - avatar: '' + voiceLength: 0, + avatar: '', + readOnly: true } static styles = [ @@ -82,9 +84,74 @@ class Bubble extends Component { object-fit: contain; -webkit-user-drag: none; } + + .type-voice { + display: flex; + align-items: center; + + .wave { + position: relative; + display: flex; + align-items: center; + width: 52rpx; + height: 44rpx; + + .i { + position: absolute; + width: 8rpx; + height: 8rpx; + border: 4rpx solid transparent; + border-right-color: rgba(0, 0, 0, 0.2); + border-radius: 50%; + + &:nth-child(1) { + border: 0; + background: rgba(0, 0, 0, 0.2); + } + &:nth-child(2) { + left: -8rpx; + width: 24rpx; + height: 24rpx; + } + &:nth-child(3) { + left: -12rpx; + width: 36rpx; + height: 36rpx; + } + &:nth-child(4) { + left: -16rpx; + width: 48rpx; + height: 48rpx; + } + } + &.on .i { + border-right-color: rgba(0, 0, 0, 0); + animation: play 1.2s infinite; + + &:nth-child(3) { + animation-delay: 0.3s; + } + &:nth-child(4) { + animation-delay: 0.6s; + } + } + } + } + + @keyframes play { + from, + to { + border-right-color: rgba(0, 0, 0, 0); + } + 50% { + border-right-color: rgba(0, 0, 0, 0.2); + } + } ` ] + #playing = false + #drawContent() { switch (this.type) { case 'text': @@ -94,7 +161,15 @@ class Bubble extends Component { return html`` case 'voice': - return html`` + return html`
+
+ + + + +
+ ${this.voiceLength}' +
` case 'media': return html``