lpotthast / leptonic

Leptos component framework.
https://leptonic.dev
Apache License 2.0
248 stars 43 forks source link

tauri+leptos+leptonic gives a compilation error #52

Open aptly-io opened 5 months ago

aptly-io commented 5 months ago

I wanted to try tauri with leptos and this leptonic library. I go through these steps:

sh <(curl https://create.tauri.app/sh)    # choosing tauri-leptos as name, cargo/rust and leptos
✔ Project name · tauri-leptos
✔ Choose which language to use for your frontend · Rust - (cargo)
✔ Choose your UI template · Leptos - (https://leptos.dev/)

cd tauri-leptos

# I want to use components from leptonic, I don't really care if it uses client or server side-rendering
# (I follow leptonic's doc's on custom installation):

cargo add leptonic --features clipboard,tiptap

cargo tauri dev

During the compilation I notice the following error (the tauri demo screen shows up empty white)

   Compiling leptos_meta v0.6.9
        Warn Waiting for your frontend dev server to start on http://localhost:1420/...                                                                                                                                                      
error[E0599]: no method named `clipboard` found for struct `Navigator` in the current scope
   --> /home/francis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/typography.rs:199:29
    |
199 |             match navigator.clipboard() {
    |                             ^^^^^^^^^ method not found in `Navigator`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `leptonic` (lib) due to 1 previous error
2024-03-09T13:06:38.998522Z ERROR ❌ error
error from build pipeline

Caused by:
    0: HTML build pipeline failed (1 errors), showing first
    1: error from asset pipeline
    2: error during cargo build execution
    3: cargo call to executable 'cargo' with args: '["build", "--target=wasm32-unknown-unknown", "--manifest-path", "/home/francis/dev/projects/tauri/tauri-leptos/Cargo.toml"]' returned a bad status: exit status: 101
2024-03-09T13:06:38.999658Z  INFO 📡 serving static assets at -> /

Is there something I'm doing wrong in the way to use leptonic in tauri-leptos? Thank you!

PS it works without the clipboard feature. I can copy from and paste to the tauri window. Do one really need the clipboard feature? What benefit does it offer?

lpotthast commented 5 months ago

Hey, I have never used Tauri. But I think demand for it might be high enough that an additional template could be a good idea.

To your error specifically: Do you have a .cargo dir with a config.toml containing

[build]
rustflags = ["--cfg=web_sys_unstable_apis"]

This is necessary for the Clipboard feature. Documentation should definitely reflect this better!

aptly-io commented 5 months ago

Thank you. What you mean is to put together a leptonic-template-tauri? That would be awesome! I look forward to that!

I think some way forward for me now (as a rust beginner) is to maybe start off with the tauri-leptos scaffold-ed project and replace the front-end demo code with your leptonic-template-csr.

I tried to add the AppBar inside that scaffold-ed code. And that angered the compiler. Feels too difficult with my current rustc/cargo understanding to fix. It seems easier to try to glue 2 working projects together ...

lpotthast commented 5 months ago

Can you try out this template: https://github.com/lpotthast/leptonic-template-tauri

lpotthast commented 5 months ago

Make sure to install the cli for Tauri v2 with cargo install tauri-cli@2.0.0-beta.8

aptly-io commented 5 months ago

Thanks you! Well done! I could start on both the Linux desktop and Android emulator!