mirror of
https://github.com/adoyle0/thaw.git
synced 2025-02-08 19:03:09 -05:00
fix: Icon returns the function's warning (#127)
This commit is contained in:
parent
4d0adf61ac
commit
1a55b45d01
1 changed files with 18 additions and 10 deletions
|
@ -38,9 +38,9 @@ pub fn Icon(
|
||||||
let icon = icon.get();
|
let icon = icon.get();
|
||||||
|
|
||||||
let style = match (style.clone(), icon.style) {
|
let style = match (style.clone(), icon.style) {
|
||||||
(Some(a), Some(b)) => Some((move || format!("{b} {}", a.get())).into_attribute()),
|
(Some(a), Some(b)) => Some(Memo::new(move |_| format!("{b} {}", a.get())).into()),
|
||||||
(Some(a), None) => Some((move || a.get()).into_attribute()),
|
(Some(a), None) => Some(a),
|
||||||
(None, Some(b)) => Some(b.into_attribute()),
|
(None, Some(b)) => Some(b.into()),
|
||||||
(None, None) => None,
|
(None, None) => None,
|
||||||
};
|
};
|
||||||
icon_style.set(style);
|
icon_style.set(style);
|
||||||
|
@ -49,14 +49,14 @@ pub fn Icon(
|
||||||
icon_y.set(icon.y.map(|y| y.into_attribute()));
|
icon_y.set(icon.y.map(|y| y.into_attribute()));
|
||||||
|
|
||||||
let width = match (width.clone(), icon.width) {
|
let width = match (width.clone(), icon.width) {
|
||||||
(Some(a), _) => (move || a.get()).into_attribute(),
|
(Some(a), _) => a,
|
||||||
_ => "1em".into_attribute(),
|
_ => "1em".into(),
|
||||||
};
|
};
|
||||||
icon_width.set(Some(width));
|
icon_width.set(Some(width));
|
||||||
|
|
||||||
let height = match (height.clone(), icon.height) {
|
let height = match (height.clone(), icon.height) {
|
||||||
(Some(a), _) => (move || a.get()).into_attribute(),
|
(Some(a), _) => a,
|
||||||
_ => "1em".into_attribute(),
|
_ => "1em".into(),
|
||||||
};
|
};
|
||||||
icon_height.set(Some(height));
|
icon_height.set(Some(height));
|
||||||
|
|
||||||
|
@ -72,11 +72,11 @@ pub fn Icon(
|
||||||
view! {
|
view! {
|
||||||
<svg
|
<svg
|
||||||
class=class.map(|c| c.get())
|
class=class.map(|c| c.get())
|
||||||
style=move || take(icon_style)
|
style=move || take_signal(icon_style)
|
||||||
x=move || take(icon_x)
|
x=move || take(icon_x)
|
||||||
y=move || take(icon_y)
|
y=move || take(icon_y)
|
||||||
width=move || take(icon_width)
|
width=move || take_signal(icon_width)
|
||||||
height=move || take(icon_height)
|
height=move || take_signal(icon_height)
|
||||||
viewBox=move || take(icon_view_box)
|
viewBox=move || take(icon_view_box)
|
||||||
stroke-linecap=move || take(icon_stroke_linecap)
|
stroke-linecap=move || take(icon_stroke_linecap)
|
||||||
stroke-linejoin=move || take(icon_stroke_linejoin)
|
stroke-linejoin=move || take(icon_stroke_linejoin)
|
||||||
|
@ -88,6 +88,14 @@ pub fn Icon(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn take_signal(signal: RwSignal<Option<MaybeSignal<String>>>) -> Option<String> {
|
||||||
|
signal.with(|s| match s {
|
||||||
|
Some(MaybeSignal::Static(value)) => Some(value.clone()),
|
||||||
|
Some(MaybeSignal::Dynamic(signal)) => Some(signal.get()),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn take(signal: RwSignal<Option<Attribute>>) -> Option<Attribute> {
|
fn take(signal: RwSignal<Option<Attribute>>) -> Option<Attribute> {
|
||||||
signal.track();
|
signal.track();
|
||||||
signal.try_update_untracked(|value| value.take()).flatten()
|
signal.try_update_untracked(|value| value.take()).flatten()
|
||||||
|
|
Loading…
Add table
Reference in a new issue