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. 11
      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\"" })
}

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

@ -206,3 +206,14 @@ class GridAreaTests {
}
}
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