Skip to content

Commit

Permalink
fix: sx utils
Browse files Browse the repository at this point in the history
  • Loading branch information
syfxlin committed Aug 14, 2023
1 parent 4ad46bb commit 39a0fdb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"homepage": "https://github.com/syfxlin/reve#readme",
"dependencies": {
"@vanilla-extract/css-utils": "^0.1.3",
"@vanilla-extract/dynamic": "^2.0.3",
"clsx": "^2.0.0",
"stylis": "^4.3.0"
},
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "./theme";
export * from "./utils/calc";
export * from "./utils/cx";
export * from "./utils/sx";
export * from "./utils/dynamic.ts";
1 change: 1 addition & 0 deletions src/utils/dynamic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "@vanilla-extract/dynamic";
4 changes: 3 additions & 1 deletion src/utils/sx.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { CSSProperties } from "react";
import { assignInlineVars } from "@vanilla-extract/dynamic";

export function sx(...values: Array<CSSProperties | Record<string, any> | boolean | null | undefined>) {
let results: CSSProperties = {};
for (const value of values) {
if (value === null || value === undefined || typeof value === "boolean") {
continue;
}
results = { ...results, ...value };
// @ts-ignore
results = { ...results, ...assignInlineVars(value) };
}
return results;
}

0 comments on commit 39a0fdb

Please sign in to comment.