styletron icon indicating copy to clipboard operation
styletron copied to clipboard

Transform key values

Open sarjanen opened this issue 5 years ago • 7 comments

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 avatar Dec 15 '20 08:12 sarjanen

Okey I could transform my styles in driver function.

sarjanen avatar Dec 15 '20 09:12 sarjanen

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

sarjanen avatar Dec 23 '20 14:12 sarjanen

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

tajo avatar Dec 23 '20 19:12 tajo

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.

sarjanen avatar Dec 23 '20 20:12 sarjanen

What do you mean by extracting shorthands?

tajo avatar Dec 24 '20 10:12 tajo

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.

sarjanen avatar Dec 24 '20 10:12 sarjanen

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

bonzali avatar Nov 17 '21 19:11 bonzali