-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(stylex.create): preserve camelCased variable names when being ass…
…igned a value
- Loading branch information
Showing
14 changed files
with
120 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as stylex from '@stylexjs/stylex'; | ||
|
||
export const tokens = stylex.defineVars({ | ||
arrow_transform: 'translateX(0)', | ||
arrowTransform: 'translateX(0)', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as stylex from '@stylexjs/stylex'; | ||
|
||
export const tokens = stylex.defineVars({ | ||
arrow_transform: 'translateX(0)', | ||
arrowTransform: 'translateX(0)', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...ate_test/stylex_create_call_setting_vars.rs/preserves_camel_case_in_css_variable_names.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//__stylex_metadata_start__[{"class_name":"x1ujxqga","style":{"rtl":null,"ltr":".x1ujxqga{--myCustomVar:red}"},"priority":1},{"class_name":"x1g24lt9","style":{"rtl":null,"ltr":".x1g24lt9{--anotherCamelVar:10px}"},"priority":1}]__stylex_metadata_end__ | ||
import _inject from "@stylexjs/stylex/lib/stylex-inject"; | ||
var _inject2 = _inject; | ||
import stylex from 'stylex'; | ||
_inject2(".x1ujxqga{--myCustomVar:red}", 1); | ||
_inject2(".x1g24lt9{--anotherCamelVar:10px}", 1); |
11 changes: 11 additions & 0 deletions
11
...ate_test/stylex_create_call_setting_vars.rs/preserves_kebab_case_in_css_variable_names.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//__stylex_metadata_start__[{"class_name":"xgau0yw","style":{"rtl":null,"ltr":".xgau0yw{--background-color:red}"},"priority":1}]__stylex_metadata_end__ | ||
import _inject from "@stylexjs/stylex/lib/stylex-inject"; | ||
var _inject2 = _inject; | ||
import stylex from 'stylex'; | ||
_inject2(".xgau0yw{--background-color:red}", 1); | ||
export const styles = { | ||
default: { | ||
"--background-color": "xgau0yw", | ||
$$css: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
crates/stylex-shared/tests/stylex_transform_create_test/stylex_create_call_setting_vars.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use stylex_shared::{shared::structures::plugin_pass::PluginPass, StyleXTransform}; | ||
use swc_core::ecma::{ | ||
parser::{Syntax, TsSyntax}, | ||
transforms::testing::test, | ||
}; | ||
|
||
test!( | ||
Syntax::Typescript(TsSyntax { | ||
tsx: true, | ||
..Default::default() | ||
}), | ||
|tr| StyleXTransform::new_test_force_runtime_injection_with_pass( | ||
tr.comments.clone(), | ||
PluginPass::default(), | ||
None | ||
), | ||
preserves_kebab_case_in_css_variable_names, | ||
r#" | ||
import stylex from 'stylex'; | ||
export const styles = stylex.create({ | ||
default: { | ||
'--background-color': 'red', | ||
}, | ||
}); | ||
"# | ||
); | ||
|
||
|
||
test!( | ||
Syntax::Typescript(TsSyntax { | ||
tsx: true, | ||
..Default::default() | ||
}), | ||
|tr| StyleXTransform::new_test_force_runtime_injection_with_pass( | ||
tr.comments.clone(), | ||
PluginPass::default(), | ||
None | ||
), | ||
preserves_camel_case_in_css_variable_names, | ||
r#" | ||
import stylex from 'stylex'; | ||
const styles = stylex.create({ | ||
default: { | ||
'--myCustomVar': 'red', | ||
'--anotherCamelVar': '10px', | ||
}, | ||
}); | ||
"# | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters