@weser/styling 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { CSSProperties } from 'react';
|
|
2
1
|
import { createHooks as baseCreateHooks } from '@css-hooks/react';
|
|
3
2
|
import { WithHooks } from '@css-hooks/core';
|
|
4
3
|
import { assignStyle } from 'css-in-js-utils';
|
|
5
|
-
import { T_Fallback } from '../types.js';
|
|
4
|
+
import { T_Fallback, T_RawStyle } from '../types.js';
|
|
6
5
|
type Plugin<T> = (style: T) => T;
|
|
7
6
|
type HookOptions<Hooks extends string> = Parameters<typeof baseCreateHooks<Hooks>>[0];
|
|
8
7
|
type Config<T, Hooks extends string> = {
|
|
@@ -12,8 +11,8 @@ type Config<T, Hooks extends string> = {
|
|
|
12
11
|
mergeStyle?: typeof assignStyle;
|
|
13
12
|
};
|
|
14
13
|
type Properties<T, Hooks> = Array<Properties<T, Hooks>> | WithHooks<Hooks, T> | undefined;
|
|
15
|
-
type CSSFunction<T, Hooks> = (...style: Array<Properties<T, Hooks>>) =>
|
|
16
|
-
export default function createRenderer<Hooks extends Record<string, string>, T extends Record<string, any> =
|
|
14
|
+
type CSSFunction<T, Hooks> = (...style: Array<Properties<T, Hooks>>) => T_RawStyle;
|
|
15
|
+
export default function createRenderer<Hooks extends Record<string, string>, T extends Record<string, any> = T_RawStyle>({ hooks, fallbacks, plugins, mergeStyle, }: Config<T, keyof Hooks & string>): [
|
|
17
16
|
string,
|
|
18
17
|
CSSFunction<T, keyof Hooks & string>
|
|
19
18
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useCSSVariable(): [`--${string}`, string];
|
|
1
|
+
export default function useCSSVariable(fallbackValue?: string): [`--${string}`, string];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { useId } from 'react';
|
|
2
|
-
export default function useCSSVariable() {
|
|
2
|
+
export default function useCSSVariable(fallbackValue) {
|
|
3
3
|
const id = useId();
|
|
4
4
|
const name = id.replace(/:/g, '_');
|
|
5
|
-
|
|
5
|
+
const variable = `--${name}`;
|
|
6
|
+
if (fallbackValue) {
|
|
7
|
+
return [variable, `var(${variable}, ${fallbackValue})`];
|
|
8
|
+
}
|
|
9
|
+
return [variable, `var(${variable})`];
|
|
6
10
|
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weser/styling",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Utils for styling with CSS hooks",
|
|
5
5
|
"author": "Robin Weser <robin@weser.io>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"styles-debugger": "^1.0.0",
|
|
58
58
|
"typescript": "^5.9.2"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "6dd1ad00ab8dacea2878edc99085324ea5d03588"
|
|
61
61
|
}
|