UNPKG

@jad-mlb/react-modern-ui

Version:

A simple UI library for react with some simple UI elements

46 lines (45 loc) 1.87 kB
import React, { CSSProperties } from "react"; import { ThemeType } from "../types/theme"; import { Colour } from "../types"; type ThemeDispatchAction = { type: "set"; values: Partial<ThemeType>; } | { type: "reset"; }; type ThemeContextType = { theme: ThemeType; dispatch: React.Dispatch<ThemeDispatchAction>; }; /** * Theme provider to wrap the app components so they can use a theme and be displayed */ export declare function ThemeProvider({ children }: { children: React.ReactNode; }): import("@emotion/react/jsx-runtime").JSX.Element; /** * Gets the current theme and the dispatch function used to change it. * The dispatch function takes in: * - an object containing the key "type" set to "set" with an object representing a part of the theme or its entirity, or * - an object containing the key "type" set to "reset" and nothing else, used to reset the theme to the default one. * * @returns An object made of "theme" containing the value of the active theme, as well as a "dispatch" to set the theme */ export declare function useTheme(): ThemeContextType; /** * Gets which mode is being used, either dark mode, light mode or set to auto. The former 2 are meant to be fixed, while "auto" is meant to represent a mode that changes with the system, and thus is affected by it. * * @returns true if theme.mode is "dark", or "auto" and the system prefers dark mode, false otherwise */ export declare function useDarkMode(): boolean; /** * Used to get the colour based on its simplified name * @returns A function that takes the role and returns its hex value */ export declare function useThemeColours(): ThemeColourFunction; export type Style = CSSProperties & { [key: string]: any; }; export declare function useThemeParser(): (styles: Style) => Style; export type ThemeColourFunction = (col: Colour) => string; export {};