Shubham Singh
12/07/2024, 7:35 AMcustom pElement
(Pseudo Element) in Kilua? My usecase does not fall under the available enum entries.
I want to be able to customise a range
(slider) component, make a custom thumb and change the range/track colors, and to do so, I'll probably need to use the -webkit-slider-thumb
pseudo element, like this:
// This is a .css file
.slider {
width: 100px;
}
// This is what I need to achieve using Kilua's Kotlin APIs
.slider::-webkit-slider-thumb {
appearance: none;
width: 20px;
height: 20px;
background: #8758ff;
}
Robert Jaros
12/07/2024, 1:25 PMstyle(".slider") {
width(100.perc)
}
style(".slider::-webkit-slider-thumb") {
style("appearance", "none")
width(20.px)
height(20.px)
background(Background(color = Color.hex(0x8758ff)))
}
Shubham Singh
12/07/2024, 1:28 PMval hoverStyle = dev.kilua.html.style.style(pClass = PClass.Hover) {
style("scale", "1.5 1.5")
}
val pressStyle = dev.kilua.html.style.style(pClass = PClass.Active) {
opacity(0.8)
style("scale", "1.0 1.0")
}
div(className = hoverStyle % pressStyle) {
...
}
Where do I provide the .slider
className in this case?Robert Jaros
12/07/2024, 1:29 PMrange(className = "slider") {
...
}
Shubham Singh
12/07/2024, 1:30 PM"slider"
with the hoverStyle
and pressStyle
style `className`s I mentioned above?
Something like "slider" % hoverStyle % pressStyle
?Robert Jaros
12/07/2024, 1:31 PMRobert Jaros
12/07/2024, 1:31 PM%
operator is defined for String?
typeRobert Jaros
12/07/2024, 1:32 PMstyle()
just returns String valuesShubham Singh
12/07/2024, 1:34 PMrange(className = "slider") {
cursor(Cursor.Pointer)
flexGrow(1)
height(4.px)
marginLeft(8.px)
marginRight(8.px)
style("accent-color", Colors.greenButtonBG.value)
dev.kilua.html.style.style(".slider::-webkit-slider-thumb") {
style("appearance", "none")
width(20.px)
height(20.px)
background(Background(color = Color.hex(0x8758ff)))
}
}
Am I doing something incorrect?Robert Jaros
12/07/2024, 1:42 PMrange(className = "slider") {
cursor(Cursor.Pointer)
flexGrow(1)
height(4.px)
marginLeft(8.px)
marginRight(8.px)
style("accent-color", "red")
style(".slider") {
style("appearance", "none")
background(Background(color = Color.hex(0xdddddd)))
}
style(".slider::-webkit-slider-thumb") {
style("appearance", "none")
width(20.px)
height(20.px)
background(Background(color = Color.hex(0x8758ff)))
}
}
Robert Jaros
12/07/2024, 1:44 PMShubham Singh
12/07/2024, 1:44 PMRobert Jaros
12/07/2024, 1:54 PMrange
component. These functions create global stylesheets and keeping them inside a component may lead to wrong assumptions the styles are somehow its descendants (or even errors if you would extract the range to some reusable component).Shubham Singh
12/07/2024, 1:58 PMRobert Jaros
12/07/2024, 2:00 PMShubham Singh
12/07/2024, 2:00 PMShubham Singh
12/07/2024, 2:08 PMRobert Jaros
12/07/2024, 8:42 PMrange {
cursor(Cursor.Pointer)
flexGrow(1)
height(4.px)
marginLeft(8.px)
marginRight(8.px)
style("accent-color", "red")
appliedStyle {
style("appearance", "none")
background(Color.hex(0xdddddd))
pElement("-webkit-slider-thumb") {
style("appearance", "none")
width(20.px)
height(20.px)
background(Color.hex(0x8758ff))
}
}
}
Robert Jaros
12/07/2024, 8:48 PMRobert Jaros
12/07/2024, 9:16 PMappliedStyle
, localStyle
, componentStyle
, but also making it style
and changing the current function to globalStyle
. I'm open to suggestions.Shubham Singh
12/08/2024, 9:55 AMTagStyleFun
only contains a single function named style
with no other overloads, the new function could just be an overload that only accepts a lambda.
It would make it easier for new users to find this APIRobert Jaros
12/08/2024, 9:59 AMstyle(String, String)
method. It's a problem with current global function style()
, which declares global stylesheet and new ITag<E>.appliedStyle()
extension function. They can't have the same name, because they are ambiguous for the compiler.Shubham Singh
12/08/2024, 10:01 AMstyle
function to globalStyle
and calling the new function style
only instead of appliedStyle
✅Shubham Singh
12/08/2024, 10:03 AMlocal
should automatically be inferred since the users are working in a Compose
environment
And the term global
should be explicit here