Newer
Older
test-pure-kotlin-js / src / main / kotlin / nl / astraeus / Main.kt
rnentjes on 4 Mar 2020 721 bytes Test Kotlin/JS import modules
package nl.astraeus

import kotlinx.html.div
import nl.astraeus.komp.HtmlBuilder
import nl.astraeus.komp.Komponent
import nl.astraeus.komp.include
import kotlin.browser.document

class TextKomponent(
    val text: String
): Komponent() {
    override fun HtmlBuilder.render() {
        div {
            attributes["style"] = "color: green; margin: 10px; padding: 15px; border: 2px solid green;"
            + text
        }
    }
}

class TestKomponent: Komponent() {
    override fun HtmlBuilder.render() {
        div {
            + "What!? is this?"

            include(TextKomponent("MORE TEXT"))
        }
    }
}

fun main() {
    Komponent.create(document.body!!, TestKomponent())

    println("Started zzz")
}