diff --git a/components.d.ts b/components.d.ts index b65d4a36..7a387b8c 100644 --- a/components.d.ts +++ b/components.d.ts @@ -12,10 +12,12 @@ declare module '@vue/runtime-core' { '404.page': typeof import('./src/pages/404.page.vue')['default'] About: typeof import('./src/pages/About.vue')['default'] AiPromptSplitter: typeof import('./src/tools/ai-prompt-splitter/ai-prompt-splitter.vue')['default'] + AlarmSoundToggle: typeof import('./src/tools/pomodoro-timer/app/components/AlarmSoundToggle.vue')['default'] AngleConverter: typeof import('./src/tools/angle-converter/angle-converter.vue')['default'] AnsibleVaultCryptDecrypt: typeof import('./src/tools/ansible-vault-crypt-decrypt/ansible-vault-crypt-decrypt.vue')['default'] ApiTester: typeof import('./src/tools/api-tester/api-tester.vue')['default'] App: typeof import('./src/App.vue')['default'] + AppColorPicker: typeof import('./src/tools/pomodoro-timer/app/components/AppColorPicker.vue')['default'] AreaConverter: typeof import('./src/tools/area-converter/area-converter.vue')['default'] AsciiTextDrawer: typeof import('./src/tools/ascii-text-drawer/ascii-text-drawer.vue')['default'] AspectRatioCalculator: typeof import('./src/tools/aspect-ratio-calculator/aspect-ratio-calculator.vue')['default'] @@ -74,6 +76,7 @@ declare module '@vue/runtime-core' { CommandPaletteOption: typeof import('./src/modules/command-palette/components/command-palette-option.vue')['default'] CommonRegex: typeof import('./src/tools/common-regex-memo/common-regex.md')['default'] CommonRegexMemo: typeof import('./src/tools/common-regex-memo/common-regex-memo.vue')['default'] + Counter: typeof import('./src/tools/pomodoro-timer/app/components/Counter.vue')['default'] CrcCalculator: typeof import('./src/tools/crc-calculator/crc-calculator.vue')['default'] CrontabGenerator: typeof import('./src/tools/crontab-generator/crontab-generator.vue')['default'] CSelect: typeof import('./src/ui/c-select/c-select.vue')['default'] @@ -126,8 +129,10 @@ declare module '@vue/runtime-core' { FavoriteButton: typeof import('./src/components/FavoriteButton.vue')['default'] FileHasher: typeof import('./src/tools/file-hasher/file-hasher.vue')['default'] FileType: typeof import('./src/tools/file-type/file-type.vue')['default'] + FinishedPopup: typeof import('./src/tools/pomodoro-timer/app/components/FinishedPopup.vue')['default'] FloatingPointNumberConverter: typeof import('./src/tools/floating-point-number-converter/floating-point-number-converter.vue')['default'] FolderStructureDiagram: typeof import('./src/tools/folder-structure-diagram/folder-structure-diagram.vue')['default'] + Footer: typeof import('./src/tools/pomodoro-timer/app/components/Footer.vue')['default'] ForceConverter: typeof import('./src/tools/force-converter/force-converter.vue')['default'] FormatTransformer: typeof import('./src/components/FormatTransformer.vue')['default'] FortuneWheel: typeof import('./src/tools/fortune-wheel/fortune-wheel.vue')['default'] @@ -139,10 +144,12 @@ declare module '@vue/runtime-core' { HarSanitizer: typeof import('./src/tools/har-sanitizer/har-sanitizer.vue')['default'] HashText: typeof import('./src/tools/hash-text/hash-text.vue')['default'] HddCalculator: typeof import('./src/tools/hdd-calculator/hdd-calculator.vue')['default'] + Header: typeof import('./src/tools/pomodoro-timer/app/components/Header.vue')['default'] HeicConverter: typeof import('./src/tools/heic-converter/heic-converter.vue')['default'] HexConverter: typeof import('./src/tools/hex-converter/hex-converter.vue')['default'] HexFileConverter: typeof import('./src/tools/hex-file-converter/hex-file-converter.vue')['default'] HmacGenerator: typeof import('./src/tools/hmac-generator/hmac-generator.vue')['default'] + Home: typeof import('./src/tools/pomodoro-timer/app/views/Home.vue')['default'] 'Home.page': typeof import('./src/pages/Home.page.vue')['default'] HtmlCleaner: typeof import('./src/tools/html-cleaner/html-cleaner.vue')['default'] HtmlEntities: typeof import('./src/tools/html-entities/html-entities.vue')['default'] @@ -249,6 +256,7 @@ declare module '@vue/runtime-core' { MicTester: typeof import('./src/tools/mic-tester/mic-tester.vue')['default'] MimeConverter: typeof import('./src/tools/mime-converter/mime-converter.vue')['default'] MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default'] + ModeIconBar: typeof import('./src/tools/pomodoro-timer/app/components/ModeIconBar.vue')['default'] MongoObjectidConverter: typeof import('./src/tools/mongo-objectid-converter/mongo-objectid-converter.vue')['default'] MorseConverter: typeof import('./src/tools/morse-converter/morse-converter.vue')['default'] MultiLinkDownloader: typeof import('./src/tools/multi-link-downloader/multi-link-downloader.vue')['default'] @@ -259,6 +267,8 @@ declare module '@vue/runtime-core' { NanoMemo: typeof import('./src/tools/nano-memo/nano-memo.vue')['default'] 'NanoMemo.content': typeof import('./src/tools/nano-memo/nano-memo.content.md')['default'] NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default'] + NButton: typeof import('naive-ui')['NButton'] + NCard: typeof import('naive-ui')['NCard'] NCheckbox: typeof import('naive-ui')['NCheckbox'] NCode: typeof import('naive-ui')['NCode'] NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] @@ -283,6 +293,7 @@ declare module '@vue/runtime-core' { NLayout: typeof import('naive-ui')['NLayout'] NLayoutSider: typeof import('naive-ui')['NLayoutSider'] NMenu: typeof import('naive-ui')['NMenu'] + NModal: typeof import('naive-ui')['NModal'] NP: typeof import('naive-ui')['NP'] NRadio: typeof import('naive-ui')['NRadio'] NRadioGroup: typeof import('naive-ui')['NRadioGroup'] @@ -294,7 +305,10 @@ declare module '@vue/runtime-core' { NStatistic: typeof import('naive-ui')['NStatistic'] NSwitch: typeof import('naive-ui')['NSwitch'] NTable: typeof import('naive-ui')['NTable'] + NTabPane: typeof import('naive-ui')['NTabPane'] + NTabs: typeof import('naive-ui')['NTabs'] NText: typeof import('naive-ui')['NText'] + NumberInput: typeof import('./src/tools/pomodoro-timer/app/components/NumberInput.vue')['default'] NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default'] OcrImage: typeof import('./src/tools/ocr-image/ocr-image.vue')['default'] Option43Generator: typeof import('./src/tools/option43-generator/option43-generator.vue')['default'] @@ -315,10 +329,13 @@ declare module '@vue/runtime-core' { PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default'] PhpArrayToJson: typeof import('./src/tools/php-array-to-json/php-array-to-json.vue')['default'] PinCodeGenerator: typeof import('./src/tools/pin-code-generator/pin-code-generator.vue')['default'] + PlayPauseBtn: typeof import('./src/tools/pomodoro-timer/app/components/PlayPauseBtn.vue')['default'] + PomodoroTimer: typeof import('./src/tools/pomodoro-timer/pomodoro-timer.vue')['default'] PortNumbers: typeof import('./src/tools/port-numbers/port-numbers.vue')['default'] Potrace: typeof import('./src/tools/potrace/potrace.vue')['default'] PowerConverter: typeof import('./src/tools/power-converter/power-converter.vue')['default'] PressureConverter: typeof import('./src/tools/pressure-converter/pressure-converter.vue')['default'] + ProgressBar: typeof import('./src/tools/pomodoro-timer/app/components/ProgressBar.vue')['default'] PropertiesToYaml: typeof import('./src/tools/properties-to-yaml/properties-to-yaml.vue')['default'] PunycodeConverter: typeof import('./src/tools/punycode-converter/punycode-converter.vue')['default'] QrCodeDecoder: typeof import('./src/tools/qr-code-decoder/qr-code-decoder.vue')['default'] @@ -330,6 +347,7 @@ declare module '@vue/runtime-core' { 'RegexMemo.content': typeof import('./src/tools/regex-memo/regex-memo.content.md')['default'] RegexTester: typeof import('./src/tools/regex-tester/regex-tester.vue')['default'] RemoveExif: typeof import('./src/tools/remove-exif/remove-exif.vue')['default'] + ResetDropup: typeof import('./src/tools/pomodoro-timer/app/components/ResetDropup.vue')['default'] ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default'] RmbNumbers: typeof import('./src/tools/rmb-numbers/rmb-numbers.vue')['default'] RomanNumeralConverter: typeof import('./src/tools/roman-numeral-converter/roman-numeral-converter.vue')['default'] @@ -340,6 +358,7 @@ declare module '@vue/runtime-core' { RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default'] SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default'] SensitiveDataMasker: typeof import('./src/tools/sensitive-data-masker/sensitive-data-masker.vue')['default'] + Settings: typeof import('./src/tools/pomodoro-timer/app/views/Settings.vue')['default'] SharepointDecoder: typeof import('./src/tools/sharepoint-decoder/sharepoint-decoder.vue')['default'] SipAuth: typeof import('./src/tools/sip-auth/sip-auth.vue')['default'] SlaCalculator: typeof import('./src/tools/sla-calculator/sla-calculator.vue')['default'] @@ -349,6 +368,7 @@ declare module '@vue/runtime-core' { SnowflakeIdExtractor: typeof import('./src/tools/snowflake-id-extractor/snowflake-id-extractor.vue')['default'] SoftwareLicenceCompatibility: typeof import('./src/tools/software-licence-compatibility/software-licence-compatibility.vue')['default'] SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default'] + SplashScreen: typeof import('./src/tools/pomodoro-timer/app/views/SplashScreen.vue')['default'] SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default'] SslCertConverter: typeof import('./src/tools/ssl-cert-converter/ssl-cert-converter.vue')['default'] StacktracePrettier: typeof import('./src/tools/stacktrace-prettier/stacktrace-prettier.vue')['default'] diff --git a/package.json b/package.json index 0102fc9e..f1e20f39 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,9 @@ "release": "node ./scripts/release.mjs" }, "dependencies": { + "@fortawesome/fontawesome-svg-core": "^6.7.2", + "@fortawesome/free-solid-svg-icons": "^6.7.2", + "@fortawesome/vue-fontawesome": "^3.0.8", "@chenfengyuan/vue-barcode": "^2.0.2", "@date-fns/utc": "^1.2.0", "@dice-roller/rpg-dice-roller": "^5.5.1", @@ -259,6 +262,7 @@ "vue-shadow-dom": "^4.2.0", "vue-tsc": "^1.8.1", "vue3-fortune-wheel": "^2.0.5", + "vuex": "^4.1.0", "vuedraggable": "^4.1.0", "w-websocket-client": "^1.0.29", "wcag-contrast-utils": "^1.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f1e22d3..f2ea187e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,15 @@ dependencies: '@dice-roller/rpg-dice-roller': specifier: ^5.5.1 version: 5.5.1 + '@fortawesome/fontawesome-svg-core': + specifier: ^6.7.2 + version: 6.7.2 + '@fortawesome/free-solid-svg-icons': + specifier: ^6.7.2 + version: 6.7.2 + '@fortawesome/vue-fontawesome': + specifier: ^3.0.8 + version: 3.0.8(@fortawesome/fontawesome-svg-core@6.7.2)(vue@3.3.4) '@github/paste-markdown': specifier: ^1.5.3 version: 1.5.3 @@ -674,6 +683,9 @@ dependencies: vuedraggable: specifier: ^4.1.0 version: 4.1.0(vue@3.3.4) + vuex: + specifier: ^4.1.0 + version: 4.1.0(vue@3.3.4) w-websocket-client: specifier: ^1.0.29 version: 1.0.29 @@ -3427,6 +3439,13 @@ packages: engines: {node: '>=6'} dev: false + /@fortawesome/fontawesome-svg-core@6.7.2: + resolution: {integrity: sha512-yxtOBWDrdi5DD5o1pmVdq3WMCvnobT0LU6R8RyyVXPvFRd2o79/0NCuQoCjNTeZz9EzA9xS3JxNWfv54RIHFEA==} + engines: {node: '>=6'} + dependencies: + '@fortawesome/fontawesome-common-types': 6.7.2 + dev: false + /@fortawesome/free-regular-svg-icons@6.7.2: resolution: {integrity: sha512-7Z/ur0gvCMW8G93dXIQOkQqHo2M5HLhYrRVC0//fakJXxcF1VmMPsxnG6Ee8qEylA8b8Q3peQXWMNZ62lYF28g==} engines: {node: '>=6'} @@ -3441,6 +3460,16 @@ packages: '@fortawesome/fontawesome-common-types': 6.7.2 dev: false + /@fortawesome/vue-fontawesome@3.0.8(@fortawesome/fontawesome-svg-core@6.7.2)(vue@3.3.4): + resolution: {integrity: sha512-yyHHAj4G8pQIDfaIsMvQpwKMboIZtcHTUvPqXjOHyldh1O1vZfH4W03VDPv5RvI9P6DLTzJQlmVgj9wCf7c2Fw==} + peerDependencies: + '@fortawesome/fontawesome-svg-core': ~1 || ~6 + vue: '>= 3.0.0 < 4' + dependencies: + '@fortawesome/fontawesome-svg-core': 6.7.2 + vue: 3.3.4 + dev: false + /@github/paste-markdown@1.5.3: resolution: {integrity: sha512-PzZ1b3PaqBzYqbT4fwKEhiORf38h2OcGp2+JdXNNM7inZ7egaSmfmhyNkQILpqWfS0AYtRS3CDq6z03eZ8yOMQ==} dev: false @@ -6666,7 +6695,7 @@ packages: dependencies: '@unhead/dom': 0.5.1 '@unhead/schema': 0.5.1 - '@vueuse/shared': 13.0.0(vue@3.3.4) + '@vueuse/shared': 13.1.0(vue@3.3.4) unhead: 0.5.1 vue: 3.3.4 dev: false @@ -7338,8 +7367,8 @@ packages: - vue dev: false - /@vueuse/shared@13.0.0(vue@3.3.4): - resolution: {integrity: sha512-9MiHhAPw+sqCF/RLo8V6HsjRqEdNEWVpDLm2WBRW2G/kSQjb8X901sozXpSCaeLG0f7TEfMrT4XNaA5m1ez7Dg==} + /@vueuse/shared@13.1.0(vue@3.3.4): + resolution: {integrity: sha512-IVS/qRRjhPTZ6C2/AM3jieqXACGwFZwWTdw5sNTSKk2m/ZpkuuN+ri+WCVUP8TqaKwJYt/KuMwmXspMAw8E6ew==} peerDependencies: vue: ^3.5.0 dependencies: @@ -17982,6 +18011,15 @@ packages: vue: 3.3.4 dev: false + /vuex@4.1.0(vue@3.3.4): + resolution: {integrity: sha512-hmV6UerDrPcgbSy9ORAtNXDr9M4wlNP4pEFKye4ujJF8oqgFFuxDCdOLS3eNoRTtq5O3hoBDh9Doj1bQMYHRbQ==} + peerDependencies: + vue: ^3.2.0 + dependencies: + '@vue/devtools-api': 6.5.0 + vue: 3.3.4 + dev: false + /w-websocket-client@1.0.29: resolution: {integrity: sha512-zZg+dOo4EP3BmvpjlkpThKIgTAzCHoOFSSp6xSNY6EuywM2xDqfkiQU7Ga3QlzEMC9i8TwdXfkntRauA/D2KWA==} dependencies: diff --git a/public/Beep.mp3 b/public/Beep.mp3 new file mode 100644 index 00000000..68125b61 Binary files /dev/null and b/public/Beep.mp3 differ diff --git a/public/stopwatch.png b/public/stopwatch.png new file mode 100644 index 00000000..2d8da708 Binary files /dev/null and b/public/stopwatch.png differ diff --git a/src/main.ts b/src/main.ts index 405f740f..ab4ed2ff 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,8 @@ import { createApp } from 'vue'; import { createPinia } from 'pinia'; import { createHead } from '@vueuse/head'; +import { library } from '@fortawesome/fontawesome-svg-core'; +import { fas } from '@fortawesome/free-solid-svg-icons'; import { install as VueMonacoEditorPlugin, loader } from '@guolao/vue-monaco-editor'; import * as monaco from 'monaco-editor'; @@ -17,6 +19,10 @@ import App from './App.vue'; import router from './router'; import { i18nPlugin } from './plugins/i18n.plugin'; +import store from './tools/pomodoro-timer/app/store'; + +library.add(fas); + // loaded monaco-editor from `node_modules` loader.config({ monaco }); @@ -32,5 +38,6 @@ app.use(router); app.use(naive); app.use(plausible); app.use(shadow); +app.use(store, 'pomodoro-store'); app.mount('#app'); diff --git a/src/tools/pomodoro-timer/app/App.vue b/src/tools/pomodoro-timer/app/App.vue new file mode 100644 index 00000000..54675ece --- /dev/null +++ b/src/tools/pomodoro-timer/app/App.vue @@ -0,0 +1,157 @@ + + + + + diff --git a/src/tools/pomodoro-timer/app/components/AlarmSoundToggle.vue b/src/tools/pomodoro-timer/app/components/AlarmSoundToggle.vue new file mode 100644 index 00000000..8bc60ce1 --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/AlarmSoundToggle.vue @@ -0,0 +1,79 @@ + + + + + diff --git a/src/tools/pomodoro-timer/app/components/AppColorPicker.vue b/src/tools/pomodoro-timer/app/components/AppColorPicker.vue new file mode 100644 index 00000000..ae3a9c12 --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/AppColorPicker.vue @@ -0,0 +1,48 @@ + + + + + diff --git a/src/tools/pomodoro-timer/app/components/Counter.vue b/src/tools/pomodoro-timer/app/components/Counter.vue new file mode 100644 index 00000000..333ed60e --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/Counter.vue @@ -0,0 +1,16 @@ + + + + + diff --git a/src/tools/pomodoro-timer/app/components/FinishedPopup.vue b/src/tools/pomodoro-timer/app/components/FinishedPopup.vue new file mode 100644 index 00000000..1543accc --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/FinishedPopup.vue @@ -0,0 +1,25 @@ + + + diff --git a/src/tools/pomodoro-timer/app/components/Footer.vue b/src/tools/pomodoro-timer/app/components/Footer.vue new file mode 100644 index 00000000..431c9cbf --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/Footer.vue @@ -0,0 +1,17 @@ + + + diff --git a/src/tools/pomodoro-timer/app/components/Header.vue b/src/tools/pomodoro-timer/app/components/Header.vue new file mode 100644 index 00000000..297ab12b --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/Header.vue @@ -0,0 +1,66 @@ + + + diff --git a/src/tools/pomodoro-timer/app/components/ModeIconBar.vue b/src/tools/pomodoro-timer/app/components/ModeIconBar.vue new file mode 100644 index 00000000..16bd446f --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/ModeIconBar.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/src/tools/pomodoro-timer/app/components/NumberInput.vue b/src/tools/pomodoro-timer/app/components/NumberInput.vue new file mode 100644 index 00000000..542dcab8 --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/NumberInput.vue @@ -0,0 +1,31 @@ + + + diff --git a/src/tools/pomodoro-timer/app/components/PlayPauseBtn.vue b/src/tools/pomodoro-timer/app/components/PlayPauseBtn.vue new file mode 100644 index 00000000..3f78905b --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/PlayPauseBtn.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/src/tools/pomodoro-timer/app/components/ProgressBar.vue b/src/tools/pomodoro-timer/app/components/ProgressBar.vue new file mode 100644 index 00000000..42e28bb4 --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/ProgressBar.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/src/tools/pomodoro-timer/app/components/ResetDropup.vue b/src/tools/pomodoro-timer/app/components/ResetDropup.vue new file mode 100644 index 00000000..1458fdae --- /dev/null +++ b/src/tools/pomodoro-timer/app/components/ResetDropup.vue @@ -0,0 +1,48 @@ + + + + + diff --git a/src/tools/pomodoro-timer/app/store/index.js b/src/tools/pomodoro-timer/app/store/index.js new file mode 100644 index 00000000..a1269a81 --- /dev/null +++ b/src/tools/pomodoro-timer/app/store/index.js @@ -0,0 +1,85 @@ +import { createStore } from 'vuex'; +import { setAppAccentColor, setupNextTimerMode, startOver, startTimer, stopAlarms, stopTimer } from '../storeUtils.js'; + +export default createStore({ + state: { + counter: '25:00', + time: 0, + workInterval: 25, + shortBreak: 5, + shortBreakCount: 3, + longBreak: 30, + isTimerRunning: false, + isTimerInProgress: false, + isShowFinishedPopup: false, + isResetDropupVisible: false, + isFirstVisit: true, + prefersAlarmSound: false, + progress: ['workInterval'], + finishedMessage: '', + appAccentColor: '#3b83b0', + progressPercent: 0, + currentTab: 'home', + }, + mutations: { + goToPage(state, payload) { + state.currentTab = payload; + }, + setInitialTimer(state) { + setupNextTimerMode(state); + }, + setFirstVisitStatus(state, payload) { + state.isFirstVisit = payload.propValue; + }, + updateTimeSetting(state, payload) { + state[payload.propName] = payload.propValue; + // eslint-disable-next-line no-unused-expressions + state.isTimerInProgress ? {} : setupNextTimerMode(state); + }, + updateAppColor(state, payload) { + state[payload.propName] = payload.propValue; + setAppAccentColor(payload.propValue); + }, + toggleAlarmSound(state) { + state.prefersAlarmSound = !state.prefersAlarmSound; + }, + toggleTimer(state) { + state.isTimerRunning ? stopTimer(state) : startTimer(state); + }, + toggleResetDropup(state) { + state.isResetDropupVisible = !state.isResetDropupVisible; + }, + setProgressBarPercent(state, payload) { + state.progressPercent = payload.propValue; + }, + prepareNextTimerMode(state) { + stopAlarms(); + state.isShowFinishedPopup = false; + setupNextTimerMode(state); + }, + timerResetCurrent(state) { + stopTimer(state); + const currentMode = state.progress[state.progress.length - 1]; + this.commit('updateTimeSetting', { propName: currentMode, propValue: state[currentMode] }); + setupNextTimerMode(state); + state.isResetDropupVisible = false; + }, + timerResetAll(state) { + startOver(state); + }, + restoreDefaultSettings(state) { + this.commit('updateTimeSetting', { propName: 'workInterval', propValue: 25 }); + this.commit('updateTimeSetting', { propName: 'shortBreak', propValue: 5 }); + this.commit('updateTimeSetting', { propName: 'shortBreakCount', propValue: 3 }); + this.commit('updateTimeSetting', { propName: 'longBreak', propValue: 30 }); + state.prefersAlarmSound = false; + this.commit('updateAppColor', { propName: 'appAccentColor', propValue: '#3b83b0' }); + }, + }, + actions: { + + }, + modules: { + + }, +}); diff --git a/src/tools/pomodoro-timer/app/storeUtils.js b/src/tools/pomodoro-timer/app/storeUtils.js new file mode 100644 index 00000000..938ce51e --- /dev/null +++ b/src/tools/pomodoro-timer/app/storeUtils.js @@ -0,0 +1,146 @@ +function el(idString) { + return document.getElementById(idString); +} + +function msToString(ms) { + return new Date(ms).toISOString().slice(14, 19); +} + +let titleInterval = null; +function startTitleAlarm(str, delay) { + titleInterval = setInterval(() => { + document.title.startsWith('⏰') + ? document.title = `${str} - IT Tools` + : document.title = '⏰⏰⏰⏰⏰⏰⏰⏰⏰⏰' + ' - IT Tools'; + }, delay); +} + +function stopTitleAlarm() { + // eslint-disable-next-line no-alert + titleInterval ? clearInterval(titleInterval) : alert('Error: something went wrong when trying to stop the title alarm.'); + document.title = 'Pomodoro Timer - IT Tools'; +} + +function getNextTimerMode(state) { + const currentMode = state.progress[state.progress.length - 1]; + if (currentMode === 'workInterval') { + return state.progress.length === state.shortBreakCount * 2 + 1 ? 'longBreak' : 'shortBreak'; + } + else { + return 'workInterval'; + } +} + +function formatModeToText(mode) { + if (mode === 'workInterval') { + return 'work interval'; + } + if (mode === 'shortBreak') { + return 'short break'; + } + if (mode === 'longBreak') { + return 'long break'; + } +} + +function getAlarmText(nextMode) { + if (nextMode === 'workInterval') { + return 'Work Time'; + } + if (nextMode === 'shortBreak') { + return 'Short Break Time'; + } + if (nextMode === 'longBreak') { + return 'Long Break Time'; + } +} + +function startOver(state) { + stopTimer(state); + state.isTimerInProgress = false; + state.progress = ['workInterval']; + setupNextTimerMode(state); + state.isResetDropupVisible = false; +} + +function onTimerFinished(state, alarmPlayer) { + state.counter = '00:00'; + state.time = 0; + state.progressPercent = 100; + + const oldMode = state.progress[state.progress.length - 1]; + const newMode = getNextTimerMode(state); + state.progress.push(newMode); + + const oldModeText = formatModeToText(oldMode); + const newModeText = formatModeToText(newMode); + state.finishedMessage = `The ${oldModeText} timer has finished. Next up is a ${newModeText}.`; + state.isShowFinishedPopup = true; + + const titleText = getAlarmText(newMode); + startTitleAlarm(titleText, 500); + if (state.prefersAlarmSound) { + alarmPlayer.play(); + } + + stopTimer(state); +} + +function setupNextTimerMode(state) { + if (state.progress.length === state.shortBreakCount * 2 + 2) { + startOver(state); + } + else { + const timerMode = state.progress[state.progress.length - 1]; + state.time = state[timerMode] * 60000; + state.counter = msToString(state.time); + state.progressPercent = 0; + } +} + +function stopAlarms() { + el('alarmPlayer').pause(); + stopTitleAlarm(); +} + +let timerInterval = null; +function startTimer(state) { + state.isTimerRunning = true; + state.isTimerInProgress = true; + const timerMode = state.progress[state.progress.length - 1]; + const totalModeTime = state[timerMode] * 60000; + const remainingTime = state.time; + const startTime = Date.now(); + timerInterval = setInterval(() => { + const timeElapsed = Date.now() - startTime; + const newRemainingTime = remainingTime - timeElapsed; + if (newRemainingTime <= 0) { + onTimerFinished(state, el('alarmPlayer')); + return; + } + state.time = newRemainingTime; + state.counter = msToString(newRemainingTime); + state.progressPercent = (totalModeTime - newRemainingTime) / totalModeTime * 100; + }, 200); +} + +function stopTimer(state) { + if (timerInterval) { + clearInterval(timerInterval); + } + state.isTimerRunning = false; +} + +function setAppAccentColor(hexColor) { + const root = document.querySelector(':root'); + root.style.setProperty('--pomodoro-app-accent-color', hexColor); +} + +export { + startTimer, + stopTimer, + startOver, + setupNextTimerMode, + stopAlarms, + setAppAccentColor, +}; diff --git a/src/tools/pomodoro-timer/app/views/About.vue b/src/tools/pomodoro-timer/app/views/About.vue new file mode 100644 index 00000000..83cd9432 --- /dev/null +++ b/src/tools/pomodoro-timer/app/views/About.vue @@ -0,0 +1,40 @@ + + + diff --git a/src/tools/pomodoro-timer/app/views/Home.vue b/src/tools/pomodoro-timer/app/views/Home.vue new file mode 100644 index 00000000..61efdf6f --- /dev/null +++ b/src/tools/pomodoro-timer/app/views/Home.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/src/tools/pomodoro-timer/app/views/Settings.vue b/src/tools/pomodoro-timer/app/views/Settings.vue new file mode 100644 index 00000000..12899e88 --- /dev/null +++ b/src/tools/pomodoro-timer/app/views/Settings.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/tools/pomodoro-timer/app/views/SplashScreen.vue b/src/tools/pomodoro-timer/app/views/SplashScreen.vue new file mode 100644 index 00000000..28081e55 --- /dev/null +++ b/src/tools/pomodoro-timer/app/views/SplashScreen.vue @@ -0,0 +1,48 @@ + + + + + diff --git a/src/tools/pomodoro-timer/index.ts b/src/tools/pomodoro-timer/index.ts new file mode 100644 index 00000000..5c740aba --- /dev/null +++ b/src/tools/pomodoro-timer/index.ts @@ -0,0 +1,13 @@ +import { CalendarTime } from '@vicons/tabler'; +import { defineTool } from '../tool'; + +export const tool = defineTool({ + name: 'Pomodoro Timer', + path: '/pomodoro-timer', + description: 'Basic Pomodoro Timer', + keywords: ['pomodoro', 'timer'], + component: () => import('./pomodoro-timer.vue'), + icon: CalendarTime, + createdAt: new Date('2025-03-09'), + category: 'Development', +}); diff --git a/src/tools/pomodoro-timer/pomodoro-timer.vue b/src/tools/pomodoro-timer/pomodoro-timer.vue new file mode 100644 index 00000000..a95e9fbb --- /dev/null +++ b/src/tools/pomodoro-timer/pomodoro-timer.vue @@ -0,0 +1,9 @@ + + + diff --git a/tsconfig.app.json b/tsconfig.app.json index 181ee9ae..f2e905dd 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -15,6 +15,7 @@ "types": ["naive-ui/volar", "@intlify/unplugin-vue-i18n/messages", "unplugin-icons/types/vue"], "esModuleInterop": true, "jsx": "preserve", - "skipLibCheck": true + "skipLibCheck": true, + "allowJs": true } }