From b5e3a91e0a616173bee73b0670ebbe13d637ec47 Mon Sep 17 00:00:00 2001 From: harshit69x Date: Thu, 3 Oct 2024 15:52:00 +0530 Subject: [PATCH 1/3] Fixed the darkmode bug --- src/lib/components/MenuBar.svelte | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/components/MenuBar.svelte b/src/lib/components/MenuBar.svelte index 3c01057..7fed60c 100644 --- a/src/lib/components/MenuBar.svelte +++ b/src/lib/components/MenuBar.svelte @@ -3,11 +3,20 @@ import EditorTitle from '@/components/EditorTitle.svelte'; import { Notpad } from '@/helpers/notpad'; import { editors } from '@/store'; - import { toggleMode } from 'mode-watcher'; import { fade } from 'svelte/transition'; import { isTauri } from '$lib'; import screenfull from 'screenfull'; + let isDarkMode = false; // Track the current theme state + + function toggleMode() { + isDarkMode = !isDarkMode; + document.body.classList.toggle('dark-theme'); + + // Update the label dynamically + menuItems[3].items[5].label = isDarkMode ? 'Light Mode' : 'Dark Mode'; + } + interface MenuItems { label: string; items: Item[]; @@ -29,7 +38,6 @@ shortcut: isTauri ? 'Ctrl+N' : 'Ctrl+Alt+N', onClick: Notpad.editors.createNew }, - { label: 'Open...', shortcut: 'Ctrl+O', onClick: Notpad.fileOptions.open }, { label: 'Save', @@ -37,7 +45,6 @@ onClick: Notpad.fileOptions.save }, { label: 'Save as...', onClick: () => Notpad.fileOptions.save({ saveAs: true }) }, - { type: 'separator' }, { label: 'Print', shortcut: 'Ctrl+P', onClick: Notpad.editors.printActive }, { type: 'separator' }, @@ -82,7 +89,7 @@ shortcut: 'F11', onClick: () => screenfull.toggle() }, - { label: 'Dark Mode', onClick: toggleMode } + { label: 'Dark Mode', onClick: toggleMode } // The label here will change dynamically ] }, { @@ -94,10 +101,6 @@ let innerWidth = window.innerWidth; $: isXS = innerWidth <= 450; - /** - * Compact mode is disabled on mobile devices (width <= 450px) - * and on PCs when multiple editors are open. - */ $: tabsMode = $editors.length > 1; $: singleEditor = $editors.at(0)!; From 9f4968bd005888939b27c08ddad8443e39f4bf81 Mon Sep 17 00:00:00 2001 From: Muhammed-Rahif Date: Thu, 3 Oct 2024 21:06:06 +0530 Subject: [PATCH 2/3] fix(menubar): dark mode label is not dynamic closes #195 --- src/lib/components/MenuBar.svelte | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/lib/components/MenuBar.svelte b/src/lib/components/MenuBar.svelte index 7fed60c..5ac3232 100644 --- a/src/lib/components/MenuBar.svelte +++ b/src/lib/components/MenuBar.svelte @@ -6,16 +6,7 @@ import { fade } from 'svelte/transition'; import { isTauri } from '$lib'; import screenfull from 'screenfull'; - - let isDarkMode = false; // Track the current theme state - - function toggleMode() { - isDarkMode = !isDarkMode; - document.body.classList.toggle('dark-theme'); - - // Update the label dynamically - menuItems[3].items[5].label = isDarkMode ? 'Light Mode' : 'Dark Mode'; - } + import { toggleMode, mode } from 'mode-watcher'; interface MenuItems { label: string; @@ -89,7 +80,7 @@ shortcut: 'F11', onClick: () => screenfull.toggle() }, - { label: 'Dark Mode', onClick: toggleMode } // The label here will change dynamically + { label: 'mode', onClick: toggleMode } ] }, { @@ -103,6 +94,7 @@ $: isXS = innerWidth <= 450; $: tabsMode = $editors.length > 1; $: singleEditor = $editors.at(0)!; + $: modeLabel = $mode == 'dark' ? 'Light Mode' : 'Dark Mode'; @@ -117,7 +109,11 @@ {:else} - {label} + {#if label == 'mode'} + {modeLabel} + {:else} + {label} + {/if} {#if shortcut} {shortcut} {/if} From fe2aea45eb13a097e6dc1c6b8f0c31f18bf04d71 Mon Sep 17 00:00:00 2001 From: Muhammed-Rahif Date: Thu, 3 Oct 2024 21:29:47 +0530 Subject: [PATCH 3/3] chore(workflow): prettier fails on PRs --- .github/workflows/prettier.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 76f56ad..bb3e663 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -7,6 +7,8 @@ on: jobs: prettier: name: Prettify code + permissions: + contents: write runs-on: ubuntu-latest steps: - name: Checkout