-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: reset queries on analyzer & refactor item explorer for mobile use
- Loading branch information
Showing
4 changed files
with
104 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use leptos::*; | ||
use leptos_router::*; | ||
|
||
/// A button that sets the query property to the given value | ||
#[component] | ||
pub fn QueryButton( | ||
#[prop(into)] query_name: TextProp, | ||
/// default state classes | ||
#[prop(into)] | ||
class: TextProp, | ||
/// classes that will replace the main classes when this is active | ||
#[prop(into)] | ||
active_classes: TextProp, | ||
#[prop(into)] value: TextProp, | ||
#[prop(optional)] default: bool, | ||
/// List of other query names that should be removed when preparing this query | ||
#[prop(optional)] | ||
remove_queries: &'static [&'static str], | ||
children: Box<dyn Fn() -> Fragment>, | ||
) -> impl IntoView { | ||
let Location { | ||
pathname, query, .. | ||
} = use_location(); | ||
let query_1 = query_name.clone(); | ||
let value_1 = value.clone(); | ||
let is_active = move || { | ||
let query_name = query_1.get(); | ||
let value = value_1.get(); | ||
query.with(|q| { | ||
q.get(&query_name) | ||
.as_ref() | ||
.map(|s| s.as_str()) | ||
.unwrap_or_default() | ||
== &value | ||
}) | ||
}; | ||
view! { <a class=move || if is_active() { active_classes.get() } else { class.get() }.to_string() href=move || { | ||
let mut query = query(); | ||
for remove in remove_queries { | ||
query.remove(remove); | ||
} | ||
let _ = query.insert(query_name.get().to_string(), value.get().to_string()); | ||
format!("{}{}", pathname(), query.to_query_string()) | ||
}>{children}</a> } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters