
commonMain.kotlinx.css.properties.TextDecoration.kt Maven / Gradle / Ivy
@file:Suppress("EnumEntryName")
package kotlinx.css.properties
import kotlinx.css.Color
import kotlinx.css.StyledElement
import kotlinx.css.hyphenize
import kotlinx.css.textDecoration
enum class TextDecorationLine {
initial, inherit, unset,
underline, overline, lineThrough;
override fun toString() = name.hyphenize()
}
class TextDecoration(
private val lines: Set,
val style: TextDecorationStyle? = null,
val color: Color? = null,
) {
companion object {
val none = TextDecoration(setOf())
}
override fun toString() = when {
lines.isEmpty() -> "none"
else -> buildString {
append(lines.joinToString(" "))
style?.let { append(" $it") }
color?.let { append(" $it") }
}
}
}
enum class TextDecorationStyle {
initial, inherit, unset,
solid, double, dotted, dashed, wavy;
override fun toString() = name
}
fun StyledElement.textDecoration(
vararg lines: TextDecorationLine,
style: TextDecorationStyle? = null,
color: Color? = null,
) {
textDecoration = TextDecoration(lines.toSet(), style, color)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy