diff --git a/.changeset/neat-games-rescue.md b/.changeset/neat-games-rescue.md new file mode 100644 index 0000000..158a978 --- /dev/null +++ b/.changeset/neat-games-rescue.md @@ -0,0 +1,5 @@ +--- +'studytimer.io': minor +--- + +Add audio alerts for timer events and settings customization. diff --git a/src/app.js b/src/app.js index 43c9247..d5ae5ca 100644 --- a/src/app.js +++ b/src/app.js @@ -2,23 +2,30 @@ import { Router } from '@lit-labs/router'; import { LitElement, css, html, nothing } from 'lit'; import { notificationApiService } from './services/notification-api.service.js'; +import { webAudioApiService } from './services/web-audio-api.service.js'; import { buttonStyles } from './shared/styles/buttonStyles.js'; import { captionTextStyles } from './shared/styles/captionTextStyles.js'; import { linkStyles } from './shared/styles/linkStyles.js'; import { modalStyles } from './shared/styles/modalStyles.js'; +import { tooltipStyles } from './shared/styles/tooltipStyles.js'; import { appStore } from './stores/app.js'; import { DEFAULT_SETTINGS, settingsStore } from './stores/settings.js'; import { + AUDIO_SOUND, + AUDIO_VOLUME, CLIENT_ERROR_MESSAGE, NOTIFICATION_PERMISSION, SETTINGS_EVENT, STORAGE_KEY_NAMESPACE, } from './utils/constants.js'; -import { isBool, isNum } from './utils/helpers.js'; +import { isBool, isNum, toSentenceCase } from './utils/helpers.js'; import './components/app-top-bar.js'; import './components/header.js'; +const AUDIO_SOUNDS = Object.freeze(Object.values(AUDIO_SOUND)); +const AUDIO_VOLUMES = Object.freeze(Object.values(AUDIO_VOLUME)); + const POMODORO_RESOURCE_LINKS = Object.freeze({ WIKI: 'https://en.wikipedia.org/wiki/Pomodoro_Technique', VIDEO: 'https://youtu.be/dC4ZYCiRF_w?si=ekRqmmWpnqrAZM-c&t=8', @@ -85,6 +92,11 @@ export class App extends LitElement { connectedCallback() { super.connectedCallback(); + window.addEventListener('click', this.#initAudio, { once: true }); + window.addEventListener('pointerup', this.#initAudio, { + once: true, + }); + window.addEventListener('keydown', this.#initAudio, { once: true }); this._settingsFormValues = { ...settingsStore.settings }; } @@ -257,6 +269,8 @@ export class App extends LitElement { pomodoroMinutes, shortBreakMinutes, longBreakMinutes, + audioSound, + audioVolume, } = this._settingsFormValues; return html`