Hirola is an opinionated web framework for that is focused on simplicity and predictability.

Overview

Hirola

Latest Version Build Status MIT licensed

Hirola is an opinionated web framework for that is focused on simplicity and predictability.

Goals

  1. Keep it simple. Most Rust web frameworks have a huge learning curve and verbose syntaxes. We yearn to minimize these.
  2. Make it easy to read, extend and share code. Mixins and components are kept simple and macro-free.
  3. No Context. You can choose passing props down, and/or use the global-state if routing. You can write hook-like functions though.
  4. Familiality. Uses rsx which is very similar to JSX.

Here is a simple example:

use hirola::prelude::*;

fn counter(_: &HirolaApp) -> Dom {
    let state = Signal::new(99);
    let decerement = state.mut_callback(|count, _| *count - 1);
    let incerement = state.mut_callback(|count, _| *count + 1);

    html! {
        <div>
            <button on:click={decerement}>"-"</button>
            <input value={state.get()} disabled/>
            <button on:click={incerement}>"+"</button>
        </div>
    }
}

fn main() {
    let mut app = HirolaApp::new();
    app.mount("body", counter);
}

Mixins

Mixins are hirola's way of extending functionality and following DRY principles. Here is an example:

// Mixin that controls tailwind opacity based on a bool signal
fn opacity<'a>(signal: &'a Signal<bool>) -> Box<dyn Fn(DomNode) -> () + 'a> {
   let cb = move |node: DomNode| {
       let element = node.unchecked_into::<Element>();
       if *signal.get() {
           element.class_list().add_1("opacity-100").unwrap();
           element.class_list().remove_1("opacity-0").unwrap();
       } else {
           element.class_list().add_1("opacity-0").unwrap();
           element.class_list().remove_1("opacity-100").unwrap();
       }
   };
   Box::new(cb)
}

You can now use you mixin on a dom node eg:

html! {
    <div class="bla blah" mixin:transition=opacity(&display)/>
}

Since you are passing a signal, you can now manipulate the signal to change the opacity.

Mixins run in namespaces, eg the one above is run in transition namespace. This allows you to only run specific mixins. The inbuilt form mixins can only be run in mixin:form namespace.

Ecosystem

Here are some extensions for hirola:

  1. Form

Milestones

Status Goal Labels
Write code that is declarative and easy to follow ready
Allow extensibility via mixins ready
Standardize Components inprogress
🚀 SSR First Approach help wanted
🚀 Hydration help wanted
🚀 Serverside integrations help wanted

Inspiration

  • Sycamore/Maple
  • Alpine.js
  • React.js
  • Yew

Demo examples

This API will certainly change.

Go to examples and use trunk

$  trunk serve

Prerequisite:

You need need to have rust, cargo and trunk installed.

License: MIT

Comments
  • added few mixin features

    added few mixin features

    CHANGE LOG

    • added mixin:class
    • remove block style in mixin:show if signal is true
    • added mixin:nshow
    • added DomTokenList in hirola-core cargo.toml
    • added classes~ macro

    Feel free to give any comments :)

    opened by Najidnadri 2
  • Hirola webapp template

    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?

    bug 
    opened by Najidnadri 2
  • Added more info on docs

    Added more info on docs

    Added a bit more examples, description and information in the doc. I really would like to add some more, however I feels like it is better to make it simple for now as breaking changes may occur in the future.

    opened by Najidnadri 1
  • v0.2 Release

    v0.2 Release

    Fixes:

    • [x] #1
    • [x] #2
    • [x] Fix Keyed and Indexed components
    • [x] Allow passing callbacks to components
    • [x] Fix unnecessary braces around function argument for expressions
    • [x] Standardize Form mixins
    • [ ] Add syn-rsx docs
    opened by geofmureithi 0
  • Standardise components

    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

    opened by geofmureithi 0
  • 2-way mixin model input bug

    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>
      }
    }
    
    opened by Najidnadri 1
  • mixin:transition implementation

    mixin:transition implementation

    mixin:transition

    process flow

    • transition function set a new mixintransition attribute for the Element.
    • to activate the transition, enter_transition and leave_transition helper functions are called.

    current status: developing

    current implementation:

    • must have transition feature to use the mixin.
    • the implementation is very similar as in vuejs and alpine. reference: https://sebastiandedeyne.com/javascript-framework-diet/enter-leave-transitions/

    Suggestions on how to make this mixin feature better would be really helpful

    opened by Najidnadri 1
Releases(v0.2.0)
  • v0.2.0(Oct 1, 2022)

    What's Changed

    • v0.2 Release by @geofmureithi in https://github.com/geofmureithi/hirola/pull/3
    • Standardised components in #1 & #2
    • Browser and Unit tests are now passing
    • Improved documentation

    New Contributors

    • @geofmureithi made their first contribution in https://github.com/geofmureithi/hirola/pull/3

    Full Changelog: https://github.com/geofmureithi/hirola/compare/v0.1.7...v0.2.0

    Source code(tar.gz)
    Source code(zip)
  • v0.1.7(Aug 16, 2022)

  • v0.1.3(Aug 1, 2022)

Owner
For my old account see @geofmureithi-zz
null
Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix 16.2k Jan 2, 2023
Sauron is an html web framework for building web-apps. It is heavily inspired by elm.

sauron Guide Sauron is an web framework for creating fast and interactive client side web application, as well as server-side rendering for back-end w

Jovansonlee Cesar 1.7k Dec 26, 2022
A (flash) message framework for actix-web. A port to Rust of Django's message framework.

actix-web-flash-messages Flash messages for actix-web Web applications sometimes need to show a one-time notification to the user - e.g. an error mess

Luca Palmieri 31 Dec 29, 2022
Prettier - Prettier is an opinionated code formatter.

Opinionated Code Formatter JavaScript · TypeScript · Flow · JSX · JSON CSS · SCSS · Less HTML · Vue · Angular GraphQL · Markdown · YAML Your favorite

Prettier 44.6k Jan 7, 2023
Ergonomic and modular web framework built with Tokio, Tower, and Hyper

axum axum is a web application framework that focuses on ergonomics and modularity. More information about this crate can be found in the crate docume

Tokio 7.9k Dec 31, 2022
A rust web framework with safety and speed in mind.

darpi A web api framework with speed and safety in mind. One of the big goals is to catch all errors at compile time, if possible. The framework uses

null 32 Apr 11, 2022
Thruster - An fast and intuitive rust web framework

A fast, middleware based, web framework written in Rust

null 913 Dec 27, 2022
A full-featured and easy-to-use web framework with the Rust programming language.

Poem Framework A program is like a poem, you cannot write a poem without writing it. --- Dijkstra A full-featured and easy-to-use web framework with t

Poem Web 2.2k Jan 6, 2023
Seed is a Rust front-end framework for creating fast and reliable web apps with an Elm-like architecture.

Seed is a Rust front-end framework for creating fast and reliable web apps with an Elm-like architecture.

null 3.6k Jan 6, 2023
The simplest build-time framework for writing web apps with html templates and typescript

Encoped A build-time fast af tool to write static apps with html and TypeScript Features Template-based ESLint, Prettier and Rollup integration No ext

null 1 Dec 11, 2021
Implementation of the RealWorld backend API spec in Actix, Rust's powerful actor system and most fun web framework.

Actix codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API. ❗ (2021/05/13) This cod

Allen 475 Jan 2, 2023
Demo of Rust and axum web framework

Demo of Rust and axum web framework Demonstration of: Rust: programming language that focuses on reliability and stability. axum: web framework that f

Joel Parker Henderson 115 Dec 29, 2022
Starter template for use with the Leptos web framework and Axum.

Leptos Axum Starter Template This is a template for use with the Leptos web framework and the cargo-leptos tool using Axum. Creating your template rep

Leptos 10 Mar 4, 2023
axum-serde is a library that provides multiple serde-based extractors and responders for the Axum web framework.

axum-serde ?? Overview axum-serde is a library that provides multiple serde-based extractors / responses for the Axum web framework. It also offers a

GengTeng 3 Dec 12, 2023
Hot reload static web server for deploying mutiple static web site with version control.

SPA-SERVER It is to provide a static web http server with cache and hot reload. 中文 README Feature Built with Hyper and Warp, fast and small! SSL with

null 7 Dec 18, 2022
Code template for a production Web Application using Axum: The AwesomeApp Blueprint for Professional Web Development.

AwesomeApp rust-web-app More info at: https://awesomeapp.dev/rust-web-app/ rust-web-app YouTube episodes: Episode 01 - Rust Web App - Course to Produc

null 45 Sep 6, 2023
A highly customizable, full scale web backend for web-rwkv, built on axum with websocket protocol.

web-rwkv-axum A axum web backend for web-rwkv, built on websocket. Supports BNF-constrained grammar, CFG sampling, etc., all streamed over network. St

Li Junyu 12 Sep 25, 2023
A Rust web framework

cargonauts - a Rust web framework Documentation cargonauts is a Rust web framework intended for building maintainable, well-factored web apps. This pr

null 179 Dec 25, 2022
A web framework for Rust.

Rocket Rocket is an async web framework for Rust with a focus on usability, security, extensibility, and speed. #[macro_use] extern crate rocket; #[g

Sergio Benitez 19.4k Jan 4, 2023