Browse Source

Introduce basic support for text-align in CSS API

pull/880/head
Shagen Ogandzhanian 3 years ago
parent
commit
6dd06d4d18
  1. 5
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/text.kt
  2. 45
      web/core/src/jsTest/kotlin/css/CSSTextTests.kt

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

@ -50,4 +50,9 @@ fun StyleBuilder.letterSpacing(value: String) {
fun StyleBuilder.letterSpacing(value: CSSNumeric) { fun StyleBuilder.letterSpacing(value: CSSNumeric) {
property("letter-spacing", value) property("letter-spacing", value)
}
// https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
fun StyleBuilder.textAlign(value: String) {
property("text-align", value)
} }

45
web/core/src/jsTest/kotlin/css/CSSFontTests.kt → web/core/src/jsTest/kotlin/css/CSSTextTests.kt

@ -14,7 +14,7 @@ import org.w3c.dom.get
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
class CSSFontTests { class CSSTextTests {
@Test @Test
fun fontSize() = runTest { fun fontSize() = runTest {
@ -155,5 +155,48 @@ class CSSFontTests {
assertEquals("italic bold 0.8em / 1.2 Arial, sans-serif", (root.children[0] as HTMLElement).style.font) assertEquals("italic bold 0.8em / 1.2 Arial, sans-serif", (root.children[0] as HTMLElement).style.font)
} }
@Test
fun textAlign() = runTest {
composition {
Div({
style {
textAlign("left")
}
})
Div({
style {
textAlign("right")
}
})
Div({
style {
textAlign("center")
}
})
Div({
style {
textAlign("justify")
}
})
Div({
style {
textAlign("start")
}
})
Div({
style {
textAlign("end")
}
})
}
assertEquals("left", (root.children[0] as HTMLElement).style.textAlign)
assertEquals("right", (root.children[1] as HTMLElement).style.textAlign)
assertEquals("center", (root.children[2] as HTMLElement).style.textAlign)
assertEquals("justify", (root.children[3] as HTMLElement).style.textAlign)
assertEquals("start", (root.children[4] as HTMLElement).style.textAlign)
assertEquals("end", (root.children[5] as HTMLElement).style.textAlign)
}
} }
Loading…
Cancel
Save