-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dropdown #265
Add dropdown #265
Conversation
Another issue is that the overlay doesn't maintain relative position when the window is resized |
I'm about to write a wall of text specifically about the API, so I'll focus exclusively on that. Is there a specific rationale for choosing Although not writing to the signal internally is consistent with what most widgets do, dropdown(
a_list.iter(),
|item| {
stack((
label(move || item),
chevron_down_icon_view,
))
.style(|s| s.items_center().justify_between().size_full())
},
rw_signal,
) It's a slightly simpler, but more restrictive API. If my memory serves me well, several UI frameworks including Vue follow a "data bubbles down, events bubble up" strategy where the UI component merely reads the variable and emits an event to indicate changes by the user. It seems like a good principle, and your proposal seems consistent with that, so I've also been contemplating the implications of having an dropdown(
a_list.iter(),
|item| {
stack((
label(move || item),
chevron_down_icon_view,
))
.style(|s| s.items_center().justify_between().size_full())
},
signal,
).on_change(move |_, new_value| set_signal.set(new_value)) This feels like a bit of a compromise between the flexibility of letting the caller control the event handler and the simplicity of keeping the lower level stuff behind the scenes. Currently I quite like this, although I haven't sufficiently considered possible downsides to voice a definitive opinion about it. So to recap, the options I see:
(Disclaimer: I haven't tested any of the snippets, just making this up as I go along) |
Another thing to be added is a function to drive the open/close state of the list Edit: implemented |
172a54f
to
6a226c9
Compare
@pieterdd I want the on_change api for this but I took a stab at implementing it and couldn't get it to work |
@jrmoulton I couldn't implement a working |
I'm open for any feedback @dzhou121 but I think this is good to merge for now |
const CHEVRON_DOWN: &str = r#"<?xml version="1.0" encoding="iso-8859-1"?> | ||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --> | ||
<svg height="800px" width="800px" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" | ||
viewBox="0 0 185.344 185.344" xml:space="preserve"> | ||
<g> | ||
<g> | ||
<path style="fill:#010002;" d="M92.672,144.373c-2.752,0-5.493-1.044-7.593-3.138L3.145,59.301c-4.194-4.199-4.194-10.992,0-15.18 | ||
c4.194-4.199,10.987-4.199,15.18,0l74.347,74.341l74.347-74.341c4.194-4.199,10.987-4.199,15.18,0 | ||
c4.194,4.194,4.194,10.981,0,15.18l-81.939,81.934C98.166,143.329,95.419,144.373,92.672,144.373z"/> | ||
</g> | ||
</g> | ||
</svg>"#; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we fix up the SVG markup a bit:
const CHEVRON_DOWN: &str = r#<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 185.344 185.344">
<path fill="#010002" d="M92.672 144.373a10.707 10.707 0 0 1-7.593-3.138L3.145 59.301c-4.194-4.199-4.194-10.992 0-15.18a10.72 10.72 0 0 1 15.18 0l74.347 74.341 74.347-74.341a10.72 10.72 0 0 1 15.18 0c4.194 4.194 4.194 10.981 0 15.18l-81.939 81.934a10.694 10.694 0 0 1-7.588 3.138z"/>
</svg>"#;
Note I haven't tested the SVG in your code, only the SVG code itself
Just started checking the recent discussions on the |
05718ef
to
2288429
Compare
3bdeba6
to
07729d7
Compare
Add dropdown example Update svg syntax Co-authored-by: Dominik Wilkowski <[email protected]> Get dropdown styling working Fix ups to styles and event handling Update dropdown example in widget gallery
07729d7
to
af039ff
Compare
@pieterdd
I'm marking this as a draft because I still need to add docs / examples and it'd be awesome if @pieterdd / anyone else could give some feedback on it.
This has an issue with styling being removed from the overlay when the overlay receives events.
sort of example:
Like other widgets this doesn't automatically set the active item when an item in the list is clicked. Currently I am adding an on click handle to each item in the list. Feedback on this api would be nice.