Set sleep timer button color to primary when active
This commit is contained in:
parent
d74eca943c
commit
44acd814cc
1 changed files with 32 additions and 23 deletions
29
js/player.js
29
js/player.js
|
|
@ -574,35 +574,44 @@ export class Player {
|
||||||
|
|
||||||
updateSleepTimerUI() {
|
updateSleepTimerUI() {
|
||||||
const timerBtn = document.getElementById('sleep-timer-btn');
|
const timerBtn = document.getElementById('sleep-timer-btn');
|
||||||
if (!timerBtn) return;
|
const timerBtnDesktop = document.getElementById('sleep-timer-btn-desktop');
|
||||||
|
|
||||||
|
const updateBtn = (btn) => {
|
||||||
|
if (!btn) return;
|
||||||
if (this.isSleepTimerActive()) {
|
if (this.isSleepTimerActive()) {
|
||||||
const remaining = this.getSleepTimerRemaining();
|
const remaining = this.getSleepTimerRemaining();
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
const minutes = Math.floor(remaining / 60);
|
const minutes = Math.floor(remaining / 60);
|
||||||
const seconds = remaining % 60;
|
const seconds = remaining % 60;
|
||||||
timerBtn.innerHTML = `<span style="font-size: 12px; font-weight: bold;">${minutes}:${seconds.toString().padStart(2, '0')}</span>`;
|
btn.innerHTML = `<span style="font-size: 12px; font-weight: bold;">${minutes}:${seconds.toString().padStart(2, '0')}</span>`;
|
||||||
timerBtn.title = `Sleep Timer: ${minutes}:${seconds.toString().padStart(2, '0')} remaining`;
|
btn.title = `Sleep Timer: ${minutes}:${seconds.toString().padStart(2, '0')} remaining`;
|
||||||
timerBtn.classList.add('active');
|
btn.classList.add('active');
|
||||||
|
btn.style.color = 'var(--primary)';
|
||||||
} else {
|
} else {
|
||||||
timerBtn.innerHTML = `
|
btn.innerHTML = `
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
<circle cx="12" cy="12" r="10"/>
|
<circle cx="12" cy="12" r="10"/>
|
||||||
<polyline points="12,6 12,12 16,14"/>
|
<polyline points="12,6 12,12 16,14"/>
|
||||||
</svg>
|
</svg>
|
||||||
`;
|
`;
|
||||||
timerBtn.title = 'Sleep Timer';
|
btn.title = 'Sleep Timer';
|
||||||
timerBtn.classList.remove('active');
|
btn.classList.remove('active');
|
||||||
|
btn.style.color = '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
timerBtn.innerHTML = `
|
btn.innerHTML = `
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
<circle cx="12" cy="12" r="10"/>
|
<circle cx="12" cy="12" r="10"/>
|
||||||
<polyline points="12,6 12,12 16,14"/>
|
<polyline points="12,6 12,12 16,14"/>
|
||||||
</svg>
|
</svg>
|
||||||
`;
|
`;
|
||||||
timerBtn.title = 'Sleep Timer';
|
btn.title = 'Sleep Timer';
|
||||||
timerBtn.classList.remove('active');
|
btn.classList.remove('active');
|
||||||
|
btn.style.color = '';
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateBtn(timerBtn);
|
||||||
|
updateBtn(timerBtnDesktop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue