Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pistonite/celera",
"version": "0.1.3",
"version": "0.1.4",
"type": "module",
"private": true,
"description": "In-house UI framework",
Expand Down
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ export {
type DisplayModeOptions,
} from "#pref";

export { gale, GALE_BUILTIN_STYLES, injectStyle, ThemeProvider } from "#style";
export {
gale,
GALE_BUILTIN_STYLES,
injectStyle,
ThemeProvider,
type GaleEngine,
type GaleKeys,
type GaleHook,
type GaleFn,
type GaleString,
} from "#style";

import { log } from "#util";
export { log as celeraLogger };
21 changes: 16 additions & 5 deletions src/style/gale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,25 @@ export const gale = <T extends string>(
return Object.assign(useStyleEngine, { extend: makeComponentLevelStyleEngine });
};

type GaleKeys<T extends string> = T | GaleBuiltinKey;
interface GaleEngine<T extends string> extends GaleHook<T> {
/**
* Engine function created by {@link gale}
*
* Can either be used as a hook to get the `m` function, or use `.extend()`
* to extend the styles for component-specific hook.
*/
export interface GaleEngine<T extends string> extends GaleHook<T> {
/** Extend the styles to get a component-specific hook */
extend: <K extends string>(componentStyles: Record<K, GriffelStyle>) => GaleHook<K | T>;
}
type GaleHook<T extends string> = () => GaleFn<T>;
type GaleFn<T extends string> = <K extends string>(classes: GaleString<K, T>) => string;
/** Wrapper to concatenate built-in style keys with project-specific style keys */
export type GaleKeys<T extends string> = T | GaleBuiltinKey;
/** Hook to be called inside a component to get the `m` function. See {@link gale} */
export type GaleHook<T extends string> = () => GaleFn<T>;
/** The `m` function that turns a style string into class names */
export type GaleFn<T extends string> = <K extends string>(classes: GaleString<K, T>) => string;

type GaleString<K extends string, T extends string> = K extends T
/** Type-safe, space-separated style idents */
export type GaleString<K extends string, T extends string> = K extends T
? K
: K extends `${infer U} ${infer N}`
? U extends T
Expand Down
Loading