From d38f7347ab789d2f4351f72159e3b38b56ccc9a6 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Mon, 20 Dec 2021 13:27:29 +0100 Subject: [PATCH] Introduce Canvas element --- .../jetbrains/compose/web/elements/Elements.kt | 16 ++++++++++++++++ .../src/jsTest/kotlin/elements/ElementsTests.kt | 2 ++ 2 files changed, 18 insertions(+) diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/elements/Elements.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/elements/Elements.kt index 6ebec334b4..ddce7513a1 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/elements/Elements.kt +++ b/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 = AttrsBuilder.() -> Unit typealias ContentBuilder = @Composable ElementScope.() -> Unit @@ -149,6 +150,8 @@ private val Td: ElementBuilder = ElementBuilderImplementat private val Tbody: ElementBuilder = ElementBuilderImplementation("tbody") private val Tfoot: ElementBuilder = ElementBuilderImplementation("tfoot") +private val Canvas: ElementBuilder = ElementBuilderImplementation("canvas") + val Style: ElementBuilder = ElementBuilderImplementation("style") fun interface ElementBuilder { @@ -161,6 +164,19 @@ fun interface ElementBuilder { } } +@Composable +fun Canvas( + attrs: AttrBuilderContext? = null, + content: ContentBuilder? = null +) { + TagElement( + elementBuilder = Canvas, + applyAttrs = attrs, + content = content + ) +} + + @Composable fun Address( attrs: AttrBuilderContext? = null, diff --git a/web/core/src/jsTest/kotlin/elements/ElementsTests.kt b/web/core/src/jsTest/kotlin/elements/ElementsTests.kt index 19d8b3f6a1..c311d2a7f9 100644 --- a/web/core/src/jsTest/kotlin/elements/ElementsTests.kt +++ b/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 {