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

Transform key values #386

Open
sarjanen opened this issue Dec 15, 2020 · 7 comments
Open

Transform key values #386

sarjanen opened this issue Dec 15, 2020 · 7 comments

Comments

@sarjanen
Copy link

Hi!

Would love to be able to transform keys and values with a custom function, maybe pass it in to createdStyled? If I havent missed anything it shouldn't be too much work, can gladly help.

I knwo that we have withTransform but i need to transform keys and values before deepMerge is called and the only workaround ive seen is to write my own custom createStyledElementComponent function.

@sarjanen
Copy link
Author

Okey I could transform my styles in driver function.

@sarjanen
Copy link
Author

Seems like useStyletron css doesn't goes through driver so this issue is still relevant.

@sarjanen sarjanen reopened this Dec 23, 2020
@tajo
Copy link
Member

tajo commented Dec 23, 2020

Could you wrap/reexport useStyletron() and apply the transform there?

@sarjanen
Copy link
Author

Could you wrap/reexport useStyletron() and apply the transform there?

Smart! Then I don’t need to create a new hook. Still think this issue is a good feature tho. My primary goal with transform is to extract shorthand’s and I think that’s something most people want to do if they want to get as much as possible out of styletron.

@tajo
Copy link
Member

tajo commented Dec 24, 2020

What do you mean by extracting shorthands?

@sarjanen
Copy link
Author

What do you mean by extracting shorthands?

I’m extracting padding, margin, flex and border shorthands to long hands. padding: 0 24px for example becomes paddingTop: 0, paddingRight: 24px, ... and so on. This way we minimize the amount of classes we possible can create.

@bonzali
Copy link

bonzali commented Nov 17, 2021

If you have a theme as implemented in the baseui library, you can solve this by creating in the theme objects a Theme.mixin.margin function and either pass in a string , or parameters to apply to the shorthand properties

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

No branches or pull requests

3 participants