Browse Source

Minimal support for backgroundOrigin in CSS API

CSS_BASIC_PROPS
Shagen Ogandzhanian 3 years ago
parent
commit
fb98e9f495
  1. 5
      web/core/src/jsMain/kotlin/androidx/compose/web/css/properties/background.kt
  2. 21
      web/core/src/jsTest/kotlin/css/CSSBackgroundTests.kt

5
web/core/src/jsMain/kotlin/androidx/compose/web/css/properties/background.kt

@ -27,6 +27,11 @@ fun StyleBuilder.backgroundImage(value: String) {
property("background-image", value)
}
// https://developer.mozilla.org/en-US/docs/Web/CSS/background-origin
fun StyleBuilder.backgroundOrigin(value: String) {
property("background-origin", value)
}
// https://developer.mozilla.org/en-US/docs/Web/CSS/background-position
fun StyleBuilder.backgroundPosition(value: String) {
property("background-position", value)

21
web/core/src/jsTest/kotlin/css/CSSBackgroundTests.kt

@ -122,4 +122,25 @@ class CSSBackgroundTests {
assertEquals("padding-box", window.getComputedStyle(root.children[1] as HTMLElement).backgroundClip)
assertEquals("content-box", window.getComputedStyle(root.children[2] as HTMLElement).backgroundClip)
}
@Test
fun backgroundOrigin() = runTest {
composition {
Div({style {
backgroundOrigin("border-box")
}})
Div({style {
backgroundOrigin("padding-box")
}})
Div({style {
backgroundOrigin("content-box")
}})
}
assertEquals("border-box", window.getComputedStyle(root.children[0] as HTMLElement).backgroundOrigin)
assertEquals("padding-box", window.getComputedStyle(root.children[1] as HTMLElement).backgroundOrigin)
assertEquals("content-box", window.getComputedStyle(root.children[2] as HTMLElement).backgroundOrigin)
}
}
Loading…
Cancel
Save