Skip to content

Commit

Permalink
voice msg style optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
DWHengr committed Jul 31, 2024
1 parent 023a593 commit e654b74
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
8 changes: 6 additions & 2 deletions src/componets/CommonChatFrame/ChatContent/Voice/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ const Voice = memo(({value, right = false}) => {
<div className={"chat-content-voice"}>
<div className={`content ${right ? "right" : ""}`}>
{info &&
<CustomAudio key={retryNum} audioUrl={info} time={audioTime}
onLoadedMetadata={() => clearInterval(interval.current)}
<CustomAudio
type={right ? "" : "minor"}
key={retryNum}
audioUrl={info}
time={audioTime}
onLoadedMetadata={() => clearInterval(interval.current)}
/>
}
</div>
Expand Down
13 changes: 6 additions & 7 deletions src/componets/CustomAudio/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./index.less"
import CustomSoundIcon from "../CustomSoundIcon/index.jsx";
import React, {useRef, useState} from "react";

export default function CustomAudio({audioUrl, time, onLoadedMetadata}) {
export default function CustomAudio({audioUrl, time, onLoadedMetadata, type = ""}) {
const [audioTime, setAudioTime] = useState(time)
const audioRef = useRef(null)
const [isPlay, setIsPlay] = useState(false)
Expand All @@ -22,10 +22,10 @@ export default function CustomAudio({audioUrl, time, onLoadedMetadata}) {
}
};

return (
<div>
<div onClick={playAudio} className="custom-audio">
<CustomSoundIcon isStart={isPlay} style={{color: "#fff", marginLeft: 10}}/>
return (<div>
<div onClick={playAudio} className={`custom-audio ${type}`}>
<CustomSoundIcon isStart={isPlay} style={{marginLeft: 10}}
barStyle={{backgroundColor: type === "" ? "#fff" : "#1f1f1f"}}/>
<div style={{marginLeft: 10}}>{audioTime}"</div>
<audio
ref={audioRef}
Expand All @@ -38,6 +38,5 @@ export default function CustomAudio({audioUrl, time, onLoadedMetadata}) {
src={audioUrl} controls style={{display: "none"}}
/>
</div>
</div>
)
</div>)
}
5 changes: 5 additions & 0 deletions src/componets/CustomAudio/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
display: flex;
align-items: center;
cursor: pointer;

&.minor {
background-color: #FFFFFF;
color: #1F1F1F;
}
}
12 changes: 6 additions & 6 deletions src/componets/CustomSoundIcon/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import './index.less';

const CustomSoundIcon = ({isStart, style = {}}) => {
const CustomSoundIcon = ({isStart, style = {}, barStyle = {}}) => {
return (
<div className={`sound-icon ${isStart ? 'start' : ''}`} style={style}>
<div className="bar bar1"></div>
<div className="bar bar2"></div>
<div className="bar bar3"></div>
<div className="bar bar4"></div>
<div className="bar bar5"></div>
<div className="bar bar1" style={barStyle}></div>
<div className="bar bar2" style={barStyle}></div>
<div className="bar bar3" style={barStyle}></div>
<div className="bar bar4" style={barStyle}></div>
<div className="bar bar5" style={barStyle}></div>
</div>
);
};
Expand Down

0 comments on commit e654b74

Please sign in to comment.