Browse Source

Introduce basic support for white-space in CSS API

pull/893/head
Shagen Ogandzhanian 3 years ago
parent
commit
5164e0669b
  1. 5
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/text.kt
  2. 1
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/ui.kt
  3. 44
      web/core/src/jsTest/kotlin/css/CSSTextTests.kt

5
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/text.kt

@ -89,3 +89,8 @@ fun StyleBuilder.textDecorationLine(value: String) {
fun StyleBuilder.textDecoration(value: String) {
property("text-decoration", value)
}
// https://developer.mozilla.org/en-US/docs/Web/CSS/white-space
fun StyleBuilder.whiteSpace(value: String) {
property("white-space", value)
}

1
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/ui.kt

@ -5,6 +5,7 @@
package org.jetbrains.compose.web.css
// https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
fun StyleBuilder.cursor(vararg value: String) {
property("cursor", value.joinToString(", "))
}

44
web/core/src/jsTest/kotlin/css/CSSTextTests.kt

@ -353,4 +353,48 @@ class CSSTextTests {
assertEquals("line-through", (root.children[2] as HTMLElement).style.textDecoration)
assertEquals("underline overline dashed", (root.children[3] as HTMLElement).style.textDecoration)
}
@Test
fun whiteSpace() = runTest {
composition {
Div({
style {
whiteSpace("normal")
}
})
Div({
style {
whiteSpace("nowrap")
}
})
Div({
style {
whiteSpace("pre")
}
})
Div({
style {
whiteSpace("pre-wrap")
}
})
Div({
style {
whiteSpace("pre-line")
}
})
Div({
style {
whiteSpace("break-spaces")
}
})
}
assertEquals("normal", (root.children[0] as HTMLElement).style.whiteSpace)
assertEquals("nowrap", (root.children[1] as HTMLElement).style.whiteSpace)
assertEquals("pre", (root.children[2] as HTMLElement).style.whiteSpace)
assertEquals("pre-wrap", (root.children[3] as HTMLElement).style.whiteSpace)
assertEquals("pre-line", (root.children[4] as HTMLElement).style.whiteSpace)
assertEquals("break-spaces", (root.children[5] as HTMLElement).style.whiteSpace)
}
}
Loading…
Cancel
Save