Introduce basic support for white-space in CSS API

This commit is contained in:
Shagen Ogandzhanian
2021-07-13 21:08:42 +02:00
parent f861210bdd
commit 5164e0669b
3 changed files with 50 additions and 0 deletions

View File

@@ -88,4 +88,9 @@ fun StyleBuilder.textDecorationLine(value: String) {
// https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration
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)
}

View File

@@ -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(", "))
}

View File

@@ -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)
}
}