fun main()

in html/integration-core/src/jsMain/kotlin/androidx/compose/web/sample/Sample.kt [124:270]


fun main() {
    val urlParams = URLSearchParams(window.location.search)

    if (urlParams.has("test")) {
        launchTestCase(urlParams.get("test") ?: "")
        return
    }

    renderComposableInBody {
        println("renderComposable")
        val counter = remember { mutableStateOf(0) }

        CheckboxInput(checked = false) {
            onInput {
                println("Checkbox input = ${it.value}")
            }
            onChange {
                println("Checkbox onChange = ${it.value}")
            }
        }

        var emailState by remember { mutableStateOf("") }
        var rangeState by remember { mutableStateOf<Number>(10) }

        TextInput(value = emailState) {
            onInput {
                println("Typed value = ${it.value}")
                emailState = it.value
            }
        }

        NumberInput(value = 10) {
            onBeforeInput { println(("number onBeforeInput = ${it.value}")) }
            onInput { println(("number onInput = ${it.value}")) }
            onChange { println(("number onChange = ${it.value}")) }
        }

        RangeInput(rangeState) {
            onBeforeInput { println(("RangeInput onBeforeInput = ${it.value}")) }
            onInput {
                println(("RangeInput onInput = ${it.value}"))
                rangeState = it.value ?: 0
            }
        }

        MonthInput(value = "2021-10") {
            onInput {
                println("Month = ${it.value}")
            }
        }

        CounterApp(counter)

        val inputValue = remember { mutableStateOf("") }

        smallColoredTextWithState(
            text = derivedStateOf {
                if (inputValue.value.isNotEmpty()) {
                    " ___ " + inputValue.value
                } else {
                    ""
                }
            }
        )

        A(href = "http://127.0.0.1") {
            Text("Click Me")
        }

        MyInputComponent(text = inputValue) {
            inputValue.value = it
        }

        Text("inputValue.value" + inputValue.value)

        Style {
            className(MyClassName) style {
                opacity(0.3)
            }

            className(MyClassName) + hover style {
                opacity(1)
            }

            ".${AppStyleSheet.myClass}:hover" {
                color(Color.red)
            }

            media(mediaMinWidth(500.px) and mediaMaxWidth(700.px)) {
                className(MyClassName) style {
                    fontSize(40.px)
                }
            }
        }
        Style(AppStyleSheet)

        Div(
            attrs = {
                classes(
                    AppStyleSheet.classWithNested
                )
            }
        ) {
            Text("My text")
        }

        Div(
            attrs = {
                classes(MyClassName)
            }
        ) {
            Text("My text")
        }

        Div({
            classes(
                AppStyleSheet.myClass
            )

            style {
                opacity(0.3)
            }
        }) {
            Text("My text")
        }

        Div(
            attrs = {
                style {
                    color(Color.pink)
                    opacity(30.percent)
                }
            }
        ) {
            Text("My text")
        }

        KotlinCodeSnippets()
    }

    MainScope().launch {
        while (true) {
            delay(3000)
            globalState.isDarkTheme = !globalState.isDarkTheme
        }
    }
}