49 Commits

Author SHA1 Message Date
MAZE
320d05d414 style: change tool labels 2024-08-31 17:22:48 +03:30
MAZE
fdd23899f1 feat: add shortcut for the countdown timer 2024-08-31 17:16:30 +03:30
MAZE
24c0d58eee feat: add simple countdown timer 2024-08-31 17:11:56 +03:30
MAZE
cb37b08d37 feat: change shortcuts 2024-08-31 15:43:03 +03:30
MAZE
716fbca0f6 style: change items order 2024-08-31 15:33:45 +03:30
MAZE
cf77d33bd8 feat: add todo checklist tool 2024-08-31 15:32:04 +03:30
MAZE
876d575854 feat: add toolbox 2024-08-31 14:45:10 +03:30
MAZE
41845ffe5e style: remove animation on change 2024-08-31 14:34:10 +04:30
MAZE
48a85b2601 feat: add animation for labels 2024-08-31 14:02:11 +04:30
MAZE
5865fc867d feat: add timer for breathing exercises 2024-08-31 13:58:44 +04:30
MAZE
b27f24d374 style: minor changes 2024-08-31 13:26:10 +04:30
MAZE
5c9a2aa23a style: change border radius 2024-08-31 13:09:55 +04:30
MAZE
12d3255d57 style: fix pointer event 2024-08-31 13:00:04 +04:30
MAZE
c12ef12b79 style: remove pointer event 2024-08-31 12:55:55 +04:30
MAZE
ba3cd5ca5b style: add binary pattern 2024-08-31 12:49:40 +04:30
MAZE
a3b794d974 feat: add breathing exercise shortcut 2024-08-31 00:23:21 +03:30
MAZE
3ef4a076a2 fix: remove extra hook 2024-08-31 00:21:08 +03:30
MAZE
1f2b6b952c feat: add breathing exercise 2024-08-31 00:19:55 +03:30
MAZE
2bbdc7e09e feat: remove all tools 2024-08-31 00:10:58 +03:30
MAZE
47a63a774e feat: add store to the notepad 2024-08-30 23:38:37 +03:30
MAZE
edd53d8102 feat: add countdown timer 2024-08-30 23:35:58 +03:30
MAZE
302a71cdc6 style: minor change 2024-08-30 23:18:15 +03:30
MAZE
b73fd0b16e style: minor change 2024-08-30 23:17:13 +03:30
MAZE
5b3972b347 feat: add Moodist description to tools 2024-08-30 22:26:57 +03:30
MAZE
bee391acfe feat: add pomodoro timer tool 2024-08-30 22:21:23 +03:30
MAZE
1fd02f927c feat: add notepad tool page 2024-08-30 22:14:15 +03:30
MAZE
d56f8be448 refactor: refactor the breathing tool 2024-08-30 22:10:21 +03:30
MAZE
eee755378a feat: add breathing exercises and other tools 2024-08-30 22:09:07 +03:30
MAZE
4b015016e7 style: change logo color 2024-08-30 17:51:51 +03:30
MAZE
251f30930c feat: change shortcuts 2024-08-30 17:17:46 +03:30
MAZE
a29e2c20e4 style: minor changes 2024-08-30 17:14:29 +03:30
MAZE
1cf9a85e13 style: center icons 2024-08-30 17:09:07 +03:30
MAZE
69eb8832da style: add pattern 2024-08-30 17:01:30 +03:30
MAZE
c1ece582f4 feat: add new logo 2024-08-30 16:42:41 +03:30
MAZE
b32d8b2803 feat: remove all tools 2024-08-30 16:33:20 +03:30
MAZE
1768ba1548 feat: update the menu items 2024-08-30 15:30:22 +03:30
MAZE
a80289db57 feat: add notepad tool 2024-08-30 15:24:39 +03:30
MAZE
9208663050 style: change description 2024-08-30 15:20:28 +03:30
MAZE
d2edeb48be feat: add pomodoro timer 2024-08-30 15:19:35 +03:30
MAZE
27f25785e1 feat: add breathing exercises tool 2024-08-30 15:12:11 +03:30
MAZE ✧
f526f97908 Merge pull request #39 from arapl3y/feature/fix-modal-layout-shift
feat: fix modal and scrollbar layout shift
2024-08-03 21:35:17 +03:30
Alex Rapley
e399673462 feat: fix modal and scrollbar layout shift 2024-08-02 16:40:08 +10:00
MAZE
3d83a1427f perf: improve the breathing cricle 2024-07-06 19:37:30 +03:30
MAZE ✧
ddf929f4c0 Merge pull request #38 from SuperMeepBoy/accessbility-ignore-icons-screen-reader
accessibility: ignore icons for screen readers
2024-07-06 19:34:29 +03:30
MAZE
5ffb06be03 refactor: remove the timer store 2024-07-06 19:31:32 +03:30
MAZE
d6ed3fd251 feat: remove the countdown timer 2024-07-06 19:29:52 +03:30
MAZE
0052b917a8 style: reorder menu items 2024-07-04 20:02:46 +03:30
MAZE
9e38a8fd7d style: change gradient 2024-07-01 20:28:23 +03:30
Jef Roelandt
ee0a28b296 accessibility: ignore icons for screen readers 2024-06-19 23:08:39 +02:00
83 changed files with 1020 additions and 1303 deletions

View File

@@ -8,7 +8,8 @@
"rules": {
"import-notation": "string",
"selector-class-pattern": null
"selector-class-pattern": null,
"no-descending-specificity": null
},
"overrides": [

3
package-lock.json generated
View File

@@ -3602,7 +3602,8 @@
"node_modules/@formkit/auto-animate": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/@formkit/auto-animate/-/auto-animate-0.8.2.tgz",
"integrity": "sha512-SwPWfeRa5veb1hOIBMdzI+73te5puUBHmqqaF1Bu7FjvxlYSz/kJcZKSa9Cg60zL0uRNeJL2SbRxV6Jp6Q1nFQ=="
"integrity": "sha512-SwPWfeRa5veb1hOIBMdzI+73te5puUBHmqqaF1Bu7FjvxlYSz/kJcZKSa9Cg60zL0uRNeJL2SbRxV6Jp6Q1nFQ==",
"license": "MIT"
},
"node_modules/@humanwhocodes/config-array": {
"version": "0.11.11",

View File

@@ -1,11 +1,10 @@
<svg width="200" height="200" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M100 150C127.614 150 150 127.614 150 100C150 72.3858 127.614 50 100 50C72.3858 50 50 72.3858 50 100C50 127.614 72.3858 150 100 150ZM100 125C113.807 125 125 113.807 125 100C125 86.1929 113.807 75 100 75C86.1929 75 75 86.1929 75 100C75 113.807 86.1929 125 100 125Z" fill="#FAFAFA"/>
<path d="M50 50C22.3858 50 2.00172e-06 72.3857 7.94663e-07 100C-4.12393e-07 127.614 22.3858 150 50 150V125C36.1929 125 25 113.807 25 100C25 86.1929 36.1929 75 50 75V50Z" fill="#D4D4D8"/>
<path d="M150 50C150 22.3858 127.614 2.41411e-06 100 0C72.3858 -2.41411e-06 50 22.3858 50 50L75 50C75 36.1929 86.1929 25 100 25C113.807 25 125 36.1929 125 50H150Z" fill="#D4D4D8"/>
<path d="M150 150C177.614 150 200 127.614 200 100C200 72.3858 177.614 50 150 50V75C163.807 75 175 86.1929 175 100C175 113.807 163.807 125 150 125V150Z" fill="#D4D4D8"/>
<path d="M50 150C50 177.614 72.3857 200 100 200C127.614 200 150 177.614 150 150H125C125 163.807 113.807 175 100 175C86.1929 175 75 163.807 75 150H50Z" fill="#D4D4D8"/>
<path d="M25 50C25 36.1929 36.1929 25 50 25V1.39091e-06C22.3858 1.83851e-07 2.00172e-06 22.3857 7.94663e-07 50H25Z" fill="#A1A1AA"/>
<path d="M150 25C163.807 25 175 36.1929 175 50H200C200 22.3858 177.614 3.24858e-06 150 8.34465e-07L150 25Z" fill="#A1A1AA"/>
<path d="M175 150C175 163.807 163.807 175 150 175V200C177.614 200 200 177.614 200 150H175Z" fill="#A1A1AA"/>
<path d="M50 175C36.1929 175 25 163.807 25 150H0C0 177.614 22.3857 200 50 200V175Z" fill="#A1A1AA"/>
<path d="M100 64.4661C100 58.6219 101.411 53.1072 103.911 48.2441L103.911 48.2429L103.928 48.2107C105.198 45.7464 106.747 43.4498 108.535 41.3629C112.141 37.1521 116.716 33.7949 121.914 31.6361C121.346 30.9518 120.742 30.2877 120.101 29.6465C116.762 26.3072 112.799 23.9724 108.587 22.642C106.178 24.1973 103.912 25.9549 101.813 27.891C101.691 28.0031 101.571 28.1157 101.45 28.229C100.957 28.6929 100.474 29.1667 100 29.6501C99.5262 29.1667 99.0427 28.6929 98.5497 28.229C96.3499 26.1591 93.9616 24.2873 91.4133 22.642C88.8486 20.9862 86.1219 19.5598 83.2621 18.392C77.5239 16.0487 71.2502 14.7462 64.6755 14.7191C64.6057 14.7188 64.5359 14.7186 64.4661 14.7186C61.0306 14.7186 57.6765 15.0669 54.4371 15.73C35.009 19.7068 19.7068 35.009 15.7299 54.4371C21.5092 50.112 27.9257 47.0293 34.6104 45.1892C37.3473 40.959 40.9589 37.3474 45.1892 34.6104C47.9325 32.8355 50.936 31.4284 54.1299 30.4589C57.4006 29.4661 60.871 28.9322 64.4661 28.9322C66.6264 28.9322 68.7416 29.125 70.7956 29.4943C73.3293 29.9498 75.7698 30.6739 78.0864 31.6362C83.2841 33.795 87.8585 37.1521 91.4651 41.3629C93.2606 43.4592 94.8163 45.7672 96.0894 48.2441C96.2311 48.5197 96.3692 48.7973 96.5039 49.0771C98.7445 53.7333 100 58.9531 100 64.4661Z" fill="#FAFAFA"/>
<path d="M125.126 74.8737C129.259 70.7413 134.156 67.8394 139.362 66.1682C139.558 66.1053 139.755 66.0441 139.952 65.9846C142.418 65.2401 144.949 64.7693 147.498 64.5724C153.025 64.1451 158.634 65.0059 163.836 67.1547C163.919 66.2697 163.961 65.3729 163.961 64.4661C163.961 59.7437 162.81 55.2903 160.772 51.3713C157.934 50.7602 155.053 50.3994 152.163 50.289C152.034 50.2841 151.905 50.2796 151.775 50.2757C151.099 50.2551 150.422 50.2482 149.745 50.2551C149.752 49.5783 149.745 48.9014 149.724 48.2248C149.632 45.2056 149.267 42.1933 148.629 39.228C147.986 36.2436 147.067 33.3069 145.87 30.4589C143.47 24.7444 139.954 19.3872 135.325 14.7191C135.275 14.6695 135.226 14.6201 135.177 14.5707C132.748 12.1414 130.13 10.0159 127.37 8.1942C110.82 -2.7314 89.1798 -2.7314 72.63 8.19421C79.7748 9.2225 86.4918 11.5799 92.5196 15.0055C97.4462 13.9496 102.554 13.9496 107.48 15.0055C110.675 15.6902 113.794 16.8191 116.738 18.3919C119.753 20.0027 122.584 22.0791 125.126 24.6212C126.654 26.1487 128.013 27.7808 129.204 29.4942C130.674 31.608 131.888 33.8457 132.845 36.1642C134.994 41.366 135.855 46.9746 135.428 52.5022C135.215 55.2542 134.683 57.9862 133.832 60.6379C133.737 60.9329 133.638 61.2269 133.536 61.5199C131.828 66.3968 129.025 70.9754 125.126 74.8737Z" fill="#FAFAFA"/>
<path d="M135.534 100C141.378 100 146.893 101.411 151.756 103.911L151.789 103.928C154.254 105.198 156.55 106.747 158.637 108.535C162.848 112.141 166.205 116.716 168.364 121.914C169.048 121.346 169.712 120.742 170.354 120.101C173.693 116.762 176.028 112.799 177.358 108.587C175.713 106.038 173.841 103.65 171.771 101.45C171.307 100.957 170.833 100.474 170.35 100C170.833 99.5263 171.307 99.0427 171.771 98.5497C173.841 96.3499 175.713 93.9616 177.358 91.4133C179.014 88.8486 180.44 86.1218 181.608 83.262C183.951 77.5238 185.254 71.2501 185.281 64.6754C185.281 64.6057 185.281 64.5359 185.281 64.4661C185.281 61.0306 184.933 57.6764 184.27 54.437C180.293 35.009 164.991 19.7069 145.563 15.73C149.888 21.5092 152.971 27.9258 154.811 34.6104C159.041 37.3474 162.653 40.959 165.39 45.1892C167.165 47.9325 168.572 50.936 169.541 54.1299C170.534 57.4006 171.068 60.871 171.068 64.4661C171.068 66.6264 170.875 68.7416 170.506 70.7955C170.05 73.3293 169.326 75.7697 168.364 78.0864C166.205 83.2841 162.848 87.8586 158.637 91.4651C156.541 93.2607 154.233 94.8163 151.756 96.0894C151.48 96.2311 151.203 96.3693 150.923 96.5039C146.267 98.7445 141.047 100 135.534 100Z" fill="#FAFAFA"/>
<path d="M125.126 125.126C129.259 129.259 132.161 134.156 133.832 139.362C133.895 139.558 133.956 139.755 134.015 139.952C134.76 142.418 135.231 144.949 135.428 147.498C135.855 153.025 134.994 158.634 132.845 163.836C133.73 163.919 134.627 163.961 135.534 163.961C140.256 163.961 144.71 162.81 148.629 160.772C149.24 157.934 149.601 155.052 149.711 152.163C149.716 152.034 149.72 151.905 149.724 151.775C149.745 151.099 149.752 150.422 149.745 149.745C150.422 149.752 151.099 149.745 151.775 149.724C154.794 149.632 157.807 149.267 160.772 148.629C163.756 147.986 166.693 147.066 169.541 145.87C175.256 143.47 180.613 139.954 185.281 135.325C185.33 135.275 185.38 135.226 185.429 135.177C187.859 132.748 189.984 130.13 191.806 127.37C202.731 110.82 202.731 89.1797 191.806 72.6299C190.777 79.7747 188.42 86.4917 184.995 92.5196C186.05 97.4462 186.05 102.554 184.995 107.48C184.31 110.675 183.181 113.794 181.608 116.738C179.997 119.753 177.921 122.584 175.379 125.126C173.851 126.654 172.219 128.013 170.506 129.204C168.392 130.674 166.154 131.888 163.836 132.845C158.634 134.994 153.025 135.855 147.498 135.428C144.746 135.215 142.014 134.683 139.362 133.832C139.067 133.737 138.773 133.638 138.48 133.536C133.603 131.828 129.025 129.025 125.126 125.126Z" fill="#FAFAFA"/>
<path d="M100 135.534C100 141.378 98.5891 146.893 96.0894 151.756L96.0723 151.789C94.8023 154.254 93.2526 156.55 91.4651 158.637C87.8585 162.848 83.284 166.205 78.0864 168.364C78.6536 169.048 79.2578 169.712 79.899 170.354C83.2382 173.693 87.2014 176.028 91.4133 177.358C93.9478 175.722 96.324 173.861 98.514 171.805L98.5497 171.771C99.0427 171.307 99.5262 170.833 100 170.35C100.474 170.833 100.957 171.307 101.45 171.771C103.65 173.841 106.038 175.713 108.587 177.358C111.151 179.014 113.878 180.44 116.738 181.608C122.476 183.951 128.75 185.254 135.325 185.281C135.394 185.281 135.464 185.281 135.534 185.281C138.969 185.281 142.324 184.933 145.563 184.27C164.991 180.293 180.293 164.991 184.27 145.563C178.491 149.888 172.074 152.971 165.39 154.811C162.653 159.041 159.041 162.653 154.811 165.39C152.068 167.164 149.064 168.572 145.87 169.541C142.599 170.534 139.129 171.068 135.534 171.068C133.374 171.068 131.258 170.875 129.204 170.506C126.671 170.05 124.23 169.326 121.914 168.364C116.716 166.205 112.141 162.848 108.535 158.637C106.739 156.541 105.184 154.233 103.911 151.756C103.769 151.48 103.631 151.203 103.496 150.923C101.255 146.267 100 141.047 100 135.534Z" fill="#FAFAFA"/>
<path d="M74.8737 125.126C70.7413 129.259 65.8442 132.161 60.6379 133.832C60.4418 133.895 60.2453 133.956 60.0483 134.015C57.582 134.76 55.0507 135.231 52.5022 135.428C46.9745 135.855 41.366 134.994 36.1642 132.845C36.0813 133.73 36.0389 134.627 36.0389 135.534C36.0389 140.256 37.1904 144.71 39.2279 148.629C42.1932 149.267 45.2056 149.632 48.2247 149.724C48.9013 149.745 49.5783 149.752 50.2551 149.745C50.2483 150.422 50.2551 151.099 50.2757 151.775C50.3676 154.794 50.7328 157.807 51.3714 160.772C52.014 163.756 52.9335 166.693 54.1299 169.541C56.5304 175.256 60.0456 180.613 64.6755 185.281C64.7246 185.33 64.7739 185.38 64.8232 185.429C67.2525 187.859 69.8705 189.984 72.63 191.806C89.1798 202.731 110.82 202.731 127.37 191.806C120.225 190.778 113.508 188.42 107.48 184.995C102.554 186.05 97.4462 186.05 92.5196 184.994C89.3248 184.31 86.206 183.181 83.2621 181.608C80.2473 179.997 77.4159 177.921 74.8737 175.379C73.3462 173.851 71.9868 172.219 70.7956 170.506C69.3261 168.392 68.1125 166.154 67.1547 163.836C65.0059 158.634 64.1451 153.025 64.5724 147.498C64.7851 144.746 65.317 142.014 66.1682 139.362C66.2629 139.067 66.3616 138.773 66.4642 138.48C68.1723 133.603 70.9755 129.025 74.8737 125.126Z" fill="#FAFAFA"/>
<path d="M41.3629 108.535C43.4592 106.739 45.7671 105.184 48.2441 103.911C48.5197 103.769 48.7973 103.631 49.0771 103.496C53.7333 101.255 58.9531 100 64.4661 100C58.6219 100 53.1072 98.5891 48.2441 96.0894L48.2428 96.0888L48.2107 96.0723C45.7464 94.8023 43.4498 93.2526 41.3629 91.4651C37.1521 87.8586 33.7949 83.2841 31.6361 78.0864C30.9517 78.6536 30.2877 79.2578 29.6465 79.899C26.3072 83.2382 23.9724 87.2015 22.642 91.4134C23.7775 93.1722 25.021 94.8547 26.363 96.4517C26.9654 97.1686 27.5877 97.8682 28.2289 98.5498C28.6928 99.0427 29.1666 99.5263 29.6501 100C29.1666 100.474 28.6928 100.957 28.2289 101.45C26.1591 103.65 24.2873 106.038 22.642 108.587C20.9862 111.151 19.5598 113.878 18.3919 116.738C16.0486 122.476 14.7461 128.75 14.719 135.324C14.7187 135.394 14.7186 135.464 14.7186 135.534C14.7186 138.969 15.0668 142.324 15.7299 145.563C19.7068 164.991 35.009 180.293 54.437 184.27C50.112 178.491 47.0293 172.074 45.1892 165.39C40.959 162.653 37.3474 159.041 34.6104 154.811C32.8354 152.067 31.4283 149.064 30.4588 145.87C29.466 142.599 28.9321 139.129 28.9321 135.534C28.9321 133.374 29.1249 131.258 29.4942 129.204C29.9498 126.671 30.6739 124.23 31.6361 121.914C33.7949 116.716 37.1521 112.141 41.3629 108.535Z" fill="#FAFAFA"/>
<path d="M52.5022 64.5724C55.2542 64.7851 57.9862 65.317 60.6379 66.1682C60.9329 66.2629 61.227 66.3616 61.5199 66.4642C66.3968 68.1723 70.9755 70.9754 74.8737 74.8737C70.7413 70.7413 67.8394 65.8442 66.1682 60.6379C66.1053 60.4418 66.0441 60.2453 65.9846 60.0483C65.2401 57.582 64.7694 55.0507 64.5724 52.5022C64.1451 46.9746 65.0059 41.366 67.1547 36.1642C66.2697 36.0813 65.3729 36.039 64.4661 36.039C59.7437 36.039 55.2903 37.1904 51.3714 39.2279C50.7328 42.1933 50.3676 45.2056 50.2757 48.2248C50.2551 48.9014 50.2483 49.5783 50.2551 50.2551C49.5783 50.2482 48.9014 50.2551 48.2248 50.2757C45.2056 50.3676 42.1933 50.7328 39.2279 51.3714C36.2435 52.014 33.3068 52.9335 30.4589 54.1299C24.7444 56.5305 19.3872 60.0457 14.719 64.6755C14.6695 64.7246 14.6201 64.7739 14.5707 64.8232C12.1414 67.2525 10.0159 69.8705 8.19417 72.63C-2.73139 89.1798 -2.73139 110.82 8.19418 127.37C9.22247 120.225 11.5798 113.508 15.0055 107.48C13.9496 102.554 13.9496 97.4463 15.0055 92.5197C15.6902 89.3248 16.8191 86.2061 18.3919 83.2621C20.0027 80.2473 22.0791 77.4159 24.6212 74.8737C26.1487 73.3462 27.7807 71.9868 29.4942 70.7956C31.6079 69.3261 33.8457 68.1125 36.1642 67.1547C41.366 65.0059 46.9745 64.1451 52.5022 64.5724Z" fill="#FAFAFA"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@@ -18,10 +18,6 @@ const paragraphs = [
body: 'The beauty of Moodist lies in its simplicity and customization. No complex menus or confusing options just choose your desired sounds, adjust the volume balance, and hit play. Want to blend the gentle chirping of birds with the soothing sound of rain? No problem! Layer as many sounds as you like to create your personalized soundscape oasis.',
title: 'Create Your Soundscape',
},
{
body: 'Moodist offers more than ambient sounds with its suite of productivity tools to keep you organized and focused. Use the built-in pomodoro timer for structured work intervals, jot down ideas in the notepad, track tasks with the to-do list (coming soon), and set multiple timers with the distraction-free countdown timer. These tools integrate seamlessly with the ambient soundscapes, creating a personalized environment that fosters focus and relaxation.',
title: 'A Productivity Toolbox',
},
{
body: "Whether you're looking to unwind after a long day, enhance your focus during work, or lull yourself into a peaceful sleep, Moodist has the perfect soundscape waiting for you. The best part? It's completely free and open-source, so you can enjoy its benefits without any strings attached. Start using Moodist today and discover your new haven of tranquility and focus!",
title: 'Sounds for Every Moment',

View File

@@ -48,14 +48,14 @@ export function PlayButton() {
>
{isPlaying ? (
<>
<span>
<span aria-hidden="true">
<BiPause />
</span>{' '}
Pause
</>
) : (
<>
<span>
<span aria-hidden="true">
<BiPlay />
</span>{' '}
Play

View File

@@ -20,7 +20,10 @@
width: 45px;
height: 45px;
font-size: var(--font-md);
background-color: var(--color-neutral-100);
background: linear-gradient(
var(--color-neutral-50),
var(--color-neutral-100)
);
border: 1px solid var(--color-neutral-300);
border-radius: 50%;
}
@@ -31,6 +34,16 @@
font-size: var(--font-lg);
font-weight: 600;
text-align: center;
& span {
background: linear-gradient(
135deg,
var(--color-foreground),
var(--color-foreground-subtle)
);
background-clip: text;
-webkit-text-fill-color: transparent;
}
}
& .desc {

View File

@@ -9,12 +9,14 @@ export function Donate() {
<div className={styles.donate}>
<div className={styles.iconContainer}>
<div className={styles.tail} />
<div className={styles.icon}>
<div aria-hidden="true" className={styles.icon}>
<FaCoffee />
</div>
</div>
<div className={styles.title}>Support Me</div>
<div className={styles.title}>
<span>Support Me</span>
</div>
<p className={styles.desc}>Help me keep Moodist ad-free.</p>
<SpecialButton
className={styles.button}

View File

@@ -22,7 +22,10 @@
width: 45px;
height: 45px;
font-size: var(--font-md);
background-color: var(--color-neutral-100);
background: linear-gradient(
var(--color-neutral-50),
var(--color-neutral-100)
);
border: 1px solid var(--color-neutral-300);
border-radius: 50%;
}

View File

@@ -19,7 +19,9 @@ export function Category({
<div className={styles.category} id={`category-${id}`}>
<div className={styles.iconContainer}>
<div className={styles.tail} />
<div className={styles.icon}>{icon}</div>
<div aria-hidden="true" className={styles.icon}>
{icon}
</div>
</div>
<div className={styles.title}>{title}</div>

View File

@@ -11,24 +11,21 @@ const count = soundCount();
<div class="hero">
<Container>
<div class="wrapper">
<div class="pattern"></div>
<img
alt="Faded Moodist Logo"
aria-hidden="true"
class="logo"
height={45}
src="/logo.svg"
width={45}
/>
<div class="title">
<div class="left"></div>
<h2>Moodist</h2>
<div class="right"></div>
</div>
<h2 class="title"><span>Moodist</span></h2>
<h1 class="desc">Ambient sounds for focus and calm.</h1>
<p class="sounds">
<span class="icon">
<span aria-hidden="true" class="icon">
<BsSoundwave />
</span>
<span>{count} Sounds</span>
@@ -43,54 +40,55 @@ const count = soundCount();
.wrapper {
position: relative;
padding: 100px 0 80px;
padding: 120px 0 80px;
& .pattern {
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
background-image: radial-gradient(
var(--color-neutral-500) 5%,
transparent 5%
);
background-position: top center;
background-size: 21px 21px;
opacity: 0.8;
mask-image: linear-gradient(#fff, transparent, transparent);
}
}
& .logo {
display: block;
width: 45px;
margin: 0 auto 12px;
margin: 0 auto 16px;
animation-name: logo;
animation-duration: 45s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
& .title {
display: flex;
column-gap: 15px;
align-items: center;
font-family: var(--font-display);
font-size: var(--font-2xlg);
font-weight: 600;
line-height: 1;
& div {
flex-grow: 1;
height: 1px;
&.left {
background: linear-gradient(
90deg,
transparent,
transparent,
var(--color-neutral-200),
var(--color-neutral-300)
);
}
&.right {
background: linear-gradient(
90deg,
var(--color-neutral-300),
var(--color-neutral-200),
transparent,
transparent
);
}
}
& h2 {
font-family: var(--font-display);
font-size: var(--font-2xlg);
font-weight: 600;
& span {
background: linear-gradient(
135deg,
var(--color-foreground),
var(--color-foreground-subtle)
);
background-clip: text;
-webkit-text-fill-color: transparent;
}
}
& .desc {
margin-top: 5px;
margin-top: 4px;
line-height: 1.6;
color: var(--color-foreground-subtle);
}
@@ -139,4 +137,14 @@ const count = soundCount();
}
}
}
@keyframes logo {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
</style>

View File

@@ -2,11 +2,11 @@ import { MdOutlineTimer } from 'react-icons/md/index';
import { Item } from '../item';
interface SleepTimerProps {
interface CountdownProps {
open: () => void;
}
export function CountdownTimer({ open }: SleepTimerProps) {
export function Countdown({ open }: CountdownProps) {
return (
<Item
icon={<MdOutlineTimer />}

View File

@@ -1,11 +1,12 @@
export { Shuffle as ShuffleItem } from './shuffle';
export { Share as ShareItem } from './share';
export { Donate as DonateItem } from './donate';
export { Notepad as NotepadItem } from './notepad';
export { Source as SourceItem } from './source';
export { Pomodoro as PomodoroItem } from './pomodoro';
export { Presets as PresetsItem } from './presets';
export { Shortcuts as ShortcutsItem } from './shortcuts';
export { SleepTimer as SleepTimerItem } from './sleep-timer';
export { CountdownTimer as CountdownTimerItem } from './countdown-timer';
export { BreathingExercise as BreathingExerciseItem } from './breathing-exercise';
export { Pomodoro as PomodoroItem } from './pomodoro';
export { Notepad as NotepadItem } from './notepad';
export { Todo as TodoItem } from './todo';
export { Countdown as CountdownItem } from './countdown';

View File

@@ -15,7 +15,7 @@ export function Notepad({ open }: NotepadProps) {
<Item
active={!!note.length}
icon={<MdNotes />}
label="Notepad"
label="Simple Notepad"
shortcut="Shift + N"
onClick={open}
/>

View File

@@ -15,7 +15,7 @@ export function Pomodoro({ open }: PomodoroProps) {
<Item
active={running}
icon={<MdOutlineAvTimer />}
label="Pomodoro"
label="Pomodoro Timer"
shortcut="Shift + P"
onClick={open}
/>

View File

@@ -15,7 +15,7 @@ export function SleepTimer({ open }: SleepTimerProps) {
active={active}
icon={<IoMoonSharp />}
label="Sleep Timer"
shortcut="Shift + T"
shortcut="Shift + Alt + T"
onClick={open}
/>
);

View File

@@ -0,0 +1,18 @@
import { MdTaskAlt } from 'react-icons/md/index';
import { Item } from '../item';
interface TodoProps {
open: () => void;
}
export function Todo({ open }: TodoProps) {
return (
<Item
icon={<MdTaskAlt />}
label="Todo Checklist"
shortcut="Shift + T"
onClick={open}
/>
);
}

View File

@@ -7,6 +7,7 @@
height: 45px;
font-size: var(--font-md);
color: var(--color-foreground);
pointer-events: auto;
cursor: pointer;
background-color: var(--color-neutral-100);
border: 1px solid var(--color-neutral-300);
@@ -37,5 +38,5 @@
overflow: auto;
background-color: var(--color-neutral-100);
border: 1px solid var(--color-neutral-300);
border-radius: 4px;
border-radius: 8px;
}

View File

@@ -8,26 +8,23 @@ import {
ShuffleItem,
ShareItem,
DonateItem,
NotepadItem,
SourceItem,
PomodoroItem,
CountdownTimerItem,
PresetsItem,
ShortcutsItem,
SleepTimerItem,
BreathingExerciseItem,
PomodoroItem,
NotepadItem,
TodoItem,
CountdownItem,
} from './items';
import { Divider } from './divider';
import { ShareLinkModal } from '@/components/modals/share-link';
import { PresetsModal } from '@/components/modals/presets';
import { ShortcutsModal } from '@/components/modals/shortcuts';
import { SleepTimerModal } from '@/components/modals/sleep-timer';
import {
Notepad,
Pomodoro,
CountdownTimer,
BreathingExercise,
} from '@/components/toolbox';
import { BreathingExerciseModal } from '../modals/breathing';
import { Pomodoro, Notepad, Todo, Countdown } from '../toolbox';
import { fade, mix, slideY } from '@/lib/motion';
import { useSoundStore } from '@/stores/sound';
@@ -42,14 +39,15 @@ export function Menu() {
const initial = useMemo(
() => ({
breathingExercise: false,
countdownTimer: false,
breathing: false,
countdown: false,
notepad: false,
pomodoro: false,
presets: false,
shareLink: false,
shortcuts: false,
sleepTimer: false,
todo: false,
}),
[],
);
@@ -73,14 +71,15 @@ export function Menu() {
);
useHotkeys('shift+m', () => setIsOpen(prev => !prev));
useHotkeys('shift+n', () => open('notepad'));
useHotkeys('shift+p', () => open('pomodoro'));
useHotkeys('shift+c', () => open('countdownTimer'));
useHotkeys('shift+b', () => open('breathingExercise'));
useHotkeys('shift+alt+p', () => open('presets'));
useHotkeys('shift+h', () => open('shortcuts'));
useHotkeys('shift+b', () => open('breathing'));
useHotkeys('shift+n', () => open('notepad'));
useHotkeys('shift+p', () => open('pomodoro'));
useHotkeys('shift+t', () => open('todo'));
useHotkeys('shift+c', () => open('countdown'));
useHotkeys('shift+s', () => open('shareLink'), { enabled: !noSelected });
useHotkeys('shift+t', () => open('sleepTimer'));
useHotkeys('shift+alt+t', () => open('sleepTimer'));
useCloseListener(closeAll);
@@ -119,12 +118,11 @@ export function Menu() {
<SleepTimerItem open={() => open('sleepTimer')} />
<Divider />
<CountdownItem open={() => open('countdown')} />
<PomodoroItem open={() => open('pomodoro')} />
<NotepadItem open={() => open('notepad')} />
<BreathingExerciseItem
open={() => open('breathingExercise')}
/>
<CountdownTimerItem open={() => open('countdownTimer')} />
<TodoItem open={() => open('todo')} />
<BreathingExerciseItem open={() => open('breathing')} />
<Divider />
<ShortcutsItem open={() => open('shortcuts')} />
@@ -144,25 +142,23 @@ export function Menu() {
show={modals.shareLink}
onClose={() => close('shareLink')}
/>
<BreathingExerciseModal
show={modals.breathing}
onClose={() => close('breathing')}
/>
<ShortcutsModal
show={modals.shortcuts}
onClose={() => close('shortcuts')}
/>
<PresetsModal show={modals.presets} onClose={() => close('presets')} />
<Notepad show={modals.notepad} onClose={() => close('notepad')} />
<Pomodoro
open={() => open('pomodoro')}
show={modals.pomodoro}
onClose={() => close('pomodoro')}
/>
<BreathingExercise
show={modals.breathingExercise}
onClose={() => close('breathingExercise')}
/>
<CountdownTimer
show={modals.countdownTimer}
onClose={() => close('countdownTimer')}
/>
<Notepad show={modals.notepad} onClose={() => close('notepad')} />
<Todo show={modals.todo} onClose={() => close('todo')} />
<Countdown show={modals.countdown} onClose={() => close('countdown')} />
<PresetsModal show={modals.presets} onClose={() => close('presets')} />
<SleepTimerModal
show={modals.sleepTimer}
onClose={() => close('sleepTimer')}

View File

@@ -19,6 +19,8 @@ interface ModalProps {
wide?: boolean;
}
const TRANSITION_DURATION = 300;
export function Modal({
children,
lockBody = true,
@@ -34,9 +36,12 @@ export function Modal({
useEffect(() => {
if (show && lockBody) {
document.body.style.overflow = 'hidden';
document.body.style.overflowY = 'hidden';
} else if (lockBody) {
document.body.style.overflow = 'auto';
// Wait for transition to finish before allowing scrollbar to return
setTimeout(() => {
document.body.style.overflowY = 'auto';
}, TRANSITION_DURATION);
}
}, [show, lockBody]);
@@ -68,6 +73,7 @@ export function Modal({
<motion.div
{...animationProps}
className={styles.overlay}
transition={{ duration: TRANSITION_DURATION / 1000 }}
variants={variants.overlay}
onClick={onClose}
onKeyDown={onClose}
@@ -76,6 +82,7 @@ export function Modal({
<motion.div
{...animationProps}
className={cn(styles.content, wide && styles.wide)}
transition={{ duration: TRANSITION_DURATION / 1000 }}
variants={variants.modal}
>
<button className={styles.close} onClick={onClose}>

View File

@@ -8,7 +8,7 @@ interface TimerProps {
show: boolean;
}
export function BreathingExercise({ onClose, show }: TimerProps) {
export function BreathingExerciseModal({ onClose, show }: TimerProps) {
return (
<Modal show={show} onClose={onClose}>
<h2 className={styles.title}>Breathing Exercise</h2>

View File

@@ -0,0 +1,91 @@
.exercise {
position: relative;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 75px 0;
margin-top: 12px;
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 8px;
& .timer {
position: absolute;
top: 4px;
left: 4px;
padding: 4px 12px;
font-size: var(--font-xsm);
color: var(--color-foreground-subtle);
background: linear-gradient(
var(--color-neutral-100),
var(--color-neutral-50)
);
border: 1px solid var(--color-neutral-200);
border-radius: 4px;
}
& .phase {
font-family: var(--font-display);
font-size: var(--font-lg);
font-weight: 600;
}
& .circle {
position: absolute;
top: 50%;
left: 50%;
z-index: -1;
height: 55%;
aspect-ratio: 1 / 1;
background-image: radial-gradient(
var(--color-neutral-50),
var(--color-neutral-100)
);
border: 1px solid var(--color-neutral-200);
border-radius: 50%;
transform: translate(-50%, -50%);
}
}
.selectWrapper {
position: relative;
width: 100%;
height: 45px;
padding: 0 12px;
margin-top: 8px;
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 8px;
&::before {
position: absolute;
top: -1px;
left: 50%;
width: 80%;
height: 1px;
content: '';
background: linear-gradient(
90deg,
transparent,
var(--color-neutral-300),
transparent
);
transform: translateX(-50%);
}
& .selectBox {
width: 100%;
min-width: 0;
height: 100%;
font-size: var(--font-sm);
color: var(--color-foreground);
background-color: transparent;
border: none;
outline: none;
& option {
color: var(--color-neutral-50);
}
}
}

View File

@@ -0,0 +1,126 @@
import { useState, useEffect, useMemo, useCallback } from 'react';
import { motion } from 'framer-motion';
import { padNumber } from '@/helpers/number';
import styles from './exercise.module.css';
type Exercise = 'Box Breathing' | 'Resonant Breathing' | '4-7-8 Breathing';
type Phase = 'inhale' | 'exhale' | 'holdInhale' | 'holdExhale';
const EXERCISE_PHASES: Record<Exercise, Phase[]> = {
'4-7-8 Breathing': ['inhale', 'holdInhale', 'exhale'],
'Box Breathing': ['inhale', 'holdInhale', 'exhale', 'holdExhale'],
'Resonant Breathing': ['inhale', 'exhale'],
};
const EXERCISE_DURATIONS: Record<Exercise, Partial<Record<Phase, number>>> = {
'4-7-8 Breathing': { exhale: 8, holdInhale: 7, inhale: 4 },
'Box Breathing': { exhale: 4, holdExhale: 4, holdInhale: 4, inhale: 4 },
'Resonant Breathing': { exhale: 5, inhale: 5 }, // No holdExhale
};
const PHASE_LABELS: Record<Phase, string> = {
exhale: 'Exhale',
holdExhale: 'Hold',
holdInhale: 'Hold',
inhale: 'Inhale',
};
export function Exercise() {
const [selectedExercise, setSelectedExercise] =
useState<Exercise>('4-7-8 Breathing');
const [phaseIndex, setPhaseIndex] = useState(0);
const phases = useMemo(
() => EXERCISE_PHASES[selectedExercise],
[selectedExercise],
);
const durations = useMemo(
() => EXERCISE_DURATIONS[selectedExercise],
[selectedExercise],
);
const currentPhase = phases[phaseIndex];
const animationVariants = useMemo(
() => ({
exhale: {
transform: 'translate(-50%, -50%) scale(1)',
transition: { duration: durations.exhale },
},
holdExhale: {
transform: 'translate(-50%, -50%) scale(1)',
transition: { duration: durations.holdExhale },
},
holdInhale: {
transform: 'translate(-50%, -50%) scale(1.5)',
transition: { duration: durations.holdInhale },
},
inhale: {
transform: 'translate(-50%, -50%) scale(1.5)',
transition: { duration: durations.inhale },
},
}),
[durations],
);
const resetExercise = useCallback(() => {
setPhaseIndex(0);
}, []);
const updatePhase = useCallback(() => {
setPhaseIndex(prevIndex => (prevIndex + 1) % phases.length);
}, [phases.length]);
useEffect(() => {
resetExercise();
}, [selectedExercise, resetExercise]);
useEffect(() => {
const intervalDuration = (durations[currentPhase] || 4) * 1000;
const interval = setInterval(updatePhase, intervalDuration);
return () => clearInterval(interval);
}, [currentPhase, durations, updatePhase]);
const [timer, setTimer] = useState(0);
useEffect(() => {
const interval = setInterval(() => setTimer(prev => prev + 1), 1000);
return () => clearInterval(interval);
}, []);
return (
<>
<div className={styles.exercise}>
<div className={styles.timer}>
{padNumber(Math.floor(timer / 60))}:{padNumber(timer % 60)}
</div>
<motion.div
animate={currentPhase}
className={styles.circle}
key={selectedExercise}
variants={animationVariants}
/>
<p className={styles.phase}>{PHASE_LABELS[currentPhase]}</p>
</div>
<div className={styles.selectWrapper}>
<select
className={styles.selectBox}
value={selectedExercise}
onChange={e => setSelectedExercise(e.target.value as Exercise)}
>
{Object.keys(EXERCISE_PHASES).map(exercise => (
<option key={exercise} value={exercise}>
{exercise}
</option>
))}
</select>
</div>
</>
);
}

View File

@@ -0,0 +1 @@
export { BreathingExerciseModal } from './breathing';

View File

@@ -18,7 +18,7 @@
justify-content: space-between;
& .label {
font-weight: 500;
font-size: var(--font-sm);
color: var(--color-foreground-subtle);
}

View File

@@ -22,24 +22,28 @@ export function ShortcutsModal({ onClose, show }: ShortcutsModalProps) {
label: 'Share Sounds',
},
{
keys: ['Shift', 'N'],
label: 'Notepad',
},
{
keys: ['Shift', 'P'],
label: 'Pomodoro Timer',
},
{
keys: ['Shift', 'B'],
label: 'Breathing Exercise',
keys: ['Shift', 'Alt', 'T'],
label: 'Sleep Timer',
},
{
keys: ['Shift', 'C'],
label: 'Countdown Timer',
},
{
keys: ['Shift', 'N'],
label: 'Simple Notepad',
},
{
keys: ['Shift', 'P'],
label: 'Pomodoro Timer',
},
{
keys: ['Shift', 'T'],
label: 'Sleep Timer',
label: 'Todo Checklist',
},
{
keys: ['Shift', 'B'],
label: 'Breathing Exercise',
},
{
keys: ['Shift', 'Space'],

View File

@@ -6,6 +6,7 @@
height: 45px;
font-size: var(--font-md);
color: var(--color-foreground);
pointer-events: auto;
cursor: pointer;
background-color: var(--color-neutral-100);
border: 1px solid var(--color-neutral-300);

View File

@@ -56,6 +56,7 @@ export function Favorite({ id, label }: FavoriteProps) {
>
<motion.span
animate="show"
aria-hidden="true"
exit="hidden"
initial="hidden"
key={isFavorite ? `${id}-is-favorite` : `${id}-not-favorite`}

View File

@@ -47,6 +47,10 @@
color: var(--color-foreground-subtler);
transition: 0.2s;
& span {
line-height: 0;
}
&::after {
position: absolute;
top: 0;

View File

@@ -97,11 +97,11 @@ export const Sound = forwardRef<HTMLDivElement, SoundProps>(function Sound(
<Favorite id={id} label={label} />
<div className={styles.icon}>
{isLoading ? (
<span className={styles.spinner}>
<span aria-hidden="true" className={styles.spinner}>
<ImSpinner9 />
</span>
) : (
icon
<span aria-hidden="true">{icon}</span>
)}
</div>
<div className={styles.label} id={id}>

View File

@@ -3,6 +3,10 @@ import { FaGithub } from 'react-icons/fa/index';
import { SpecialButton } from './special-button';
import { Container } from './container';
import { generateRandomBinaryString } from '@/helpers/binary';
const binary = generateRandomBinaryString(1000);
---
<div class="source">
@@ -15,7 +19,7 @@ import { Container } from './container';
</div>
</div>
<h2 class="title">Open Source</h2>
<h2 class="title"><span>Open Source</span></h2>
<p class="desc">Moodist is free and open-source!</p>
<div class="button">
@@ -23,6 +27,8 @@ import { Container } from './container';
Source Code
</SpecialButton>
</div>
<div class="binary">{binary}</div>
</div>
</Container>
</div>
@@ -34,9 +40,28 @@ import { Container } from './container';
& .wrapper {
position: relative;
padding: 0 20px 40px;
overflow: hidden;
background: linear-gradient(transparent, rgb(24 24 27 / 70%));
border-radius: 0 0 20px 20px;
& .binary {
position: absolute;
bottom: -2.1rem;
left: 50%;
width: calc(100% + 10px);
height: 200px;
overflow: hidden;
font-family: 'Nimbus Mono PS', 'Courier New', monospace;
color: var(--color-foreground-subtler);
word-break: break-all;
pointer-events: none;
cursor: default;
user-select: none;
opacity: 0.35;
mask-image: linear-gradient(transparent, #000);
transform: translateX(-50%);
}
&::after {
position: absolute;
bottom: 0;
@@ -73,7 +98,10 @@ import { Container } from './container';
width: 45px;
height: 45px;
font-size: var(--font-md);
background-color: var(--color-neutral-100);
background: linear-gradient(
var(--color-neutral-50),
var(--color-neutral-100)
);
border: 1px solid var(--color-neutral-300);
border-radius: 50%;
}
@@ -84,6 +112,16 @@ import { Container } from './container';
font-size: var(--font-lg);
font-weight: 600;
text-align: center;
& span {
background: linear-gradient(
135deg,
var(--color-foreground),
var(--color-foreground-subtle)
);
background-clip: text;
-webkit-text-fill-color: transparent;
}
}
& .desc {

View File

@@ -6,19 +6,20 @@ interface SpecialButtonProps {
children: React.ReactNode;
className?: string;
href: string;
internal?: boolean;
}
export function SpecialButton({
children,
className,
href,
internal,
}: SpecialButtonProps) {
return (
<a
className={cn(styles.button, className)}
href={href}
rel="noreferrer"
target="_blank"
{...(!internal ? { rel: 'noreferrer', target: '_blank' } : {})}
>
{children}
</a>

View File

@@ -3,7 +3,7 @@ import { useEffect } from 'react';
import { useSoundStore } from '@/stores/sound';
import { useNoteStore } from '@/stores/note';
import { usePresetStore } from '@/stores/preset';
import { useCountdownTimers } from '@/stores/countdown-timers';
import { useTodoStore } from '@/stores/todo';
interface StoreConsumerProps {
children: React.ReactNode;
@@ -14,7 +14,7 @@ export function StoreConsumer({ children }: StoreConsumerProps) {
useSoundStore.persist.rehydrate();
useNoteStore.persist.rehydrate();
usePresetStore.persist.rehydrate();
useCountdownTimers.persist.rehydrate();
useTodoStore.persist.rehydrate();
}, []);
return <>{children}</>;

View File

@@ -9,4 +9,8 @@
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 8px;
&.tall {
padding: 60px 0;
}
}

View File

@@ -1,13 +1,15 @@
import { padNumber } from '@/helpers/number';
import { cn } from '@/helpers/styles';
import styles from './timer.module.css';
interface TimerProps {
displayHours?: boolean;
tall?: boolean;
timer: number;
}
export function Timer({ displayHours = false, timer }: TimerProps) {
export function Timer({ displayHours = false, tall, timer }: TimerProps) {
let hours = Math.floor(timer / 3600);
let minutes = Math.floor((timer % 3600) / 60);
let seconds = timer % 60;
@@ -21,7 +23,7 @@ export function Timer({ displayHours = false, timer }: TimerProps) {
const formattedSeconds = padNumber(seconds);
return (
<div className={styles.timer}>
<div className={cn(styles.timer, tall && styles.tall)}>
{displayHours ? (
<>
{formattedHours}:{formattedMinutes}:{formattedSeconds}

View File

@@ -3,7 +3,8 @@
bottom: 20px;
left: 0;
z-index: 15;
width: 100%;
width: 100vw;
pointer-events: none;
.container {
display: flex;

View File

@@ -1,44 +0,0 @@
.exercise {
position: relative;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 75px 0;
margin-top: 12px;
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 8px;
& .phase {
font-family: var(--font-display);
font-size: var(--font-lg);
font-weight: 600;
}
& .circle {
position: absolute;
top: 50%;
left: 50%;
z-index: -1;
height: 55%;
aspect-ratio: 1 / 1;
background-image: radial-gradient(transparent, var(--color-neutral-100));
border: 1px solid var(--color-neutral-200);
border-radius: 50%;
transform: translate(-50%, -50%);
}
}
.selectBox {
width: 100%;
min-width: 0;
height: 45px;
padding: 0 12px;
margin-top: 8px;
font-size: var(--font-sm);
color: var(--color-foreground);
background-color: var(--color-neutral-100);
border: 1px solid var(--color-neutral-200);
border-radius: 8px;
}

View File

@@ -1,120 +0,0 @@
import { useState, useEffect } from 'react';
import { motion } from 'framer-motion';
import styles from './exercise.module.css';
type Exercise = 'Box Breathing' | 'Resonant Breathing' | '4-7-8 Breathing';
type Phase = 'inhale' | 'exhale' | 'holdInhale' | 'holdExhale';
export function Exercise() {
const [selectedExercise, setSelectedExercise] =
useState<Exercise>('4-7-8 Breathing');
const getAnimationPhases = (
exercise: Exercise,
): Array<'inhale' | 'holdInhale' | 'exhale' | 'holdExhale'> => {
switch (exercise) {
case 'Box Breathing':
return ['inhale', 'holdInhale', 'exhale', 'holdExhale'];
case 'Resonant Breathing':
return ['inhale', 'exhale'];
case '4-7-8 Breathing':
return ['inhale', 'holdInhale', 'exhale'];
default:
return ['inhale', 'holdInhale', 'exhale', 'holdExhale'];
}
};
const getAnimationDurations = (exercise: Exercise) => {
switch (exercise) {
case 'Box Breathing':
return { exhale: 4, holdExhale: 4, holdInhale: 4, inhale: 4 };
case 'Resonant Breathing':
return { exhale: 5, inhale: 5 };
case '4-7-8 Breathing':
return { exhale: 8, holdInhale: 7, inhale: 4 };
default:
return { exhale: 4, holdExhale: 4, holdInhale: 4, inhale: 4 };
}
};
const getLabel = (phase: Phase) => {
switch (phase) {
case 'inhale':
return 'Inhale';
case 'exhale':
return 'Exhale';
default:
return 'Hold';
}
};
const [phase, setPhase] = useState<Phase>('inhale');
const [durations, setDurations] = useState(
getAnimationDurations(selectedExercise),
);
const animationVariants = {
exhale: { scale: 1, transition: { duration: durations.exhale } },
holdExhale: {
scale: 1,
transition: { duration: durations.holdExhale || 4 },
},
holdInhale: {
scale: 1.5,
transition: { duration: durations.holdInhale || 4 },
},
inhale: { scale: 1.5, transition: { duration: durations.inhale } },
};
useEffect(() => {
setDurations(getAnimationDurations(selectedExercise));
}, [selectedExercise]);
useEffect(() => {
const phases = getAnimationPhases(selectedExercise);
let phaseIndex = 0;
setPhase(phases[phaseIndex]);
const interval = setInterval(
() => {
phaseIndex = (phaseIndex + 1) % phases.length;
setPhase(phases[phaseIndex]);
},
(durations[phases[phaseIndex]] || 4) * 1000,
);
return () => clearInterval(interval);
}, [selectedExercise, durations]);
return (
<>
<div className={styles.exercise}>
<motion.div
animate={phase}
className={styles.circle}
key={selectedExercise}
transition={{ ease: 'linear' }}
variants={animationVariants}
transformTemplate={(_, generatedString) =>
`translate(-50%, -50%) ${generatedString}`
}
/>
<p className={styles.phase}>{getLabel(phase)}</p>
</div>
<select
className={styles.selectBox}
value={selectedExercise}
onChange={e => setSelectedExercise(e.target.value as Exercise)}
>
<option value="Box Breathing">Box Breathing</option>
<option value="Resonant Breathing">Resonant Breathing</option>
<option value="4-7-8 Breathing">4-7-8 Breathing</option>
</select>
</>
);
}

View File

@@ -1 +0,0 @@
export { BreathingExercise } from './breathing';

View File

@@ -1,6 +0,0 @@
.title {
margin-bottom: 16px;
font-family: var(--font-heading);
font-size: var(--font-md);
font-weight: 600;
}

View File

@@ -1,25 +0,0 @@
import { useAutoAnimate } from '@formkit/auto-animate/react';
import { Modal } from '@/components/modal';
import { Form } from './form';
import { Timers } from './timers';
import styles from './countdown-timer.module.css';
interface TimerProps {
onClose: () => void;
show: boolean;
}
export function CountdownTimer({ onClose, show }: TimerProps) {
const [containerRef, enableAnimations] = useAutoAnimate<HTMLDivElement>();
return (
<Modal persist show={show} onClose={onClose}>
<h2 className={styles.title}>Countdown Timer</h2>
<Form enableAnimations={enableAnimations} />
<Timers enableAnimations={enableAnimations} ref={containerRef} />
</Modal>
);
}

View File

@@ -1,27 +0,0 @@
.field {
flex-grow: 1;
& .label {
display: block;
margin-bottom: 8px;
font-size: var(--font-sm);
font-weight: 500;
& .optional {
font-weight: 400;
color: var(--color-foreground-subtle);
}
}
& .input {
width: 100%;
min-width: 0;
height: 40px;
padding: 0 16px;
color: var(--color-foreground);
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 4px;
outline: none;
}
}

View File

@@ -1,51 +0,0 @@
import styles from './field.module.css';
interface FieldProps {
children?: React.ReactNode;
label: string;
onChange: (value: string | number) => void;
optional?: boolean;
type: 'text' | 'select';
value: string | number;
}
export function Field({
children,
label,
onChange,
optional,
type,
value,
}: FieldProps) {
return (
<div className={styles.field}>
<label className={styles.label} htmlFor={label.toLowerCase()}>
{label}{' '}
{optional && <span className={styles.optional}>(optional)</span>}
</label>
{type === 'text' && (
<input
autoComplete="off"
className={styles.input}
id={label.toLowerCase()}
type="text"
value={value}
onChange={e => onChange(e.target.value)}
/>
)}
{type === 'select' && (
<select
autoComplete="off"
className={styles.input}
id={label.toLowerCase()}
value={value}
onChange={e => onChange(parseInt(e.target.value))}
>
{children}
</select>
)}
</div>
);
}

View File

@@ -1 +0,0 @@
export { Field } from './field';

View File

@@ -1,27 +0,0 @@
.form {
display: flex;
flex-direction: column;
row-gap: 28px;
& .button {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 45px;
font-weight: 500;
color: var(--color-neutral-50);
cursor: pointer;
background-color: var(--color-neutral-950);
border: none;
border-radius: 4px;
outline: none;
}
}
.timeFields {
display: flex;
column-gap: 12px;
align-items: flex-end;
justify-content: space-between;
}

View File

@@ -1,112 +0,0 @@
import { useState, useMemo } from 'react';
import { Field } from './field';
import { useCountdownTimers } from '@/stores/countdown-timers';
import { waitUntil } from '@/helpers/wait';
import styles from './form.module.css';
interface FormProps {
enableAnimations: (enabled: boolean) => void;
}
export function Form({ enableAnimations }: FormProps) {
const [name, setName] = useState('');
const [hours, setHours] = useState(0);
const [minutes, setMinutes] = useState(10);
const [seconds, setSeconds] = useState(0);
const totalSeconds = useMemo(
() => hours * 60 * 60 + minutes * 60 + seconds,
[hours, minutes, seconds],
);
const add = useCountdownTimers(state => state.add);
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (totalSeconds === 0) return;
enableAnimations(false);
const id = add({
name,
total: totalSeconds,
});
setName('');
await waitUntil(() => !!document.getElementById(`timer-${id}`), 50);
document
.getElementById(`timer-${id}`)
?.scrollIntoView({ behavior: 'smooth' });
enableAnimations(true);
};
return (
<form className={styles.form} onSubmit={handleSubmit}>
<Field
label="Timer Name"
optional
type="text"
value={name}
onChange={value => setName(value as string)}
/>
<div className={styles.timeFields}>
<Field
label="Hours"
type="select"
value={hours}
onChange={value => setHours(value as number)}
>
{Array(13)
.fill(null)
.map((_, index) => (
<option key={`hour-${index}`} value={index}>
{index}
</option>
))}
</Field>
<Field
label="Minutes"
type="select"
value={minutes}
onChange={value => setMinutes(value as number)}
>
{Array(60)
.fill(null)
.map((_, index) => (
<option key={`minutes-${index}`} value={index}>
{index}
</option>
))}
</Field>
<Field
label="Seconds"
type="select"
value={seconds}
onChange={value => setSeconds(value as number)}
>
{Array(60)
.fill(null)
.map((_, index) => (
<option key={`seconds-${index}`} value={index}>
{index}
</option>
))}
</Field>
</div>
<button className={styles.button} type="submit">
Add Timer
</button>
</form>
);
}

View File

@@ -1 +0,0 @@
export { CountdownTimer } from './countdown-timer';

View File

@@ -1 +0,0 @@
export { Timers } from './timers';

View File

@@ -1 +0,0 @@
export { Notice } from './notice';

View File

@@ -1,11 +0,0 @@
.notice {
padding: 16px;
margin-top: 16px;
font-size: var(--font-sm);
line-height: 1.65;
color: var(--color-foreground-subtle);
text-align: center;
background-color: var(--color-neutral-50);
border: 1px dashed var(--color-neutral-300);
border-radius: 8px;
}

View File

@@ -1,10 +0,0 @@
import styles from './notice.module.css';
export function Notice() {
return (
<p className={styles.notice}>
Please do not close your browser tab while timers are running, otherwise
all timers will be stopped.
</p>
);
}

View File

@@ -1 +0,0 @@
export { Timer } from './timer';

View File

@@ -1,127 +0,0 @@
.timer {
position: relative;
padding: 8px;
overflow: hidden;
background-color: var(--color-neutral-100);
border: 1px solid var(--color-neutral-200);
border-radius: 8px;
&:not(:last-of-type) {
margin-bottom: 24px;
}
& .header {
position: relative;
top: -8px;
width: 100%;
& .bar {
height: 2px;
margin: 0 -8px;
background-color: var(--color-neutral-200);
& .completed {
height: 100%;
background-color: var(--color-neutral-500);
transition: 0.2s;
}
}
}
& .footer {
display: flex;
column-gap: 4px;
align-items: center;
& .control {
display: flex;
flex-grow: 1;
column-gap: 4px;
align-items: center;
height: 40px;
padding: 4px;
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 4px;
& .input {
flex-grow: 1;
width: 100%;
min-width: 0;
height: 100%;
padding: 0 8px;
color: var(--color-foreground-subtle);
background-color: transparent;
border: none;
border-radius: 4px;
outline: none;
&.finished {
text-decoration: line-through;
}
}
& .button {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
aspect-ratio: 1 / 1;
color: var(--color-foreground);
cursor: pointer;
background-color: var(--color-neutral-200);
border: 1px solid var(--color-neutral-300);
border-radius: 2px;
outline: none;
transition: 0.2s;
&.reset {
background-color: var(--color-neutral-100);
border: none;
}
&:disabled,
&.disabled {
cursor: not-allowed;
opacity: 0.6;
}
}
}
& .delete {
display: flex;
align-items: center;
justify-content: center;
width: 38px;
min-width: 38px;
height: 38px;
color: #f43f5e;
cursor: pointer;
background-color: rgb(244 63 94 / 10%);
border: none;
border-radius: 4px;
outline: none;
transition: 0.2s;
&.disabled {
cursor: not-allowed;
opacity: 0.6;
}
}
}
& .left {
display: flex;
align-items: center;
justify-content: center;
height: 120px;
font-family: var(--font-mono);
font-size: var(--font-2xlg);
font-weight: 700;
cursor: pointer;
& span {
color: var(--color-foreground-subtle);
}
}
}

View File

@@ -1,222 +0,0 @@
import { useRef, useMemo, useState, useEffect } from 'react';
import {
IoPlay,
IoPause,
IoRefresh,
IoTrashOutline,
} from 'react-icons/io5/index';
import { Toolbar } from './toolbar';
import { useCountdownTimers } from '@/stores/countdown-timers';
import { useAlarm } from '@/hooks/use-alarm';
import { useSnackbar } from '@/contexts/snackbar';
import { padNumber } from '@/helpers/number';
import { cn } from '@/helpers/styles';
import styles from './timer.module.css';
interface TimerProps {
enableAnimations: (enabled: boolean) => void;
id: string;
}
export function Timer({ enableAnimations, id }: TimerProps) {
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
const lastActiveTimeRef = useRef<number | null>(null);
const lastStateRef = useRef<{ spent: number; total: number } | null>(null);
const [isRunning, setIsRunning] = useState(false);
const { first, last, name, spent, total } = useCountdownTimers(state =>
state.getTimer(id),
);
const tick = useCountdownTimers(state => state.tick);
const rename = useCountdownTimers(state => state.rename);
const reset = useCountdownTimers(state => state.reset);
const deleteTimer = useCountdownTimers(state => state.delete);
const left = useMemo(() => total - spent, [total, spent]);
const hours = useMemo(() => Math.floor(left / 3600), [left]);
const minutes = useMemo(() => Math.floor((left % 3600) / 60), [left]);
const seconds = useMemo(() => left % 60, [left]);
const [isReversed, setIsReversed] = useState(false);
const spentHours = useMemo(() => Math.floor(spent / 3600), [spent]);
const spentMinutes = useMemo(() => Math.floor((spent % 3600) / 60), [spent]);
const spentSeconds = useMemo(() => spent % 60, [spent]);
const playAlarm = useAlarm();
const showSnackbar = useSnackbar();
const handleStart = () => {
if (left > 0) setIsRunning(true);
};
const handlePause = () => setIsRunning(false);
const handleToggle = () => {
if (isRunning) handlePause();
else handleStart();
};
const handleReset = () => {
if (spent === 0) return;
if (isRunning) return showSnackbar('Please first stop the timer.');
setIsRunning(false);
reset(id);
};
const handleDelete = () => {
if (isRunning) return showSnackbar('Please first stop the timer.');
enableAnimations(false);
deleteTimer(id);
setTimeout(() => enableAnimations(true), 100);
};
useEffect(() => {
if (isRunning) {
if (intervalRef.current) clearInterval(intervalRef.current);
intervalRef.current = setInterval(() => tick(id), 1000);
}
return () => {
if (intervalRef.current) clearInterval(intervalRef.current);
};
}, [isRunning, tick, id]);
useEffect(() => {
if (left === 0 && isRunning) {
setIsRunning(false);
playAlarm();
if (intervalRef.current) clearInterval(intervalRef.current);
}
}, [left, isRunning, playAlarm]);
useEffect(() => {
const handleBlur = () => {
if (isRunning) {
lastActiveTimeRef.current = Date.now();
lastStateRef.current = { spent, total };
}
};
const handleFocus = () => {
if (isRunning && lastActiveTimeRef.current && lastStateRef.current) {
const elapsed = Math.floor(
(Date.now() - lastActiveTimeRef.current) / 1000,
);
const previousLeft =
lastStateRef.current.total - lastStateRef.current.spent;
const currentLeft = left;
const correctedLeft = previousLeft - elapsed;
if (correctedLeft < currentLeft) {
tick(id, currentLeft - correctedLeft);
}
lastActiveTimeRef.current = null;
lastStateRef.current = null;
}
};
window.addEventListener('blur', handleBlur);
window.addEventListener('focus', handleFocus);
return () => {
window.removeEventListener('blur', handleBlur);
window.removeEventListener('focus', handleFocus);
};
}, [isRunning, tick, id, spent, total, left]);
return (
<div className={styles.timer} id={`timer-${id}`}>
<header className={styles.header}>
<div className={styles.bar}>
<div
className={styles.completed}
style={{ width: `${(left / total) * 100}%` }}
/>
</div>
</header>
<Toolbar first={first} id={id} last={last} />
<div
className={styles.left}
tabIndex={0}
onClick={() => setIsReversed(prev => !prev)}
onKeyDown={() => setIsReversed(prev => !prev)}
>
{!isReversed ? (
<>
{padNumber(hours)}
<span>:</span>
{padNumber(minutes)}
<span>:</span>
{padNumber(seconds)}
</>
) : (
<>
<span>-</span>
{padNumber(spentHours)}
<span>:</span>
{padNumber(spentMinutes)}
<span>:</span>
{padNumber(spentSeconds)}
</>
)}
</div>
<footer className={styles.footer}>
<div className={styles.control}>
<input
className={cn(styles.input, left === 0 && styles.finished)}
placeholder="Untitled"
type="text"
value={name}
onChange={e => rename(id, e.target.value)}
/>
<button
aria-disabled={isRunning || spent === 0}
className={cn(
styles.button,
styles.reset,
(isRunning || spent === 0) && styles.disabled,
)}
onClick={handleReset}
>
<IoRefresh />
</button>
<button
className={styles.button}
disabled={!isRunning && left === 0}
onClick={handleToggle}
>
{isRunning ? <IoPause /> : <IoPlay />}
</button>
</div>
<button
aria-disabled={isRunning}
className={cn(styles.delete, isRunning && styles.disabled)}
onClick={handleDelete}
>
<IoTrashOutline />
</button>
</footer>
</div>
);
}

View File

@@ -1 +0,0 @@
export { Toolbar } from './toolbar';

View File

@@ -1,37 +0,0 @@
.toolbar {
position: absolute;
top: 12px;
right: 12px;
display: flex;
column-gap: 4px;
align-items: center;
height: 30px;
padding: 4px;
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 4px;
& button {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
aspect-ratio: 1 / 1;
font-size: var(--font-xsm);
color: var(--color-foreground-subtle);
cursor: pointer;
background-color: transparent;
border: none;
transition: 0.2s;
&:disabled {
cursor: not-allowed;
opacity: 0.2;
}
&:not(:disabled):hover {
color: var(--color-foreground);
background-color: var(--color-neutral-100);
}
}
}

View File

@@ -1,39 +0,0 @@
import { IoIosArrowDown, IoIosArrowUp } from 'react-icons/io/index';
import { useCountdownTimers } from '@/stores/countdown-timers';
import styles from './toolbar.module.css';
interface ToolbarProps {
first: boolean;
id: string;
last: boolean;
}
export function Toolbar({ first, id, last }: ToolbarProps) {
const moveUp = useCountdownTimers(state => state.moveUp);
const moveDown = useCountdownTimers(state => state.moveDown);
return (
<div className={styles.toolbar}>
<button
disabled={first}
onClick={e => {
e.stopPropagation();
moveUp(id);
}}
>
<IoIosArrowUp />
</button>
<button
disabled={last}
onClick={e => {
e.stopPropagation();
moveDown(id);
}}
>
<IoIosArrowDown />
</button>
</div>
);
}

View File

@@ -1,28 +0,0 @@
.timers {
margin-top: 48px;
& > header {
display: flex;
column-gap: 12px;
align-items: center;
margin-bottom: 16px;
& .title {
font-family: var(--font-heading);
font-size: var(--font-md);
font-weight: 600;
line-height: 1;
}
& .line {
flex-grow: 1;
height: 0;
border-top: 1px dashed var(--color-neutral-200);
}
& .spent {
font-size: var(--font-sm);
color: var(--color-foreground-subtle);
}
}
}

View File

@@ -1,55 +0,0 @@
import { useMemo, forwardRef } from 'react';
import { Timer } from './timer';
import { Notice } from './notice';
import { useCountdownTimers } from '@/stores/countdown-timers';
import styles from './timers.module.css';
interface TimersProps {
enableAnimations: (enabled: boolean) => void;
}
export const Timers = forwardRef(function Timers(
{ enableAnimations }: TimersProps,
ref: React.ForwardedRef<HTMLDivElement>,
) {
const timers = useCountdownTimers(state => state.timers);
const spent = useCountdownTimers(state => state.spent());
const total = useCountdownTimers(state => state.total());
const spentMinutes = useMemo(() => Math.floor(spent / 60), [spent]);
const totalMinutes = useMemo(() => Math.floor(total / 60), [total]);
return (
<div>
{timers.length > 0 ? (
<div className={styles.timers}>
<header>
<h2 className={styles.title}>Timers</h2>
<div className={styles.line} />
{totalMinutes > 0 && (
<p className={styles.spent}>
{spentMinutes} / {totalMinutes} Minute
{totalMinutes !== 1 && 's'}
</p>
)}
</header>
<div ref={ref}>
{timers.map(timer => (
<Timer
enableAnimations={enableAnimations}
id={timer.id}
key={timer.id}
/>
))}
</div>
<Notice />
</div>
) : null}
</div>
);
});

View File

@@ -0,0 +1,128 @@
.header {
margin-bottom: 16px;
& .title {
margin-bottom: 8px;
font-family: var(--font-heading);
font-size: var(--font-md);
font-weight: 600;
}
& .desc {
color: var(--color-foreground-subtle);
}
}
.formContainer {
& .inputContainer {
display: flex;
column-gap: 8px;
align-items: center;
& .input {
display: block;
flex-grow: 1;
min-width: 0;
height: 45px;
padding: 0 8px;
color: var(--color-foreground);
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 8px;
}
& span {
display: block;
}
}
}
.displayTime {
position: relative;
display: flex;
align-items: center;
justify-content: center;
height: 150px;
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 8px;
&::before {
position: absolute;
bottom: -1px;
left: 50%;
width: 80%;
height: 1px;
content: '';
background: linear-gradient(
90deg,
transparent,
var(--color-neutral-300),
transparent
);
transform: translateX(-50%);
}
& span {
font-size: var(--font-xlg);
font-weight: 600;
}
& .reverse {
position: absolute;
top: 4px;
left: 4px;
padding: 4px 12px;
font-size: var(--font-xsm);
color: var(--color-foreground-subtle);
background: linear-gradient(
var(--color-neutral-100),
var(--color-neutral-50)
);
border: 1px solid var(--color-neutral-200);
border-radius: 4px;
}
}
.buttonContainer {
display: flex;
column-gap: 8px;
align-items: center;
justify-content: flex-end;
margin-top: 12px;
& .button {
padding: 12px 16px;
font-family: var(--font-heading);
font-size: var(--font-sm);
font-weight: 600;
color: var(--color-foreground-subtle);
cursor: pointer;
background-color: var(--color-neutral-200);
border: none;
border-radius: 4px;
outline: none;
transition: 0.2s;
&:focus-visible {
outline: 2px solid var(--color-neutral-400);
outline-offset: 2px;
}
&:hover,
&:focus-visible {
color: var(--color-foreground);
background-color: var(--color-neutral-300);
}
&.primary {
color: var(--color-neutral-200);
background-color: var(--color-neutral-950);
&:hover,
&:focus-visible {
background-color: var(--color-neutral-800);
}
}
}
}

View File

@@ -0,0 +1,148 @@
import { useState, useEffect, useCallback } from 'react';
import { Modal } from '@/components/modal';
import { useSoundEffect } from '@/hooks/use-sound-effect';
import { cn } from '@/helpers/styles';
import { padNumber } from '@/helpers/number';
import styles from './countdown.module.css';
interface CountdownProps {
onClose: () => void;
show: boolean;
}
export function Countdown({ onClose, show }: CountdownProps) {
const [hours, setHours] = useState(0);
const [minutes, setMinutes] = useState(0);
const [seconds, setSeconds] = useState(0);
const [timeLeft, setTimeLeft] = useState(0);
const [initialTime, setInitialTime] = useState(0);
const [isActive, setIsActive] = useState(false);
const [isFormVisible, setIsFormVisible] = useState(true);
const alarm = useSoundEffect('/sounds/alarm.mp3');
useEffect(() => {
let timer: NodeJS.Timeout;
if (isActive && timeLeft > 0) {
timer = setTimeout(() => setTimeLeft(timeLeft - 1), 1000);
} else if (timeLeft === 0 && isActive) {
alarm.play();
setIsActive(false);
setIsFormVisible(true);
}
return () => clearTimeout(timer);
}, [isActive, timeLeft, alarm]);
const handleStart = useCallback(() => {
if (hours > 0 || minutes > 0 || seconds > 0) {
const totalTime =
(hours || 0) * 3600 + (minutes || 0) * 60 + (seconds || 0);
setTimeLeft(totalTime);
setInitialTime(totalTime);
setIsActive(true);
setIsFormVisible(false);
}
}, [hours, minutes, seconds]);
const handleBack = useCallback(() => {
setIsActive(false);
setIsFormVisible(true);
setTimeLeft(0);
}, []);
const toggleTimer = useCallback(() => {
setIsActive(prev => !prev);
}, []);
const formatTime = useCallback((time: number) => {
const hrs = Math.floor(time / 3600);
const mins = Math.floor((time % 3600) / 60);
const secs = time % 60;
return `${padNumber(hrs)}:${padNumber(mins)}:${padNumber(secs)}`;
}, []);
const elapsedTime = initialTime - timeLeft;
return (
<Modal show={show} onClose={onClose}>
<header className={styles.header}>
<h2 className={styles.title}>Countdown Timer</h2>
<p className={styles.desc}>Super simple countdown timer.</p>
</header>
{isFormVisible ? (
<div className={styles.formContainer}>
<div className={styles.inputContainer}>
<input
className={styles.input}
placeholder="HH"
type="number"
value={hours}
onChange={e => setHours(Math.max(0, parseInt(e.target.value)))}
/>
<span>:</span>
<input
className={styles.input}
placeholder="MM"
type="number"
value={minutes}
onChange={e =>
setMinutes(Math.max(0, Math.min(59, parseInt(e.target.value))))
}
/>
<span>:</span>
<input
className={styles.input}
placeholder="SS"
type="number"
value={seconds}
onChange={e =>
setSeconds(Math.max(0, Math.min(59, parseInt(e.target.value))))
}
/>
</div>
<div className={styles.buttonContainer}>
<button
className={cn(styles.button, styles.primary)}
onClick={handleStart}
>
Start
</button>
</div>
</div>
) : (
<div className={styles.timerContainer}>
<div className={styles.displayTime}>
<p className={styles.reverse}>- {formatTime(elapsedTime)}</p>
<span>{formatTime(timeLeft)}</span>
</div>
<div className={styles.buttonContainer}>
<button className={styles.button} onClick={handleBack}>
Back
</button>
<button
className={cn(styles.button, styles.primary)}
onClick={toggleTimer}
>
{isActive ? 'Pause' : 'Start'}
</button>
</div>
</div>
)}
</Modal>
);
}

View File

@@ -0,0 +1 @@
export { Countdown } from './countdown';

View File

@@ -1,4 +1,4 @@
export { Notepad } from './notepad';
export { Pomodoro } from './pomodoro';
export { CountdownTimer } from './countdown-timer';
export { BreathingExercise } from './breathing';
export { Todo } from './todo';
export { Countdown } from './countdown';

View File

@@ -0,0 +1,35 @@
.wrapper {
display: flex;
align-items: center;
height: 45px;
padding: 4px;
margin-top: 12px;
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 8px;
& input {
flex-grow: 1;
min-width: 0;
height: 100%;
padding: 0 8px;
color: var(--color-foreground);
background-color: transparent;
border: none;
outline: none;
}
& button {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
padding: 0 16px;
font-size: var(--font-sm);
color: var(--color-foreground);
cursor: pointer;
background-color: var(--color-neutral-100);
border: 1px solid var(--color-neutral-200);
border-radius: 4px;
}
}

View File

@@ -0,0 +1,33 @@
import { useState } from 'react';
import { useTodoStore } from '@/stores/todo';
import styles from './form.module.css';
export function Form() {
const [value, setValue] = useState('');
const addTodo = useTodoStore(state => state.addTodo);
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (!value.trim().length) return;
addTodo(value);
setValue('');
};
return (
<form onSubmit={handleSubmit}>
<div className={styles.wrapper}>
<input
type="text"
value={value}
onChange={e => setValue(e.target.value)}
/>
<button type="submit">Add</button>
</div>
</form>
);
}

View File

@@ -0,0 +1 @@
export { Todo } from './todo';

View File

@@ -0,0 +1 @@
/* WIP */

View File

@@ -0,0 +1,20 @@
import { Modal } from '@/components/modal';
import { Form } from './form';
import { Todos } from './todos';
import styles from './todo.module.css';
interface TodoProps {
onClose: () => void;
show: boolean;
}
export function Todo({ onClose, show }: TodoProps) {
return (
<Modal show={show} onClose={onClose}>
<h2 className={styles.title}>Todos</h2>
<Form />
<Todos />
</Modal>
);
}

View File

@@ -0,0 +1 @@
export { Todos } from './todos';

View File

@@ -0,0 +1 @@
export { Todo } from './todo';

View File

@@ -0,0 +1,45 @@
.wrapper {
display: flex;
column-gap: 4px;
align-items: center;
height: 45px;
padding: 4px;
margin-top: 12px;
background-color: var(--color-neutral-50);
border: 1px solid var(--color-neutral-200);
border-radius: 8px;
& .checkbox {
display: block;
margin: 0 8px 0 4px;
}
& .textbox {
flex-grow: 1;
min-width: 0;
height: 100%;
font-size: var(--font-sm);
color: var(--color-foreground);
background-color: transparent;
border: none;
outline: none;
&.done {
color: var(--color-foreground-subtle);
text-decoration: line-through;
}
}
& button {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
aspect-ratio: 1 / 1;
color: #f43f5e;
cursor: pointer;
background-color: rgb(244 63 94 / 15%);
border: none;
border-radius: 4px;
}
}

View File

@@ -0,0 +1,41 @@
import { FaRegTrashAlt } from 'react-icons/fa/index';
import { useTodoStore } from '@/stores/todo';
import { cn } from '@/helpers/styles';
import styles from './todo.module.css';
interface TodoProps {
done: boolean;
id: string;
todo: string;
}
export function Todo({ done, id, todo }: TodoProps) {
const deleteTodo = useTodoStore(state => state.deleteTodo);
const toggleTodo = useTodoStore(state => state.toggleTodo);
const editTodo = useTodoStore(state => state.editTodo);
const handleCheck = () => toggleTodo(id);
const handleDelete = () => deleteTodo(id);
return (
<div className={styles.wrapper}>
<input
checked={done}
className={styles.checkbox}
type="checkbox"
onChange={handleCheck}
/>
<input
className={cn(styles.textbox, done && styles.done)}
type="text"
value={todo}
onChange={e => editTodo(id, e.target.value)}
/>
<button onClick={handleDelete}>
<FaRegTrashAlt />
</button>
</div>
);
}

View File

@@ -0,0 +1 @@
/* WIP */

View File

@@ -0,0 +1,17 @@
import { Todo } from './todo';
import { useTodoStore } from '@/stores/todo';
import styles from './todos.module.css';
export function Todos() {
const todos = useTodoStore(state => state.todos);
return (
<div className={styles.todos}>
{todos.map(todo => (
<Todo done={todo.done} id={todo.id} key={todo.id} todo={todo.todo} />
))}
</div>
);
}

9
src/helpers/binary.ts Normal file
View File

@@ -0,0 +1,9 @@
export function generateRandomBinaryString(length: number) {
let binaryString = '';
for (let i = 0; i < length; i++) {
binaryString += Math.floor(Math.random() * 2);
}
return binaryString;
}

View File

@@ -1,24 +0,0 @@
import { useCallback } from 'react';
import { useSound } from './use-sound';
import { useAlarmStore } from '@/stores/alarm';
export function useAlarm() {
const { play: playSound } = useSound(
'/sounds/alarm.mp3',
{ volume: 1 },
true,
);
const isPlaying = useAlarmStore(state => state.isPlaying);
const play = useAlarmStore(state => state.play);
const stop = useAlarmStore(state => state.stop);
const playAlarm = useCallback(() => {
if (!isPlaying) {
playSound(stop);
play();
}
}, [isPlaying, playSound, play, stop]);
return playAlarm;
}

View File

@@ -1,19 +0,0 @@
import { create } from 'zustand';
interface AlarmStore {
isPlaying: boolean;
play: () => void;
stop: () => void;
}
export const useAlarmStore = create<AlarmStore>()(set => ({
isPlaying: false,
play() {
set({ isPlaying: true });
},
stop() {
set({ isPlaying: false });
},
}));

View File

@@ -1,159 +0,0 @@
import { v4 as uuid } from 'uuid';
import { create } from 'zustand';
import { createJSONStorage, persist } from 'zustand/middleware';
interface Timer {
id: string;
name: string;
spent: number;
total: number;
}
interface State {
spent: () => number;
timers: Array<Timer>;
total: () => number;
}
interface Actions {
add: (timer: { name: string; total: number }) => string;
delete: (id: string) => void;
getTimer: (id: string) => Timer & { first: boolean; last: boolean };
moveDown: (id: string) => void;
moveUp: (id: string) => void;
rename: (id: string, newName: string) => void;
reset: (id: string) => void;
tick: (id: string, amount?: number) => void;
}
export const useCountdownTimers = create<State & Actions>()(
persist(
(set, get) => ({
add({ name, total }) {
const id = uuid();
set(state => ({
timers: [
{
id,
name,
spent: 0,
total,
},
...state.timers,
],
}));
return id;
},
delete(id) {
set(state => ({
timers: state.timers.filter(timer => timer.id !== id),
}));
},
getTimer(id) {
const timers = get().timers;
const timer = timers.filter(timer => timer.id === id)[0];
const index = timers.indexOf(timer);
return {
...timer,
first: index === 0,
last: index === timers.length - 1,
};
},
moveDown(id) {
set(state => {
const index = state.timers.findIndex(timer => timer.id === id);
if (index < state.timers.length - 1) {
const newTimers = [...state.timers];
[newTimers[index + 1], newTimers[index]] = [
newTimers[index],
newTimers[index + 1],
];
return { timers: newTimers };
}
return state;
});
},
moveUp(id) {
set(state => {
const index = state.timers.findIndex(timer => timer.id === id);
if (index > 0) {
const newTimers = [...state.timers];
[newTimers[index - 1], newTimers[index]] = [
newTimers[index],
newTimers[index - 1],
];
return { timers: newTimers };
}
return state;
});
},
rename(id, newName) {
set(state => ({
timers: state.timers.map(timer => {
if (timer.id !== id) return timer;
return { ...timer, name: newName };
}),
}));
},
reset(id) {
set(state => ({
timers: state.timers.map(timer => {
if (timer.id !== id) return timer;
return { ...timer, spent: 0 };
}),
}));
},
spent() {
return get().timers.reduce((prev, curr) => prev + curr.spent, 0);
},
tick(id, amount = 1) {
set(state => ({
timers: state.timers.map(timer => {
if (timer.id !== id) return timer;
const updatedSpent =
timer.spent + amount > timer.total
? timer.total
: timer.spent + amount;
return { ...timer, spent: updatedSpent };
}),
}));
},
timers: [],
total() {
return get().timers.reduce((prev, curr) => prev + curr.total, 0);
},
}),
{
name: 'moodist-countdown-timers',
partialize: state => ({ timers: state.timers }),
skipHydration: true,
storage: createJSONStorage(() => localStorage),
version: 0,
},
),
);

View File

@@ -40,32 +40,11 @@ export const usePresetStore = create<PresetStore>()(
{
merge: (persisted, current) =>
merge(current, persisted as Partial<PresetStore>),
migrate,
name: 'moodist-presets',
partialize: state => ({ presets: state.presets }),
skipHydration: true,
storage: createJSONStorage(() => localStorage),
version: 1,
version: 0,
},
),
);
function migrate(persistedState: unknown, version: number) {
let persisted = persistedState as Partial<PresetStore>;
/**
* In version 0, presets didn't have an ID
*/
if (version < 1) {
persisted = {
...persisted,
presets: (persisted.presets || []).map(preset => {
if (preset.id) return preset;
return { ...preset, id: uuid() };
}),
} as PresetStore;
}
return persisted as PresetStore;
}

81
src/stores/todo.ts Normal file
View File

@@ -0,0 +1,81 @@
import { create } from 'zustand';
import { createJSONStorage, persist } from 'zustand/middleware';
import merge from 'deepmerge';
import { v4 as uuid } from 'uuid';
interface TodoStore {
addTodo: (todo: string) => void;
deleteTodo: (id: string) => void;
editTodo: (id: string, newTodo: string) => void;
todos: Array<{
createdAt: number;
done: boolean;
id: string;
todo: string;
}>;
toggleTodo: (id: string) => void;
}
export const useTodoStore = create<TodoStore>()(
persist(
(set, get) => ({
addTodo(todo) {
set({
todos: [
{
createdAt: Date.now(),
done: false,
id: uuid(),
todo,
},
...get().todos,
],
});
},
deleteTodo(id) {
set({
todos: get().todos.filter(todo => todo.id !== id),
});
},
editTodo(id, newTodo) {
set({
todos: get().todos.map(todo => {
if (todo.id !== id) return todo;
return {
...todo,
todo: newTodo,
};
}),
});
},
todos: [],
toggleTodo(id) {
set({
todos: get().todos.map(todo => {
if (todo.id !== id) return todo;
return {
...todo,
done: !todo.done,
};
}),
});
},
}),
{
merge: (persisted, current) =>
merge(current, persisted as Partial<TodoStore>),
name: 'moodist-todos',
partialize: state => ({ todos: state.todos }),
skipHydration: true,
storage: createJSONStorage(() => localStorage),
version: 0,
},
),
);

View File

@@ -16,6 +16,9 @@ body {
font-size: var(--font-base);
color: var(--color-foreground);
background-color: var(--color-neutral-50);
/* Workaround for modal and scrollbar layout shifts */
width: 100vw;
overflow-x: hidden;
}
::selection {