diff --git a/package.json b/package.json
index 4151788..e4399d4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@pistonite/celera",
- "version": "0.1.5",
+ "version": "0.2.0",
"type": "module",
"private": true,
"description": "In-house UI framework",
diff --git a/src/style/gale.ts b/src/style/gale.ts
index 0f32658..3a1b52c 100644
--- a/src/style/gale.ts
+++ b/src/style/gale.ts
@@ -46,9 +46,16 @@ import { log } from "#util";
* return
my component
;
* };
*
+ * const useStyles = useStyleEngine.extend({
+ * container: {
+ * // not shown
+ * }
+ * });
+ *
* export const MyComponent2 = () => {
* const m = useStyles(); // component-level style idents
- * return my component
;
+ * // note component-level styles are c- prefixed
+ * return my component
;
* };
*
* const useExtraStyles = makeStyles({
@@ -56,13 +63,6 @@ import { log } from "#util";
* overflow: "hidden"
* }
* });
- *
- * export const MyComponent3 = () => {
- * const m = useStyles(); // component-level style idents
- * // if needed (should be rare), you can interop with hooks from griffel
- * const c = useExtraStyles();
- * return my component
;
- * };
* ```
*
*/
@@ -107,9 +107,12 @@ export const gale = (
};
const makeComponentLevelStyleEngine = (
componentStyles: Record,
- ): GaleHook> => {
- const useComponentStyles = makeStyles(componentStyles);
- const useStyles = (): GaleFn> => {
+ ): GaleHook<`c-${K}` | GaleKeys> => {
+ const mappedComponentStyles = Object.fromEntries(
+ Object.entries(componentStyles).map(([k, v]) => ["c-" + k, v]),
+ ) as Record<`c-${K}`, GriffelStyle>;
+ const useComponentStyles = makeStyles(mappedComponentStyles);
+ const useStyles = (): GaleFn<`c-${K}` | GaleKeys> => {
// griffel makeStyles hook return cached stable reference
const projectStyles = useProjectLevelGriffelStyles();
let componentStylesToGaleStringCache = cache.get(projectStyles);
@@ -133,7 +136,7 @@ export const gale = (
classes,
);
};
- return mFunction as GaleFn>;
+ return mFunction as GaleFn<`c-${K}` | GaleKeys>;
};
return useStyles;
};
@@ -178,7 +181,7 @@ export const gale = (
*/
export interface GaleEngine extends GaleHook {
/** Extend the styles to get a component-specific hook */
- extend: (componentStyles: Record) => GaleHook;
+ extend: (componentStyles: Record) => GaleHook<`c-${K}` | T>;
}
/** Wrapper to concatenate built-in style keys with project-specific style keys */
export type GaleKeys = T | GaleBuiltinKey;