Giter Site home page Giter Site logo

lakret / cells Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 2.0 710 KB

A small spreadsheet demo in Rust, Yew, and WASM

Home Page: https://lakret.net/demos/cells/index.html

License: MIT License

HTML 0.70% Rust 54.21% CSS 17.39% JavaScript 26.87% Python 0.83%
rust wasm webassembly yew yew-framework

cells's Introduction

Cell Demo: A WASM Spreadsheet in Rust with Yew

This is a demo for YouTube videos about Yew and topological sorting.

There's also a blog post about using Tailwind with Yew here.

Running

Make sure that Tailwind CLI is installed and is in the PATH. I recommend using a standalone CLI version:

# macOS:
# curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-arm64
# linux:
curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64
chmod +x tailwindcss-linux-x64
mv tailwindcss-linux-x64 tailwindcss

Install Rust WASM toolchain and Trunk (WASM packaging tool):

rustup target add wasm32-unknown-unknown
cargo install --locked trunk

Now you can run the app:

RUSTFLAGS='--cfg=web_sys_unstable_apis' trunk serve --port 8082 --release

Note, that I recommend running it in release mode, since debug mode is very slow.

"Prod" Serving

The content of the dist/ directory generated by trunk build could be served by any web server that can handle static files.

For example:

RUSTFLAGS='--cfg=web_sys_unstable_apis' trunk build --release -d prod_dist

# e.g., serve with python:
python -m http.server 8083 --directory prod_dist

... and you can see the app working on localhost:8083.

Note on Using Unstable web-sys APIs

To use ustable web-sys APIs such as Clipboard, you'll need to do the following:

  1. Enable the specific web-sys crate features you're planning to use, e.g.:
[dependencies]
web-sys = { version = "0.3.51", features = ["Clipboard"] }
  1. Make sure to pass RUSTFLAGS='--cfg=web_sys_unstable_apis' when you call trunk:
RUSTFLAGS='--cfg=web_sys_unstable_apis' trunk serve --port 8082 --release
  1. If you're using rust-analyzer, e.g. in VSCode, you should add this to your settings.json:
"rust-analyzer.cargo.extraEnv": {
  "RUSTFLAGS": "--cfg=web_sys_unstable_apis"
}

Please note that currently there is a bug in cargo that makes the setting above cause non-incrementral recompiles. It doesn't seem that there's a good way to avoid it, so I would recommend disabling this VSCode setting when working on non-WASM projects.

cells's People

Contributors

lakret avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cells's Issues

License?

Loving this so far -- do you have a license in mind?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.