Giter VIP home page Giter VIP logo

hirola's Introduction

Hirola

Latest Version Browser Tests Unit Tests MIT licensed

Hirola is a declarative frontend framework that is focused on simplicity and reactivity.

Goals

  1. KISS: A simple and declarative way to build frontend UIs in rust.
  2. Make it easy to read, extend and share code.
  3. Frp signals allowing fine-grained reactivity.
  4. Familiarity: Uses rsx which is very similar to jsx.

Example

We are going to create a simple counter program.

cargo new counter

With a new project, we need to create an index file which is the entry point and required by trunk

cd counter

Create an index.html in the root of counter. Add the contents below

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hirola Counter</title>
  </head>
  <body></body>
</html>

Lets add some code to src/main.rs

use hirola::prelude::*;
use hirola::dom::*;

fn counter() -> Dom {
    let count = Mutable::new(0i32);
    let decrement = count.callback(|s| *s.lock_mut() -= 1);
    let increment = count.callback(|s| *s.lock_mut() += 1);
    html! {
        <>
            <button on:click=decrement>"-"</button>
            <span>{count}</span>
            <button on:click=increment>"+"</button>
        </>
    }
}
fn main() {
    hirola::dom::mount(counter()).unwrap();
}

Now lets run our project

trunk serve

Ecosystem

Check out Hirola Docs written with Hirola itself!

Here are some extensions for hirola:

  1. Form
  2. Router
  3. State
  4. Markdown

Milestones

Status Goal Labels
Basic templating with rust and rsx ready
Extend functionality with mixins ready
Components ready
SSR ready
Signals ready
🚧 Form management started
Markdown templating pending
🚧 Styling started
SSG pending

hirola's People

Contributors

c12i avatar geofmureithi avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hirola's Issues

`fake-api` example does not compile

Running trunk serve results in compilation errors

error[E0432]: unresolved import `crate::generic_node::DomType`
 --> crates/hirola-core/src/dom.rs:2:20
  |
2 |     generic_node::{DomType, GenericNode},
  |                    ^^^^^^^ no `DomType` in `generic_node`

error[E0432]: unresolved import `crate::generic_node::DomType`
 --> crates/hirola-core/src/render.rs:4:20
  |
4 |     generic_node::{DomType, GenericNode},
  |                    ^^^^^^^ no `DomType` in `generic_node`

error[E0432]: unresolved import `crate::generic_node::DomType`
 --> crates/hirola-core/src/templating/flow.rs:6:27
  |
6 | use crate::generic_node::{DomType, GenericNode};
  |                           ^^^^^^^ no `DomType` in `generic_node`

error[E0432]: unresolved import `crate::generic_node::DomType`
 --> crates/hirola-core/src/templating/noderef.rs:2:5
  |
2 | use crate::generic_node::DomType;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `DomType` in `generic_node`

error[E0432]: unresolved import `crate::generic_node::DomType`
 --> crates/hirola-core/src/templating/suspense.rs:3:20
  |
3 |     generic_node::{DomType, GenericNode},
  |                    ^^^^^^^ no `DomType` in `generic_node`

error[E0432]: unresolved import `crate::generic_node::DomType`
 --> crates/hirola-core/src/templating/switch.rs:7:20
  |
7 |     generic_node::{DomType, GenericNode},
  |                    ^^^^^^^ no `DomType` in `generic_node`

error[E0412]: cannot find type `Event` in this scope
  --> crates/hirola-core/src/generic_node.rs:22:33
   |
22 | pub type EventListener = dyn Fn(Event);
   |                                 ^^^^^ not found in this scope

warning: unused import: `crate::dom::*`
  --> crates/hirola-core/src/lib.rs:36:5
   |
36 | use crate::dom::*;
   |     ^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

    Checking gloo-net v0.1.0
error[E0308]: mismatched types
   --> crates/hirola-core/src/dom.rs:128:33
    |
128 |     pub fn inner_html(&self) -> String {
    |            ----------           ^^^^^^ expected `String`, found `()`
    |            |
    |            implicitly returns `()` as its body has no tail or `return` expression

warning: unused import: `GenericNode`
 --> crates/hirola-core/src/dom.rs:2:29
  |
2 |     generic_node::{DomType, GenericNode},
  |                             ^^^^^^^^^^^

warning: unused import: `GenericNode`
 --> crates/hirola-core/src/render.rs:4:29
  |
4 |     generic_node::{DomType, GenericNode},
  |                             ^^^^^^^^^^^

warning: unused import: `GenericNode`
 --> crates/hirola-core/src/templating/flow.rs:6:36
  |
6 | use crate::generic_node::{DomType, GenericNode};
  |                                    ^^^^^^^^^^^

warning: unused import: `GenericNode`
 --> crates/hirola-core/src/templating/switch.rs:7:29
  |
7 |     generic_node::{DomType, GenericNode},
  |                             ^^^^^^^^^^^

warning: unused import: `GenericNode`
 --> crates/hirola-core/src/templating/suspense.rs:3:29
  |
3 |     generic_node::{DomType, GenericNode},
  |                             ^^^^^^^^^^^

Some errors have detailed explanations: E0308, E0412, E0432.
For more information about an error, try `rustc --explain E0308`.
warning: `hirola-core` (lib) generated 6 warnings
error: could not compile `hirola-core` (lib) due to 8 previous errors; 6 warnings emitted
warning: build failed, waiting for other jobs to finish...

I suspect the example is missing the "dom" feature perhaps. From my testing locally, adding this feature fixes this issue. Should I open a PR for this?

Standardise components

Right now you can write components as functions starting with uppercase.

Eg,

fn Todo(router: Router) -> Dom

then used in rsx

<Todo router={router} />

While this works, there are a few weaknesses

  1. Props must be ordered in the way of the function's signature.
  2. Because of 1, then names of props are not respected.

These two changes may be enforced with a proc-macro similar to Yew's #Component

Hirola webapp template

Hello there!

Saw this project a few days ago and thought it would be one of the best competitor to the current modern frameworks. So I created a template for it :). link is here. The design pattern is very similar to that in VueJS because of how easy for a beginner to learn.

However, I got one problem,

Clicking on this link successfully changes the url path, but somehow the content of the page is not rendered. Although it will change after I refresh the page.

<a mixin::route=&router.link() href="/about" class="about">"About Us"</a>

Any idea?

2-way mixin model input bug

bug description:
2-way binding doesnt work on mixin:input. The input field didn't change when the Signal's value changes.

recreate bug:

fn page(_: HirolaApp) -> Dom {
  let state = Signal::new(String::new());
  
  //clicking submit will reset the state
  let submit_handler = state.callback(move |st, _: Event| {
      st.set(String::new());
  });
  
  html! {
    <div>
      <p><span mixin:text=&text(&state) /></p>
      <input type="text" mixin:model=&input(&state) />
      <button on:click=submit_handler>"submit"</button>
    </div>
  }
}

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

cargo
Cargo.toml
  • document-features 0.2
  • wasm-bindgen-test 0.3.42
  • wasm-bindgen 0.2.92
  • futures-util 0.3
  • web-sys 0.3
crates/hirola-core/Cargo.toml
  • futures-signals 0.3.33
  • futures-util 0.3
  • criterion 0.3
  • wasm-bindgen-test 0.3
  • web-sys 0.3
crates/hirola-dom/Cargo.toml
  • wasm-bindgen 0.2
  • log 0.4
  • matchit 0.7
  • wasm-bindgen-futures 0.4.42
  • discard 1
  • strum 0.25.0
  • web-sys 0.3.69
  • wasm-bindgen-test 0.3.42
crates/hirola-form/Cargo.toml
  • wasm-bindgen 0.2
  • serde 1.0.197
  • web-sys 0.3
crates/hirola-kit/Cargo.toml
  • leptosfmt-pretty-printer 0.1.8
  • rstml 0.11.2
  • syn 2.0.52
  • leptosfmt-prettyplease 0.2.16
  • proc-macro2 1.0.79
  • thiserror 1.0.58
  • crop 0.4.2
  • serde 1.0.197
  • clap 4.5.2
  • rayon 1.9.0
  • glob 0.3.1
  • anyhow 1.0.81
  • toml 0.8.11
  • indoc 2.0.4
  • insta 1.36.1
  • quote 1.0.35
crates/hirola-macros/Cargo.toml
  • proc-macro2 1.0.79
  • quote 1.0.35
  • syn 2.0.52
  • rstml 0.11
  • proc-macro-error 1.0
  • proc-macro-hack 0.5
  • paste 1
  • heck 0.4.1
  • trybuild 1.0
crates/hirola-ssr/Cargo.toml
  • html-escape 0.2.13
  • wasm-bindgen-test 0.3.42
github-actions
.github/workflows/browser.yml
  • actions/checkout v4
.github/workflows/preview.yml
  • actions/checkout v4
  • actions-rs/toolchain v1
.github/workflows/production.yml
  • actions/checkout v4
  • actions-rs/toolchain v1
.github/workflows/unit.yml
  • actions/checkout v4
  • actions-rs/toolchain v1

  • Check this box to trigger a request for Renovate to run again on this repository

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.