You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.
It would be really cool to use css builders in combination with material ui. In order to do this, we can add the kotlin-styled library to the project dependencies. After that, we can add a css builder to the MaterialElementBuilder:
abstract class MaterialElementBuilder<T : Tag, Props : StandardProps>(
//.....
val muiCss = CSSBuilder()
get() = field.also {
useCSSBuilder = true
}
private var useCSSBuilder = false // Just so we have no changed functionality if muiCss {} is not invoked
//.....
override fun create(): ReactElement {
Object.keys(materialProps).forEach { key -> setProp(key, materialProps[key]) }
return if (useCSSBuilder) {
Styled.createElement(type, muiCss, props, childList)
}
else {
createElement(type, props, *childList.toTypedArray())
}
}
}
inline fun MaterialElementBuilder<*, *>.muiCss(handler: RuleSet) = muiCss.handler()
After this, we can simply make components, just like how we would use styled components:
I understand that this is a wrapper library, so perhaps this functionality is unwanted as adding functionality defeats the purpose of having a wrapper, but perhaps it is worth looking into. Perhaps we can enable/disable it, perhaps we can create a kotlin-styled-material-ui fork or something.
Please advice and give your opinion, also if this is a stupid idea!
The text was updated successfully, but these errors were encountered:
It would certainly be nice to be able to set CSS as well, like the attrs method. However, the original Material-UI recommends using the makeStyles method to completely separate the CSS settings.
It would be really cool to use css builders in combination with material ui. In order to do this, we can add the kotlin-styled library to the project dependencies. After that, we can add a css builder to the MaterialElementBuilder:
After this, we can simply make components, just like how we would use styled components:
I understand that this is a wrapper library, so perhaps this functionality is unwanted as adding functionality defeats the purpose of having a wrapper, but perhaps it is worth looking into. Perhaps we can enable/disable it, perhaps we can create a kotlin-styled-material-ui fork or something.
Please advice and give your opinion, also if this is a stupid idea!
The text was updated successfully, but these errors were encountered: