JetBrains / kotlin-wrappers

Kotlin wrappers for popular JavaScript libraries
Apache License 2.0
1.34k stars 164 forks source link

some problems when wrapper antd #2167

Closed citywalki closed 11 months ago

citywalki commented 11 months ago

in js:

import { Layout, Menu, theme } from 'antd';
const { Header, Content, Footer, Sider } = Layout;
<Layout>
      <Header>
     </Header>
</Layout>

in kotlin:

@JsModule("antd")
@JsNonModule
@JsName("Layout")
external val Layout: FC<LayoutProps>

But I don't know how to use Header in kotlin,Is there any hint?? antd layout code layout doc

turansky commented 11 months ago
@file:JsModule("antd")

external object Layout: FC<LayoutProps> {
    val Header: FC<HeaderProps>
    val Content: FC<ContentProps>
    val Footer: FC<FooterProps>
    val Sider: FC<SiderProps>
}
citywalki commented 11 months ago
@file:JsModule("antd")

external object Layout: FC<LayoutProps> {
    val Header: FC<HeaderProps>
    val Content: FC<ContentProps>
    val Footer: FC<FooterProps>
    val Sider: FC<SiderProps>
}

@turansky I tried it, the layout is fine, but adding the header has wrong.

image
turansky commented 11 months ago
  1. Could you test following?

    console.log(Layout)
    console.log(Layout.Header)
  2. Could you test following?

    Layout {
    // I don't know why `Header` works fine, it looks like props with broken nullability
    Layout.Header {
    }
    }
citywalki commented 11 months ago
@file:JsModule("antd")

external object Layout: FC<LayoutProps> {
    val Header: FC<HeaderProps>
    val Content: FC<ContentProps>
    val Footer: FC<FooterProps>
    val Sider: FC<SiderProps>
}

@turansky Sorry, I made a mistake, I used the interface. When I change it to object, everything is fine. thank you very much

citywalki commented 11 months ago

@turansky Sorry, I have a new question to ask. Can we wrap this use kotlin?

image
turansky commented 11 months ago

I don't know solution for generic T.

leerenbo commented 1 month ago

@citywalki Hi,I have the same problem as you. I just spent a day wrapper the DayJS library. I'm about to wrapper the Antd library. How's your progress? How about we wrapper together and contribute to Kotlin-wrappers?

citywalki commented 1 month ago

@leerenbo sorry, I gave up use kotlin