effcss
Version:
Self-confident CSS-in-JS
50 lines (49 loc) • 1.33 kB
TypeScript
import { TScope } from './scope';
type TThemeParams<T extends object> = Partial<T> & {
$light?: Partial<T>;
$dark?: Partial<T>;
};
type TThemeAction = {
type: 'delete';
payload: {
name: string;
};
} | {
type: 'update';
payload: {
params: object;
name?: string;
};
} | {
type: 'add';
payload: {
params: object;
name: string;
};
};
export type TThemeValue = {
[key in (string | number)]: string | number | boolean | TThemeValue;
};
export type TThemeController = {
get(name?: string): TThemeValue;
add(params: TThemeValue, name: string): void;
delete(name: string): void;
update(params: TThemeValue, name?: string): void;
switch(name?: string): void;
vars<T extends object = object>(theme?: string): TThemeParams<T>;
get list(): string[];
get current(): string | '';
get all(): Record<string, object>;
get actions(): TThemeAction[];
};
export declare const createThemeController: ({ provider, init, scope, onChange }: {
provider: {
getAttribute(name: string): string | null;
removeAttribute(name: string): void;
setAttribute(name: string, value: string): void;
};
init?: TThemeAction[];
onChange: () => void;
scope: TScope;
}) => TThemeController;
export {};