perf: cargo clippy

This commit is contained in:
luoxiao 2023-10-18 10:09:55 +08:00
parent 0279ace8d0
commit cf96d5e6b2
10 changed files with 17 additions and 17 deletions

View file

@ -55,15 +55,15 @@ pub fn Alert(
let variant = variant.get(); let variant = variant.get();
css_vars.push_str(&format!( css_vars.push_str(&format!(
"--icon-color: {};", "--icon-color: {};",
variant.theme_icon_color(&theme) variant.theme_icon_color(theme)
)); ));
css_vars.push_str(&format!( css_vars.push_str(&format!(
"--background-color: {};", "--background-color: {};",
variant.theme_background_color(&theme) variant.theme_background_color(theme)
)); ));
css_vars.push_str(&format!( css_vars.push_str(&format!(
"--border-color: {};", "--border-color: {};",
variant.theme_border_color(&theme) variant.theme_border_color(theme)
)); ));
}); });

View file

@ -58,7 +58,7 @@ pub fn AutoComplete(
<div <div
class="melt-auto-complete__menu" class="melt-auto-complete__menu"
style=move || { style=move || {
if is_show_menu.get() { String::new() } else { format!("display: none;") } if is_show_menu.get() { None } else { Some("display: none;") }
} }
ref=auto_complete_menu_ref ref=auto_complete_menu_ref

View file

@ -31,7 +31,7 @@ pub fn Badge(
mount_style("badge", include_str!("./badge.css")); mount_style("badge", include_str!("./badge.css"));
let css_vars = create_memo(move |_| { let css_vars = create_memo(move |_| {
let mut css_vars = String::new(); let mut css_vars = String::new();
css_vars.push_str(&format!("--font-color: #fff;")); css_vars.push_str("--font-color: #fff;");
theme.with(|theme| { theme.with(|theme| {
css_vars.push_str(&format!( css_vars.push_str(&format!(
"--background-color: {};", "--background-color: {};",

View file

@ -73,13 +73,13 @@ pub fn Button(
css_vars.push_str(&format!("--background-color: {bg_color};")); css_vars.push_str(&format!("--background-color: {bg_color};"));
css_vars.push_str(&format!("--background-color-hover: {bg_color_hover};")); css_vars.push_str(&format!("--background-color-hover: {bg_color_hover};"));
css_vars.push_str(&format!("--background-color-active: {bg_color_active};")); css_vars.push_str(&format!("--background-color-active: {bg_color_active};"));
css_vars.push_str(&format!("--font-color: #fff;")); css_vars.push_str("--font-color: #fff;");
css_vars.push_str(&format!("--border-color: {bg_color};")); css_vars.push_str(&format!("--border-color: {bg_color};"));
css_vars.push_str(&format!("--border-color-hover: {bg_color};")); css_vars.push_str(&format!("--border-color-hover: {bg_color};"));
} else { } else {
css_vars.push_str(&format!("--font-color-hover: {bg_color};")); css_vars.push_str(&format!("--font-color-hover: {bg_color};"));
css_vars.push_str(&format!("--border-color: #555a;")); css_vars.push_str("--border-color: #555a;");
css_vars.push_str(&format!("--border-color-hover: #555;")); css_vars.push_str("--border-color-hover: #555;");
} }
css_vars css_vars

View file

@ -95,7 +95,7 @@ pub fn ColorPicker(#[prop(optional, into)] value: MaybeRwSignal<RGBA>) -> impl I
class="melt-color-picker-popover" class="melt-color-picker-popover"
ref=popover_ref ref=popover_ref
style=move || { style=move || {
if !is_show_popover.get() { format!("display: none").into() } else { None } if !is_show_popover.get() { Some("display: none") } else { None }
} }
> >
@ -143,7 +143,7 @@ fn ColorPanel(hue: ReadSignal<u16>, sv: RwSignal<(f64, f64)>) -> impl IntoView {
let on_mouse_move = window_event_listener(ev::mousemove, cb); let on_mouse_move = window_event_listener(ev::mousemove, cb);
let on_mouse_up = window_event_listener(ev::mouseup, move |_| { let on_mouse_up = window_event_listener(ev::mouseup, move |_| {
mouse.update_value(|value| { mouse.update_value(|value| {
for handle in value.drain(..).into_iter() { for handle in value.drain(..) {
handle.remove(); handle.remove();
} }
}); });
@ -205,7 +205,7 @@ fn HueSlider(hue: RwSignal<u16>) -> impl IntoView {
let on_mouse_move = window_event_listener(ev::mousemove, cb); let on_mouse_move = window_event_listener(ev::mousemove, cb);
let on_mouse_up = window_event_listener(ev::mouseup, move |_| { let on_mouse_up = window_event_listener(ev::mouseup, move |_| {
mouse.update_value(|value| { mouse.update_value(|value| {
for handle in value.drain(..).into_iter() { for handle in value.drain(..) {
handle.remove(); handle.remove();
} }
}); });

View file

@ -15,7 +15,7 @@ pub fn show_toast(options: ToastOptions) {
let children = view! { <div class="melt-toast">{options.message}</div> }; let children = view! { <div class="melt-toast">{options.message}</div> };
let node = children.into_view(); let node = children.into_view();
#[cfg(all(target_arch = "wasm32"))] #[cfg(target_arch = "wasm32")]
{ {
use leptos::leptos_dom::Mountable; use leptos::leptos_dom::Mountable;
let node = node.get_mountable_node(); let node = node.get_mountable_node();

View file

@ -18,8 +18,8 @@ pub fn Tabs(
mount_style("tabs", include_str!("./tabs.css")); mount_style("tabs", include_str!("./tabs.css"));
let tab_options_vec = create_rw_signal(vec![]); let tab_options_vec = create_rw_signal(vec![]);
provide_context(TabsInjectionKey { provide_context(TabsInjectionKey {
active_key: value.deref().clone(), active_key: *value.deref(),
tab_options_vec: tab_options_vec.clone(), tab_options_vec,
}); });
let theme = use_theme(Theme::light); let theme = use_theme(Theme::light);
let css_vars = create_memo(move |_| { let css_vars = create_memo(move |_| {

View file

@ -13,7 +13,7 @@ pub fn Teleport(#[prop(optional)] to: Option<&'static str>, children: Children)
Element::from(document().body().expect("body element not to exist")) Element::from(document().body().expect("body element not to exist"))
}; };
#[cfg(all(target_arch = "wasm32"))] #[cfg(target_arch = "wasm32")]
{ {
use leptos::leptos_dom::Mountable; use leptos::leptos_dom::Mountable;
let node = children().into_view(); let node = children().into_view();

View file

@ -5,7 +5,7 @@ pub struct MaybeRwSignal<T: Default + 'static>(RwSignal<T>);
impl<T: Default> MaybeRwSignal<T> { impl<T: Default> MaybeRwSignal<T> {
pub fn clone_into(&self) -> RwSignal<T> { pub fn clone_into(&self) -> RwSignal<T> {
self.0.clone() self.0
} }
} }

View file

@ -29,7 +29,7 @@ impl<T> SignalWatch for RwSignal<T> {
/// count.set(2); // nothing happens /// count.set(2); // nothing happens
/// ``` /// ```
fn watch(&self, f: impl Fn(&Self::Value) + 'static) -> Box<dyn FnOnce()> { fn watch(&self, f: impl Fn(&Self::Value) + 'static) -> Box<dyn FnOnce()> {
let signal = self.clone(); let signal = *self;
let effect = create_effect(move |prev| { let effect = create_effect(move |prev| {
signal.with(|value| { signal.with(|value| {