Skip to main content

Module board

Module board 

Source
Expand description

Cross-container moves - the kanban pattern. Items travel between columns (and optionally to a position within a column) via the shared crate::core::DndContext.

The payload type flowing through the context is BoardPayload<T>, which remembers where the item came from. Wrap your app (or board) in DndProvider::<BoardPayload<Card>>.

DndProvider::<BoardPayload<Card>> {
    for (col_id, cards) in columns {
        BoardColumn::<Card> {
            id: col_id,
            on_move: move |mv: MoveEvent<Card>| {
                apply_move(&mut board.write(), &mv);
            },
            for (ix, card) in cards.iter().enumerate() {
                BoardItem::<Card> { item: card.clone(), column: col_id, index: ix,
                    CardView { card: card.clone() }
                }
            }
        }
    }
}

Re-exports§

pub use BoardItem_completions::Component::BoardItem;
pub use BoardColumn_completions::Component::BoardColumn;
pub use BoardSlot_completions::Component::BoardSlot;

Structs§

BoardColumnProps
Properties for the BoardColumn component.
BoardItemProps
Properties for the BoardItem component.
BoardPayload
What travels through the context while a board item is dragged.
BoardSlotProps
Properties for the BoardSlot component.
MoveEvent
A completed cross-container move.

Functions§

BoardColumn
A column that receives BoardItems. Emits MoveEvent with to.1 = None (append). For precise within-column positions, nest BoardSlots between items.
BoardItem
A draggable card living in a column. Thin wrapper over crate::core::Draggable that packs origin info into the payload.
BoardSlot
An insertion point between items in a column. Dropping on it produces a MoveEvent targeting exactly (column, Some(index)).
apply_move
Apply a MoveEvent to a HashMap<ContainerId, Vec<T>> board model. Removes from the source (by index, falling back gracefully if the model drifted) and inserts at the target position.

Type Aliases§

ContainerId
Columns are just zones.