Hirola is an opinionated web framework for that is focused on simplicity and predictability.
Here is a simple example:
```rust use hirola::prelude::*;
fn counter(: &HirolaApp) -> Dom { let state = Signal::new(99); let decerement = state.mutcallback(|count, | *count - 1); let incerement = state.mutcallback(|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 are hirola's way of extending functionality and following DRY principles. Here is an example:
rust
// 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:
rust
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.
Here are some extensions for hirola:
| 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
|
This API will certainly change.
Go to examples
and use trunk
$ trunk serve
You need need to have rust
, cargo
and trunk
installed.
License: MIT