Open VersorVerbi opened 1 day ago
Hi @VersorVerbi, Thanks for helping improve the project!
I checked your example in the original demo app with babel and the code does work without errors, but the second parameter does not affect or override the styles (I tried to move the styles from the example to a separate ButtonTokensOverride.stylex.ts
file).
//Theme file
// other code...
export const buttonTokensOverride = stylex.defineVars({
bgColor: "red",
textColor: "white",
cornerRadius: "4px",
paddingBlock: "4px",
paddingInline: "8px",
});
// other code...
//Component file
import * as stylex from "@stylexjs/stylex";
import { buttonTokens } from "./ButtonTokens.stylex";
import { buttonTokensOverride } from "./ButtonTokens2.stylex";
// other code...
const redTheme = stylex.createTheme(buttonTokens, buttonTokensOverride);
// other code...
It is similar to passing an empty object as the second parameter. So I am not sure that the error in this case is a bug.
In the official documentation (here and here) your case is not presented, only an object as the second argument.
PR #97 adds validation of function parameters stylex.createTheme
, I think that will be the right solution.
Describe the bug
One use-case for themes is to allow users to decide which theme they will use, including the base theme (default values as established in a
defineVars
call). As a matter of convenience, we should be able to reuse the same variables in acreateTheme
call. As of now, the Babel compiler allows this, e.g.,The workaround is to copy-paste the entire object from the
defineVars
call and then keep them in sync manually.Error stack
OS
Windows
Browser
No response
Compiler version
rs-compiler-win32-x64-msvc 0.4.1
Bundler plugin(s) version
0.4.1
To Reproduce
Define variables, then create a theme for those variables using the result of the
stylex.defineVars
call as the override theme (i.e., override a set of variables with itself).E.g., in Dwlad90/nextjs-app-dir-stylex, add this to ButtonsDemo.tsx:
Provide link to a repository with a minimal reproduction case.
No response
Additional information