ba0f3 / telebot.nim

Async Telegram Bot API Client implement in @Nim-Lang
MIT License
165 stars 24 forks source link

Rewrite `webapp.nim` for JS compatibility #96

Closed Ethosa closed 1 month ago

Ethosa commented 1 month ago

string -> cstring int64 -> cint is need because all types and procedures has {.importc, nodecl.}

Ethosa commented 1 month ago

I ran into a problem when I was writing the code for the article:

var
  tg = Telegram.WebApp
  bgColor = tg.themeParams.bg_color
  textColor = tg.themeParams.text_color

appRoutes("app"):
  "/{p:string}":
    tDiv(
      class = "flex flex-col w-screen min-h-screen h-full p-12",
      style = fmt"background: {bgColor}; color: {textColor}"  # error was here
    )
Ethosa commented 1 month ago

I also changed importc to importjs pragma in procedures, because it is methods, not functions:

discard tg.MainButton.setText("Click me!")
discard tg.MainButton.show()
tg.expand()