UNPKG

remix-themes

Version:

An abstraction for themes in your Remix_run app.

45 lines (40 loc) 1.71 kB
import { SessionStorage, ActionFunction } from 'react-router'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { Dispatch, SetStateAction, ReactNode } from 'react'; declare enum Theme { DARK = "dark", LIGHT = "light" } declare const themes: Array<Theme>; type ThemeMetadata = { definedBy: "USER" | "SYSTEM"; }; type ThemeContextType = [ Theme | null, Dispatch<SetStateAction<Theme | null>>, ThemeMetadata ]; type ThemeProviderProps = { children: ReactNode; specifiedTheme: Theme | null; themeAction: string; disableTransitionOnThemeChange?: boolean; }; declare function ThemeProvider({ children, specifiedTheme, themeAction, disableTransitionOnThemeChange, }: ThemeProviderProps): react_jsx_runtime.JSX.Element; type PreventFlashOnWrongThemeProps = { ssrTheme: boolean; nonce?: string; }; declare function PreventFlashOnWrongTheme({ ssrTheme, nonce, }: PreventFlashOnWrongThemeProps): react_jsx_runtime.JSX.Element; declare function useTheme(): ThemeContextType; declare function isTheme(value: unknown): value is Theme; type ThemeSession = { getTheme: () => Theme | null; setTheme: (theme: Theme) => void; commit: () => Promise<string>; destroy: () => Promise<string>; }; type ThemeSessionResolver = (request: Request) => Promise<ThemeSession>; declare const createThemeSessionResolver: (cookieThemeSession: SessionStorage) => ThemeSessionResolver; declare const createThemeAction: (themeSessionResolver: ThemeSessionResolver) => ActionFunction; export { PreventFlashOnWrongTheme, Theme, type ThemeMetadata, ThemeProvider, type ThemeSessionResolver, createThemeAction, createThemeSessionResolver, isTheme, themes, useTheme };