-
-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #610 from addeeandra/feat/light-mode
Theme Switch: Dark & Light Mode
- Loading branch information
Showing
63 changed files
with
314 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const themeSwitch = () => ({ | ||
|
||
theme: 'dark', // default theme | ||
|
||
availableModes: ['dark', 'light'], // e.g. system | ||
|
||
modeIndex: 0, | ||
|
||
init() { | ||
const currentTheme = localStorage.getItem('theme') || this.theme | ||
|
||
this.modeIndex = this.availableModes.indexOf(currentTheme) | ||
|
||
this.setTheme(currentTheme) | ||
}, | ||
|
||
setTheme(theme) { | ||
this.theme = theme | ||
localStorage.setItem('theme', theme) | ||
|
||
if (theme === 'dark') { | ||
this.setDarkMode() | ||
return | ||
} | ||
|
||
if (theme === 'light') { | ||
this.setLightMode() | ||
return | ||
} | ||
|
||
this.setSystemMode() | ||
}, | ||
|
||
setLightMode() { | ||
document.documentElement.classList.remove('dark') | ||
document.documentElement.classList.add(this.theme) | ||
}, | ||
|
||
setDarkMode() { | ||
document.documentElement.classList.remove('light') | ||
document.documentElement.classList.add(this.theme) | ||
}, | ||
|
||
setSystemMode() { | ||
document.documentElement.classList.remove('dark', 'light') | ||
}, | ||
|
||
toggleTheme() { | ||
const newModeIndex = (this.modeIndex + 1) % this.availableModes.length | ||
|
||
this.modeIndex = newModeIndex | ||
this.setTheme(this.availableModes[newModeIndex]) | ||
}, | ||
|
||
toggleThemeButtonText() { | ||
return this.theme.charAt(0).toUpperCase() + this.theme.slice(1) | ||
} | ||
|
||
}) | ||
|
||
export { themeSwitch } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
@php | ||
/** @var \App\Services\Autocomplete\Result $result */ | ||
@endphp | ||
<span class="truncate text-sm font-medium text-slate-50"> | ||
<span class="truncate text-sm font-medium dark:text-slate-50 text-slate-950"> | ||
{{ $result->replacement }} | ||
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<input | ||
type="checkbox" | ||
{!! $attributes->merge(['class' => 'focus:ring-pink-500 focus:ring-offset-slate-900 size-4.5 text-pink-500 border-slate-800 bg-slate-900 ring-slate-900 rounded cursor-pointer']) !!} | ||
{!! $attributes->merge(['class' => 'focus:ring-pink-500 dark:focus:ring-offset-slate-900 focus:ring-offset-slate-200 size-4.5 text-pink-500 dark:border-slate-800 border-slate-200 dark:bg-slate-900 bg-slate-50 dark:ring-slate-900 ring-slate-200 rounded cursor-pointer dark:shadow-none shadow-md']) !!} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<button {{ $attributes->merge(['class' => 'block w-full px-4 py-2 text-start text-sm leading-5 text-slate-400 hover:bg-slate-800 transition duration-150 ease-in-out']) }}> | ||
<button {{ $attributes->merge(['class' => 'block w-full px-4 py-2 text-start text-sm leading-5 dark:text-slate-400 text-slate-600 dark:hover:bg-slate-800 hover:bg-slate-200 transition duration-150 ease-in-out']) }}> | ||
{{ $slot }} | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.