Skip to content

Commit

Permalink
comps, hooks and animation, wip
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Aug 18, 2024
1 parent 44f26db commit c3f85ee
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
21 changes: 21 additions & 0 deletions book/src/learn/animation.md
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
# Animation

Freya comes with a `use_animation` hook to create and manage animations in declarative way.

TODO

Example:
```rs
fn app() -> Element {
let animation = use_animation(|ctx| {
ctx.auto_start(true);
ctx.with(AnimNum::new(0., 100.).time(50))
});

let width = animation.get().read().as_f32();

rsx!(rect {
width: "{width}",
height: "100%",
background: "blue"
})
}
27 changes: 27 additions & 0 deletions book/src/learn/built_in_components.md
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
# Built-in Components

Freya comes with a set of styled and functional components you may use to develop faster. Some examples as `Button`, `Switch`, `Scrollview`, etc.

You can find more about them in [their docs](https://docs.rs/freya-components).

Example:
```rs
fn app() -> Element {
let mut enabled = use_signal(|| true);

rsx!(
ScrollView {
Button {
onclick: |_| {
println!("Button was clicked!");
}
}
Switch {
enabled: enabled(),
ontoggled: move |_| {
enabled.toggle();
}
}
}
)
}
```
23 changes: 23 additions & 0 deletions book/src/learn/built_in_hooks.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# Built-in Hooks

Freya comes with a set hooks to simplify various tasks, such as animations, accessibility, text editing and more.

You can find more about them in [their docs](https://docs.rs/freya-hooks).

Example:
```rs
fn app() -> Element {
let mut my_focus = use_focus();

rsx!(
rect {
width: "100%",
height: "100%",
focus_id: my_focus.attribute(),
onclick: move |_| my_focus.focus(),
label {
"{my_focus.is_focused()}"
}
}
)
}
```

0 comments on commit c3f85ee

Please sign in to comment.