@csszyx/vars 0.6.2 → 0.8.0
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.
- package/package.json +1 -1
- package/src/index.ts +1 -4
- package/src/react.ts +3 -1
- package/tsconfig.json +15 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -54,10 +54,7 @@ export function applySzVars(
|
|
|
54
54
|
* @param vars - Record of CSS var name → value. Keys auto-prefixed with `--`.
|
|
55
55
|
* @param element - Target element. Defaults to `document.documentElement` (`:root`).
|
|
56
56
|
*/
|
|
57
|
-
export function patchSzVars(
|
|
58
|
-
vars: SzVars,
|
|
59
|
-
element: HTMLElement = document.documentElement,
|
|
60
|
-
): void {
|
|
57
|
+
export function patchSzVars(vars: SzVars, element: HTMLElement = document.documentElement): void {
|
|
61
58
|
for (const [key, value] of Object.entries(vars)) {
|
|
62
59
|
const name = key.startsWith('--') ? key : `--${key}`;
|
|
63
60
|
element.style.setProperty(name, String(value));
|
package/src/react.ts
CHANGED
|
@@ -26,7 +26,9 @@ export function useSzVars(vars: SzVars, ref?: RefObject<HTMLElement | null>): vo
|
|
|
26
26
|
|
|
27
27
|
useEffect(() => {
|
|
28
28
|
const el = ref?.current ?? document.documentElement;
|
|
29
|
-
if (!el) {
|
|
29
|
+
if (!el) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
30
32
|
patchSzVars(latestVars.current, el);
|
|
31
33
|
});
|
|
32
34
|
// No dep array — runs after every render, intentional:
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"composite": true,
|
|
5
|
+
"incremental": true,
|
|
6
|
+
"isolatedDeclarations": true,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo",
|
|
9
|
+
"outDir": "./dist",
|
|
10
|
+
"rootDir": "./src",
|
|
11
|
+
"types": ["node", "react"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"],
|
|
14
|
+
"exclude": ["node_modules", "dist"]
|
|
15
|
+
}
|