Scott Wilson-Billing
06/17/2021, 7:43 AMScott Wilson-Billing
06/17/2021, 7:44 AMScott Wilson-Billing
06/17/2021, 7:45 AMSwitch
component.Scott Wilson-Billing
06/17/2021, 7:45 AMSwitch.Label
and Switch.Group
which I can't expose to kotlin.Scott Wilson-Billing
06/17/2021, 7:45 AMSwitch
Scott Wilson-Billing
06/17/2021, 7:45 AM@file:JsModule("@headlessui/react")
@file:JsNonModule
import kotlinx.html.RP
import react.*
@JsName("Switch")
external val ReactSwitch: RClass<ReactSwitchProps>
external interface ReactSwitchProps: RProps {
var checked: Boolean
var className: String
var onChange: (Boolean) -> Unit
}
Big Chungus
06/17/2021, 7:46 AMScott Wilson-Billing
06/17/2021, 7:47 AMBig Chungus
06/17/2021, 7:47 AMBig Chungus
06/17/2021, 7:48 AMScott Wilson-Billing
06/17/2021, 7:50 AMBig Chungus
06/17/2021, 7:51 AMconst Comp1 = ...
const Comp2 = ...
// or module.exports = {...}
export default {
Comp1,
Comp2,
}
Which in kotlin can be represented as this
@JsModule("mymodule")
external object AnyNameYouWant {
val Comp1: RClass<RPRops>
val Comp2: RClass<RProps>
}
Scott Wilson-Billing
06/17/2021, 7:51 AMSwitch
file they do this:
Switch.Group = Group
Switch.Label = Label
Switch.Description = Description
Scott Wilson-Billing
06/17/2021, 7:51 AMBig Chungus
06/17/2021, 7:52 AMScott Wilson-Billing
06/17/2021, 7:52 AMScott Wilson-Billing
06/17/2021, 7:53 AM@file:JsModule("@headlessui/react")
@file:JsNonModule
import kotlinx.html.RP
import react.*
@JsName("Switch")
external val ReactSwitch: RClass<ReactSwitchProps>
external interface ReactSwitchProps: RProps {
var checked: Boolean
var className: String
var onChange: (Boolean) -> Unit
}
Scott Wilson-Billing
06/17/2021, 7:54 AMSwitch.Label
, Switch.Group
and Switch.Description
Big Chungus
06/17/2021, 7:55 AM@JsModule("mymodule")
external object Switch {
external operator fun invoke(props: RProps): RComponent<RProps>
val Group: RClass<RPRops>
val Label: RClass<RProps>
Description: RClass<RProps>
}
Big Chungus
06/17/2021, 7:55 AMScott Wilson-Billing
06/17/2021, 7:56 AMBig Chungus
06/17/2021, 7:58 AMScott Wilson-Billing
06/17/2021, 10:01 AM@file:JsModule("@headlessui/react")
@file:JsNonModule
import react.*
external object Switch {
operator fun invoke(props: RProps): RComponent<RProps, RState>
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
Scott Wilson-Billing
06/17/2021, 10:02 AMval switch = Switch(props)
Scott Wilson-Billing
06/17/2021, 10:02 AMUncaught TypeError: Switch.invoke is not a function
Big Chungus
06/17/2021, 10:14 AMScott Wilson-Billing
06/17/2021, 10:15 AMNon top-level `external` declaration
Big Chungus
06/17/2021, 10:16 AMexternal fun Switch(props: RProps): RComponent<RProps, RState>
external object Switch {
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
Big Chungus
06/17/2021, 10:19 AMexternal fun Switch(props: RProps): RComponent<RProps, RState>
external interface SwitchContainer {
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
@JsName("Switch")
external val SwitchC: SwitchContainer {
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
Scott Wilson-Billing
06/17/2021, 10:28 AM@JsName("Switch")
external fun Switch(props: ReactSwitchProps): RComponent<RProps, RState>
external object Switch {
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
Big Chungus
06/17/2021, 10:29 AMScott Wilson-Billing
06/17/2021, 10:29 AMScott Wilson-Billing
06/17/2021, 10:29 AMSwitch.Group {
Switch.Label {
+"Switch Label"
}
Switch(props)
}
Scott Wilson-Billing
06/17/2021, 10:30 AMScott Wilson-Billing
06/17/2021, 10:30 AMval todoCard = functionalComponent<TodoCardProps> { props ->
val (checked, setChecked) = useState(false)
div("rounded overflow-hidden h-auto sm:h-96 border-solid border border-blue-900") {
div("px-2 py-3 bg-skin-fill-primary h-auto lg:h-16 sm:flex items-center justify-between") {
p("text-white text-2xl leading-7.5 text-left sm:uppercase sm:font-bold") {
+"Todo for ${props.name}"
}
}
val switchColor = if (checked) "bg-blue-600" else "bg-gray-200"
val switchClass = "$switchColor relative inline-flex items-center h-6 rounded-full w-11"
var switchButtonClass= if (checked) "translate-x-6 inline-block w-4 h-4 transform bg-white rounded-full" else "translate-x-1 inline-block w-4 h-4 transform bg-white rounded-full"
div("p-10") {
var props: ReactSwitchProps = jsObject {
this.checked = checked
this.className = className
this.onChange = { setChecked(!checked) }
}
Switch.Group {
Switch.Label {
+"Switch Label"
}
Switch(props)
}
}
println(Switch)
println(Switch.Description)
println(Switch.Group)
println(Switch.Label)
}
}
Big Chungus
06/17/2021, 10:31 AMimport react.*
@JsModule("@headlessui/react")
@JsNonModule
external object Switch: RClass<RProps> {
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
Scott Wilson-Billing
06/17/2021, 10:33 AMScott Wilson-Billing
06/17/2021, 10:33 AMObject 'Switch' is not abstract and does not implement abstract member
Big Chungus
06/17/2021, 10:33 AMScott Wilson-Billing
06/17/2021, 10:34 AMScott Wilson-Billing
06/17/2021, 10:34 AMimport react.*
@JsModule("@headlessui/react")
@JsNonModule
external object Switch: RClass<RProps> {
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
Big Chungus
06/17/2021, 11:16 AMimport react.*
@JsModule("@headlessui/react")
@JsNonModule
external object Switch {
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
operator fun Switch.invoke(props: RProps): RComponent<RProps, RState> = Switch.asDynamic()(props)
Scott Wilson-Billing
06/17/2021, 1:11 PMScott Wilson-Billing
06/17/2021, 1:11 PMprintln(Switch)
println(Switch.Description)
println(Switch.Group)
println(Switch.Label)
Scott Wilson-Billing
06/17/2021, 1:12 PMScott Wilson-Billing
06/17/2021, 1:12 PM[object module]
undefined
undefined
undefined
Scott Wilson-Billing
06/17/2021, 1:15 PM@file:JsModule("@headlessui/react")
@file:JsNonModule
import react.*
external object Switch {
operator fun invoke(props: RProps): RComponent<RProps, RState>
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
Big Chungus
06/17/2021, 1:16 PMScott Wilson-Billing
06/17/2021, 1:17 PMScott Wilson-Billing
06/17/2021, 1:17 PMScott Wilson-Billing
06/17/2021, 1:17 PMSwitch.Label {
//
}
Switch.Group {
//
}}
Scott Wilson-Billing
06/17/2021, 1:17 PMScott Wilson-Billing
06/17/2021, 1:18 PMSwitch {
}
Scott Wilson-Billing
06/17/2021, 1:18 PMBig Chungus
06/17/2021, 1:19 PMRClass<RProps>
doesn't work?
@file:JsModule("@headlessui/react")
@file:JsNonModule
import react.*
external object Switch: RClass<RProps> {
operator fun invoke(props: RProps): RComponent<RProps, RState>
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
Scott Wilson-Billing
06/17/2021, 1:20 PMObject 'Switch' is not abstract and does not implement abstract member public abstract var contextType: RContext<Any>? defined in react.RClass
Big Chungus
06/17/2021, 1:21 PM@file:JsModule("@headlessui/react")
@file:JsNonModule
import react.*
external val Switch: RClass<RProps>
external object Switch {
operator fun invoke(props: RProps): RComponent<RProps, RState>
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
Big Chungus
06/17/2021, 1:21 PMBig Chungus
06/17/2021, 1:21 PM@file:JsModule("@headlessui/react")
@file:JsNonModule
import react.*
external val Switch: RClass<RProps>
@JsName("Switch")
external object SwitchEx {
operator fun invoke(props: RProps): RComponent<RProps, RState>
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
Big Chungus
06/17/2021, 1:24 PMimport react.*
@JsModule("@headlessui/react")
@JsNonModule
external object HeadlessUI {
external object Switch {
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
}
operator fun HeadlessUI.Switch.invoke(props: RProps): RComponent<RProps, RState> = Switch.asDynamic()(props)
Scott Wilson-Billing
06/17/2021, 1:24 PMBig Chungus
06/17/2021, 1:25 PMBig Chungus
06/17/2021, 1:26 PMScott Wilson-Billing
06/17/2021, 1:26 PMBig Chungus
06/17/2021, 1:27 PMScott Wilson-Billing
06/17/2021, 1:49 PMimport react.*
@JsModule("@headlessui/react")
@JsNonModule
external object HeadlessUI {
object Switch {
val Group: RClass<RProps>
val Label: RClass<RProps>
val Description: RClass<RProps>
}
}
operator fun HeadlessUI.Switch.invoke(props: RProps): RComponent<RProps, RState> = HeadlessUI.Switch.asDynamic()(props)
Scott Wilson-Billing
06/17/2021, 1:49 PMScott Wilson-Billing
06/17/2021, 1:49 PMScott Wilson-Billing
06/17/2021, 1:50 PMHeadlessUI.Switch.Group {
HeadlessUI.Switch.Label {
+ "Switch Label"
}
HeadlessUI.Switch() {
}
}
Scott Wilson-Billing
06/17/2021, 1:50 PMBig Chungus
06/17/2021, 1:52 PMBig Chungus
06/17/2021, 1:54 PMfun Switch(props: RProps): RComponent<RProps, RState> = HeadlessUI.asDynamic().Switch(props)
Big Chungus
06/17/2021, 1:55 PMimport react.*
@JsModule("@headlessui/react")
@JsNonModule
internal external val HeadlessUI: dynamic
val Switch: RClass<RProps> = HeadlessUI.Switch
val SwitchGroup: RClass<RProps> = HeadlessUI.Switch.Group
// etc...
Scott Wilson-Billing
06/17/2021, 2:14 PMScott Wilson-Billing
06/17/2021, 2:15 PMSwitchGroup {
div("flex items-center") {
Switch {
attrs.checked = checked
attrs.className = switchClass
attrs.onChange = { setChecked(!checked) }
span(switchButtonClass) {}
}
SwitchLabel {
span("ml-4") {
+ "This is a switch"
}
}
}
}
Scott Wilson-Billing
06/17/2021, 2:15 PMimport react.*
@JsModule("@headlessui/react")
@JsNonModule
internal external val HeadlessUI: dynamic
val Switch: RClass<ReactSwitchProps> = HeadlessUI.Switch
val SwitchGroup: RClass<RProps> = HeadlessUI.Switch.Group
val SwitchLabel: RClass<RProps> = HeadlessUI.Switch.Label
Scott Wilson-Billing
06/17/2021, 2:16 PMScott Wilson-Billing
06/17/2021, 2:16 PMBig Chungus
06/17/2021, 2:50 PMScott Wilson-Billing
06/17/2021, 2:51 PMBig Chungus
06/17/2021, 2:52 PMScott Wilson-Billing
06/17/2021, 2:54 PMBig Chungus
06/17/2021, 2:56 PMScott Wilson-Billing
06/17/2021, 3:09 PMBig Chungus
06/17/2021, 3:13 PMBig Chungus
06/17/2021, 3:13 PMScott Wilson-Billing
06/17/2021, 3:13 PM