@atlaskit/theme
Version:
Theme contains solutions for global theming, colors, and other useful mixins.
25 lines (24 loc) • 1.43 kB
TypeScript
import { type ComponentType, type ReactNode } from 'react';
type GetThemeTokensFn<ThemeTokens, ThemeProps> = (props: ThemeProps) => ThemeTokens;
type ThemeConsumerFn<ThemeTokens> = {
children: (tokens: ThemeTokens) => ReactNode;
};
export type ThemeProp<ThemeTokens, ThemeProps> = (getTokens: GetThemeTokensFn<ThemeTokens, ThemeProps>, themeProps: ThemeProps) => ThemeTokens;
/**
* createTheme is used to create a set of Providers and Consumers for theming components.
* - Takes a default theme function; this theme function gets a set of props, and returns tokens
* based on those props. An example of this default theme function is one that produces the standard
* appearance of the component
* - Returns three things - a Provider that allow for additional themes to be applied, a Consumer
* that can get the current theme and fetch it, and a custom hook - useTheme which provides an alternate (although functionally the same) API
* to the Consumer.
*/
export declare function createTheme<ThemeTokens, ThemeProps>(defaultGetTokens: GetThemeTokensFn<ThemeTokens, ThemeProps>): {
Consumer: ComponentType<ThemeProps extends void ? ThemeConsumerFn<ThemeTokens> : ThemeConsumerFn<ThemeTokens> & Omit<ThemeProps, 'children'>>;
Provider: ComponentType<{
children?: ReactNode;
value?: ThemeProp<ThemeTokens, ThemeProps>;
}>;
useTheme: GetThemeTokensFn<ThemeTokens, ThemeProps>;
};
export {};