diff --git a/deno.json b/deno.json index 0e75931..b66ab39 100644 --- a/deno.json +++ b/deno.json @@ -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", diff --git a/mod.ts b/mod.ts index 59a73d1..f4a2530 100644 --- a/mod.ts +++ b/mod.ts @@ -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', )