iari
03/16/2022, 12:50 PMobject ComponentStyles : StyleSheet("common") {
val framed by css {
border(1.px, BorderStyle.solid, Green.color)
}
// a lot more css classes ...
}
How can I do this with emotion Stylesheets?turansky
03/16/2022, 2:27 PMiari
03/16/2022, 4:30 PMturansky
03/16/2022, 4:36 PMemotion.css.css
turansky
03/16/2022, 4:37 PMfun createClassName(block: PropertiesBuilder.() -> Unit): ClassName {
val properties = ...
return emotion.css.css(properties)
}
iari
03/16/2022, 4:40 PMPropertiesBuilder
to apply block
on?iari
03/16/2022, 4:58 PMClassName
Instances?
With the kotlinx / CssBuilder / styled code I was able to do this within components css block:
if (video == props.selectedItem) +ComponentStyles.selected
else +ComponentStyles.selectable
which would add the class dynamically ...turansky
03/16/2022, 4:58 PMfun createClassName(
block: PropertiesBuilder.() -> Unit,
): ClassName =
emotion.css.css(jso(block))
iari
03/16/2022, 5:00 PMPropsWithClassName.css(
vararg classNames: ClassName?,
crossinline block: PropertiesBuilder.() -> Unit,
)
?iari
03/16/2022, 5:02 PMcss(
if (video == props.selectedItem) ComponentStyles.selected
else ComponentStyles.selectable
) {
display = Display.flex
justifyContent = JustifyContent.spaceBetween
margin = 2.px
padding = 10.px
}
turansky
03/16/2022, 5:08 PMturansky
03/16/2022, 5:10 PMClassName
alias more chances for sugarturansky
03/16/2022, 5:11 PM+if (video == props.selectedItem) ComponentStyles.selected
else ComponentStyles.selectable
css {
display = Display.flex
justifyContent = JustifyContent.spaceBetween
margin = 2.px
padding = 10.px
}
iari
03/16/2022, 5:11 PM"button, input[type=submit], .navlink" {
+ComponentStyles.buttonStyle
}
Is there any way to make that work as well?turansky
03/16/2022, 5:13 PMiari
03/16/2022, 5:13 PMiari
03/16/2022, 5:14 PMturansky
03/16/2022, 5:50 PMiari
03/16/2022, 6:06 PM