Browse Source

Basic support for grid-template-areas

This contributes to #895
pull/883/merge
Shagen Ogandzhanian 3 years ago
parent
commit
90cecde6f2
  1. 4
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/grid.kt
  2. 13
      web/core/src/jsTest/kotlin/css/GridTests.kt

4
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/grid.kt

@ -75,4 +75,8 @@ fun StyleBuilder.gridArea(rowStart: String, columnStart: String, rowEnd: String,
property("grid-area", "$rowStart / $columnStart / $rowEnd / $columnEnd")
}
// https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas
fun StyleBuilder.gridTemplateAreas(vararg rows: String) {
property("grid-template-areas", rows.joinToString(" ") { "\"$it\"" })
}

13
web/core/src/jsTest/kotlin/css/GridTests.kt

@ -205,4 +205,15 @@ class GridAreaTests {
assertEquals("span 2 / span another-grid-area / span 3 / span 2", el.style.asDynamic().gridArea)
}
}
}
class GridTemplateAreasTests {
@Test
fun gridTemplateAreas() = runTest {
composition {
Div({ style { gridTemplateAreas("head head", "nav main", "nav foot") } })
}
assertEquals("\"head head\" \"nav main\" \"nav foot\"", (root.children[0] as HTMLElement).style.asDynamic().gridTemplateAreas)
}
}

Loading…
Cancel
Save