Browse Source

Introduce Canvas element

with_mpp_example
Shagen Ogandzhanian 3 years ago
parent
commit
d38f7347ab
  1. 16
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/elements/Elements.kt
  2. 2
      web/core/src/jsTest/kotlin/elements/ElementsTests.kt

16
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/elements/Elements.kt

@ -59,6 +59,7 @@ import org.w3c.dom.HTMLUListElement
import org.w3c.dom.HTMLVideoElement
import org.w3c.dom.Text
import org.w3c.dom.css.CSSStyleSheet
import org.w3c.dom.HTMLCanvasElement
typealias AttrBuilderContext<T> = AttrsBuilder<T>.() -> Unit
typealias ContentBuilder<T> = @Composable ElementScope<T>.() -> Unit
@ -149,6 +150,8 @@ private val Td: ElementBuilder<HTMLTableCellElement> = ElementBuilderImplementat
private val Tbody: ElementBuilder<HTMLTableSectionElement> = ElementBuilderImplementation("tbody")
private val Tfoot: ElementBuilder<HTMLTableSectionElement> = ElementBuilderImplementation("tfoot")
private val Canvas: ElementBuilder<HTMLCanvasElement> = ElementBuilderImplementation("canvas")
val Style: ElementBuilder<HTMLStyleElement> = ElementBuilderImplementation("style")
fun interface ElementBuilder<TElement : Element> {
@ -161,6 +164,19 @@ fun interface ElementBuilder<TElement : Element> {
}
}
@Composable
fun Canvas(
attrs: AttrBuilderContext<HTMLCanvasElement>? = null,
content: ContentBuilder<HTMLCanvasElement>? = null
) {
TagElement(
elementBuilder = Canvas,
applyAttrs = attrs,
content = content
)
}
@Composable
fun Address(
attrs: AttrBuilderContext<HTMLElement>? = null,

2
web/core/src/jsTest/kotlin/elements/ElementsTests.kt

@ -95,6 +95,8 @@ class ElementsTests {
Pair({ Td() }, "TD"),
Pair({ Tbody() }, "TBODY"),
Pair({ Tfoot() }, "TFOOT"),
Pair({ Canvas() }, "CANVAS"),
)
composition {

Loading…
Cancel
Save