Add listening circle animation to speak button in Obsidian plugin

Use icon active focus as color of animation button
This commit is contained in:
Debanjum Singh Solanky 2024-07-05 14:00:53 +05:30
parent 516af86575
commit 6d59ad7fc9
2 changed files with 27 additions and 0 deletions

View file

@ -1014,6 +1014,7 @@ export class KhojChatView extends KhojPaneView {
// Start the countdown timer UI // Start the countdown timer UI
stopSendButtonImg.getElementsByTagName("circle")[0].style.animation = "countdown 3s linear 1 forwards"; stopSendButtonImg.getElementsByTagName("circle")[0].style.animation = "countdown 3s linear 1 forwards";
stopSendButtonImg.getElementsByTagName("circle")[0].style.color = "var(--icon-color-active)";
// Auto send message after 3 seconds // Auto send message after 3 seconds
this.sendMessageTimeout = setTimeout(() => { this.sendMessageTimeout = setTimeout(() => {
@ -1043,6 +1044,7 @@ export class KhojChatView extends KhojPaneView {
this.mediaRecorder.start(); this.mediaRecorder.start();
setIcon(transcribeButton, "mic-off"); setIcon(transcribeButton, "mic-off");
transcribeButton.classList.add("loading-encircle")
}; };
// Toggle recording // Toggle recording
@ -1057,6 +1059,7 @@ export class KhojChatView extends KhojPaneView {
this.mediaRecorder.stop(); this.mediaRecorder.stop();
this.mediaRecorder.stream.getTracks().forEach(track => track.stop()); this.mediaRecorder.stream.getTracks().forEach(track => track.stop());
this.mediaRecorder = undefined; this.mediaRecorder = undefined;
transcribeButton.classList.remove("loading-encircle");
setIcon(transcribeButton, "mic"); setIcon(transcribeButton, "mic");
} }
} }

View file

@ -598,6 +598,30 @@ img.copy-icon {
} }
} }
/* Loading Encircle */
.loading-encircle {
position: relative;
}
.loading-encircle::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 24px;
height: 24px;
margin-top: -16px;
margin-left: -16px;
border: 4px solid transparent;
border-top-color: var(--icon-color-active);
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@media only screen and (max-width: 600px) { @media only screen and (max-width: 600px) {
div.khoj-header { div.khoj-header {
display: grid; display: grid;