Skip to content

Commit 285aba5

Browse files
committed
render! -> rsx!
1 parent fbdfcb8 commit 285aba5

File tree

179 files changed

+109
-10645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+109
-10645
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
fn app(cx: Scope) -> Element {
2424
let mut count = use_state(cx, || 0);
2525
26-
render!(
26+
rsx!(
2727
rect {
2828
height: "20%",
2929
width: "100%",

book/src/guides/animating.md

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +0,0 @@
1-
# Animating
2-
3-
Freya provides you with two hooks to help you animate your components.
4-
5-
### `use_animation`
6-
7-
This a very simple hook that will let you animate a certain value from an `inital` value to a `final` value, in a given `duration` of time. There are a few animations that you can choose from:
8-
9-
- Linear
10-
- EaseIn
11-
- EaseInOut
12-
- BounceIns
13-
14-
Here is an example that will animate a value from `0.0` to `100.0` in `50` milliseconds, using the `linear` animation.
15-
16-
```rust, no_run
17-
fn main() {
18-
launch(app);
19-
}
20-
21-
fn app(cx: Scope) -> Element {
22-
let animation = use_animation(cx, || 0.0);
23-
24-
let progress = animation.value();
25-
26-
use_memo(cx, (), move |_| {
27-
animation.start(Animation::new_linear(0.0..=100.0, 50));
28-
});
29-
30-
render!(rect {
31-
width: "{progress}",
32-
})
33-
}
34-
```
35-
36-
### `use_animation_transition`
37-
38-
This hook let's you group a set of animations together with a certain type of `animation` and a given `duration`. You can also specifiy a set of dependencies that will make animations callback re run.
39-
40-
Just like `use_animation` you have these animations:
41-
42-
- Linear
43-
- EaseIn
44-
- EaseInOut
45-
- BounceIns
46-
47-
Here is an example that will animate a `size` and a color in `200` milliseconds, using the `new_sine_in_out` animation.
48-
49-
```rust, no_run
50-
fn main() {
51-
launch(app);
52-
}
53-
54-
const TARGET: f64 = 500.0;
55-
56-
fn app(cx: Scope) -> Element {
57-
let animation = use_animation_transition(cx, TransitionAnimation::new_sine_in_out(200), (), || {
58-
vec![
59-
Animate::new_size(0.0, TARGET),
60-
Animate::new_color("rgb(33, 158, 188)", "white"),
61-
]
62-
});
63-
64-
let size = animation.get(0).unwrap().as_size();
65-
let background = animation.get(1).unwrap().as_color();
66-
67-
let onclick = move |_: MouseEvent| {
68-
if size == 0.0 {
69-
animation.start();
70-
} else if size == TARGET {
71-
animation.reverse();
72-
}
73-
};
74-
75-
render!(
76-
rect {
77-
overflow: "clip",
78-
background: "black",
79-
width: "100%",
80-
height: "100%",
81-
offset_x: "{size}",
82-
rect {
83-
height: "100%",
84-
width: "200",
85-
background: "{background}",
86-
onclick: onclick,
87-
}
88-
}
89-
)
90-
}
91-
```

book/src/guides/effects.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +0,0 @@
1-
# Effects
2-
3-
Learn how the effects attributes work.
4-
5-
- [`rotate`](#rotate)
6-
7-
### rotate
8-
9-
The `rotate` attribute let's you rotate an element.
10-
11-
Example:
12-
13-
```rust, no_run
14-
fn app(cx: Scope) -> Element {
15-
render!(
16-
label {
17-
rotate: "180deg",
18-
"Hello, World!"
19-
}
20-
)
21-
}
22-
```
23-
24-
25-
Compatible elements: all except [`text`](/guides/elements.html#paragraph-and-text).

book/src/guides/elements.md

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +0,0 @@
1-
# Elements
2-
3-
Freya contains a set of primitive elements:
4-
5-
- [`rect`](#rect)
6-
- [`label`](#label)
7-
- [`image`](#image)
8-
- [`svg`](#svg)
9-
- [`paragraph and text`](#paragraph-and-text-and-text)
10-
11-
## rect
12-
13-
The `rect` element (aka `rectangle`) is a box where you can place as many elements inside you want.
14-
You can specify things like [`width`](/guides/layout.html#width), [`paddings`](/guides/layout.html#padding) or even in what [`direction`](/guides/layout.html#direction) the inner elements are stacked.
15-
16-
Example:
17-
18-
```rust, no_run
19-
fn app(cx: Scope) -> Element {
20-
render!(
21-
rect {
22-
direction: "vertical",
23-
label { "Hi!" }
24-
label { "Hi again!"}
25-
}
26-
)
27-
}
28-
```
29-
30-
### label
31-
32-
The `label` element simply shows some text.
33-
34-
Example:
35-
36-
```rust, no_run
37-
fn app(cx: Scope) -> Element {
38-
render!(
39-
label {
40-
"Hello World"
41-
}
42-
)
43-
}
44-
```
45-
46-
### svg
47-
48-
The `svg` element let's you draw a SVG. You will need to use the `bytes_to_data` to transform the bytes into data the element can recognize.
49-
50-
Example:
51-
52-
```rust, no_run
53-
54-
static FERRIS: &[u8] = include_bytes!("./ferris.svg");
55-
56-
fn app(cx: Scope) -> Element {
57-
let ferris = bytes_to_data(cx, FERRIS);
58-
render!(
59-
svg {
60-
svg_data: ferris,
61-
}
62-
)
63-
}
64-
```
65-
66-
### image
67-
68-
The `image` element, just like `svg` element, require you to pass the image bytes yourself.
69-
70-
```rust, no_run
71-
static RUST_LOGO: &[u8] = include_bytes!("./rust_logo.png");
72-
73-
fn app(cx: Scope) -> Element {
74-
let image_data = bytes_to_data(cx, RUST_LOGO);
75-
render!(
76-
image {
77-
image_data: image_data,
78-
width: "{size}",
79-
height: "{size}",
80-
}
81-
)
82-
}
83-
```
84-
85-
### paragraph and text
86-
87-
Both `paragraph` and `text` elements are used together. They will let you build texts with different styles.
88-
89-
``` rust
90-
fn app(cx: Scope) -> Element {
91-
render!(
92-
paragraph {
93-
text {
94-
font_size: "15",
95-
"Hello, "
96-
}
97-
text {
98-
font_size: "30",
99-
"World!"
100-
}
101-
}
102-
)
103-
}
104-
```

0 commit comments

Comments
 (0)