pub fn trans(
value: impl Into<StyleAttributeValue>,
transition: impl Into<StyleTransition>,
) -> impl StyleAttributeBuilder
Expand description
An ease of use function to create an StyleAttributeBuilder
with a transition.
Examples found in repository?
examples/widget_gallery.rs (line 19)
5fn ui(cx: Scope) -> impl View {
6 let counter = cx.signal(1);
7 let checked = cx.signal(false);
8 let knob_value = cx.signal(0.0);
9 let text = cx.signal(String::new());
10
11 let font_size = cx.memo(|| if *checked.get() { 32 } else { 24 });
12
13 checked.track();
14
15 view! {
16 <Div class="widget-gallery">
17 <Div class="column">
18 <Div class="row">
19 <Text text="Toggle me" style:font-size=trans(font_size, 0.5) />
20 <Checkbox bind:checked=checked />
21 </Div>
22
23 <Button on:press=|_| *counter.modify() += 1>
24 <Text text=format!("Counter: {}", counter.get()) />
25 </Button>
26
27 <Image src="examples/images/image.jpg" />
28
29 <TextInput bind:text=text />
30
31 <Text text=format!("Input: {}", text.get()) />
32 </Div>
33 <Scroll style:max-height=Em(14.0)>
34 <Div style:max-width=Em(8.0)>
35 <Text text=LONG_TEXT />
36 </Div>
37 </Scroll>
38 <Div class="column">
39 <Knob bind:value=knob_value />
40 <Text style:text-align=TextAlign::Center
41 text=format!("{:.2}", knob_value.get()) />
42 </Div>
43 </Div>
44 }
45}