Skip to main content

bridge_drop_zone

Macro bridge_drop_zone 

Source
macro_rules! bridge_drop_zone {
    (
        $(#[$meta:meta])*
        $vis:vis $name:ident {
            $( ($ty:ty, $accepts:ident, $on_drop:ident) ),+ $(,)?
        }
    ) => { ... };
}
Expand description

Generate a bridge drop-zone component for any number of coexisting payload worlds - BridgeDropZone’s recipe, packaged for N > 2 without dyn Any (Rust has no variadic generics, so the component is generated per concrete type list rather than parameterized over one).

Each (Type, accepts_prop, on_drop_prop) row becomes one world: an optional accepts_prop: Callback<Type, bool> filter and a required on_drop_prop: EventHandler<DropOutcome<Type>>. The generated component also takes the shared id/label props, forwards extra attributes to its div, and carries the same styling hooks as DropZone (data-active / data-over, lit by whichever world’s drag qualifies).

Requires use dioxus::prelude::*; in scope, and an ancestor DndProvider for every listed type. Before reaching for three worlds, consider whether one provider with an enum payload reads better.

use dioxus::prelude::*;
use dioxus_dnd::prelude::*;

dioxus_dnd::bridge_drop_zone!(pub StandupZone {
    (Ticket, accepts_ticket, on_drop_ticket),
    (Person, accepts_person, on_drop_person),
    (Alert, accepts_alert, on_drop_alert),
});

rsx! {
    StandupZone {
        label: "agenda",
        accepts_ticket: move |t: Ticket| !t.done,
        on_drop_ticket: move |o: DropOutcome<Ticket>| { /* … */ },
        on_drop_person: move |o: DropOutcome<Person>| { /* … */ },
        on_drop_alert: move |o: DropOutcome<Alert>| { /* … */ },
        "standup agenda"
    }
}