Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite webapp.nim for JS compatibility #96

Merged
merged 2 commits into from
Jul 2, 2024
Merged

Conversation

Ethosa
Copy link
Contributor

@Ethosa Ethosa commented Jul 1, 2024

No description provided.

@Ethosa
Copy link
Contributor Author

Ethosa commented Jul 1, 2024

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

@Ethosa
Copy link
Contributor Author

Ethosa commented Jul 1, 2024

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
Copy link
Contributor Author

Ethosa commented Jul 1, 2024

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()

@ba0f3 ba0f3 merged commit 980f16e into ba0f3:master Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants