Skip to content

Commit

Permalink
fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
KishiTheMechanic committed Oct 28, 2024
1 parent f24017e commit 64c8832
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elsoul/fresh-theme",
"version": "1.0.5",
"version": "1.1.0",
"description": "Theme Module for Fresh v2 App.",
"runtimes": ["deno", "browser"],
"exports": "./mod.ts",
Expand Down
13 changes: 10 additions & 3 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,21 @@ export function setTheme(newTheme: 'dark' | 'light'): void {
}
}

/**
* Type definition for the return value of the useTheme hook.
*/
type UseThemeReturn = {
theme: 'dark' | 'light'
setTheme: (newTheme: 'dark' | 'light') => void
}

/**
* Custom hook to manage the theme (light or dark) based on localStorage.
* Provides a function to set the theme and returns the current theme value.
*
* @returns {{ theme: 'dark' | 'light', setTheme: (newTheme: 'dark' | 'light') => void }}
* An object containing the current theme and a function to set the theme.
* @returns {UseThemeReturn} An object containing the current theme and a function to set the theme.
*/
export function useTheme() {
export function useTheme(): UseThemeReturn {
const theme = useSignal<'dark' | 'light'>(
(localStorage.getItem('theme') as 'dark' | 'light') || 'dark',
)
Expand Down

0 comments on commit 64c8832

Please sign in to comment.