Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] explicitly need to use styles for a variant to be detected #456

Open
jeremybarbet opened this issue Dec 18, 2024 · 3 comments
Open
Labels
enhancement New feature or request
Milestone

Comments

@jeremybarbet
Copy link
Contributor

Description

Hey,

Not sure if it's a bug report per se or an improvement.

When using variants, the babel plugin will explicitly looks for a styles object to get the styles from (https://github.com/jpudysz/react-native-unistyles/blob/main/plugin/variants.js#L6)

I personally like to name my styles object s to keep it short, which means the following is not detected.

const MyComponent = () => {
   s.useVariants(...)
}

const s = StyleSheet.create(...

Should we be able to defined a custom name through the babel.config.js or there is a smarter way to detect a style object with any custom name?

Steps to Reproduce

  1. Name your styles object s
  2. Try to set useVariants

Snack or Repository Link (Optional)

No response

Unistyles Version

3.0.0-beta.4

React Native Version

0.76.5

Platforms

iOS

Expo

Yes

@jpudysz
Copy link
Owner

jpudysz commented Dec 19, 2024

Haha, I've never seen such renames, but for sure this should be supported 😄

@jpudysz jpudysz added the enhancement New feature or request label Dec 19, 2024
@jpudysz jpudysz added this to the 3.0.0-beta.5 milestone Dec 19, 2024
@jeremybarbet
Copy link
Contributor Author

Any direction on how it should be supported? I would be happy to contribute if it's through babel config

@jpudysz
Copy link
Owner

jpudysz commented Dec 19, 2024

Yes, it's related to this one: #436

I need to change detection strategy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants