Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pepsighan/papito
A Beginner Friendly Rusty WASM Framework
https://github.com/pepsighan/papito
frontend nightly rust wasm web
Last synced: 3 months ago
JSON representation
A Beginner Friendly Rusty WASM Framework
- Host: GitHub
- URL: https://github.com/pepsighan/papito
- Owner: pepsighan
- License: mit
- Archived: true
- Created: 2018-03-17T07:35:08.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-29T04:03:23.000Z (over 6 years ago)
- Last Synced: 2024-10-12T23:40:27.045Z (4 months ago)
- Topics: frontend, nightly, rust, wasm, web
- Language: Rust
- Homepage:
- Size: 157 KB
- Stars: 50
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-repositories - pepsighan/papito - A Beginner Friendly Rusty WASM Framework (Rust)
README
# Papito (पपितो) = Papaya
## Deprecated : No Longer Maintained[![Build Status](https://travis-ci.org/csharad/papito.svg?branch=master)](https://travis-ci.org/csharad/papito)
A Vue & React inspired Frontend Web Framework in Rust for the WASM platform. Developed by a beginner for beginners.
### Goals
+ Beginner Friendly. Draws cues from Vue and React.
+ Pure Rust web apps.
+ Cargo only (without webpack). Should provide optional tools that mimic loaders such as `file-loader`, `style-loader`, `url-loader`.It is still under active development. So tread carefully.
### Demo
```rust
#![feature(proc_macro, conservative_impl_trait)]#[macro_use]
extern crate papito_codegen;
#[macro_use]
extern crate papito_dom;
extern crate papito;
#[macro_use]
extern crate stdweb;use papito_codegen::{component, render, events, event};
use papito::prelude::{Render, Lifecycle};
use papito_dom::prelude::VNode;
use papito::App;
use stdweb::web::event::ClickEvent;#[derive(Lifecycle)]
#[component]
struct Div;#[render]
impl Render for Div {
fn render(&self) -> VNode {
h!("div", { "style" => "background-color: #fafafa; color: #666;" },
h!([
h!("This is the front page of web."),
h!(comp Button, { style => "background-color: black; color: white;".to_string() })
]))
}
}#[component]
struct Button {
#[prop]
style: String,
click: bool
}#[events]
impl Button {
#[event]
fn on_click(&mut self, _: ClickEvent) {
let inv = !self.click;
self.set_click(inv);
}
}impl Lifecycle for Button {
fn created(&mut self) {
console!(log, &format!("Initial click value: {}", self.click));
}fn updated(&mut self) {
console!(log, &format!("You clicked the button: {}", self.click));
}
}#[render]
impl Render for Button {
fn render(&self) -> VNode {
let click = self.inner.borrow().click;
let style = self.inner.borrow().style.clone();
h!([
h!("h1", h!("Hello World!")),
h!("button", { "style" => style }, [ self.on_click() ], h!("Click")),
h!("h3", h!(if click { "You clicked" } else { "You unclicked" }))
])
}
}fn main() {
App::new::().render("app");
}
```### Features Supported
* [x] Component props
* [ ] Component Events
* [x] DOM Events
* [x] Reactive states
* [x] Component Lifecycle (only some)
* [x] Server Renderer
* [x] Hyperscript macro h!
* [ ] Vue-like template syntax
* [ ] Context API?