limn
    ↑↓ ChooseEnter OpenEsc Close
    GitHub

    Components/Navigation

    ChatMinimap

    A conversation's turns as a rail of short marks beside it, to see where you are in a long one and jump to another turn.

    Native componentGuide source

    Preview

    CodeSource
    fn view(state: &State, palette: ComponentPalette) -> Element {
        let marks = state
            .turns
            .iter()
            .map(|turn| ChatMinimapMark::new(format!("turn={}", turn.index), &turn.question).preview(&turn.answer))
            .collect();
        ChatMinimap::new("minimap", marks, palette)
            .active(format!("turn={}", state.turn_in_view))
            .render()
    }
    
    fn update(state: &mut State, action: &UiAction) {
        if let UiAction::Clicked { id } = action {
            if let Some(turn) = id.strip_prefix("turn=") {
                state.scroll_to_turn(turn);
            }
        }
    }

    ChatMinimap

    A conversation’s turns as a rail of short marks beside it, to see where you are in a long one and jump to another turn.

    Import

    use limn::{ChatMinimap, ChatMinimapMark, Component};

    Usage

    Give it one mark for each turn, and the mark of the turn in view. A click on a mark reports its ID, and the host scrolls that turn into view.

    fn view(state: &State, palette: ComponentPalette) -> Element {
        let marks = state
            .turns
            .iter()
            .map(|turn| ChatMinimapMark::new(format!("turn={}", turn.index), &turn.question).preview(&turn.answer))
            .collect();
        ChatMinimap::new("minimap", marks, palette)
            .active(format!("turn={}", state.turn_in_view))
            .render()
    }
    
    fn update(state: &mut State, action: &UiAction) {
        if let UiAction::Clicked { id } = action {
            if let Some(turn) = id.strip_prefix("turn=") {
                state.scroll_to_turn(turn);
            }
        }
    }

    Marks

    ChatMinimapMark::new(id, title) is one turn, and preview a line of what it says. The mark under the pointer or with the focus grows and its neighbours step down, and it shows the title and the preview in a tooltip at once, without the wait of other hints.

    The turn in view

    active(id) marks the turn the conversation shows now. The host passes it each frame as the conversation scrolls.

    Keyboard

    KeyEffect
    Up, DownMove the focus to the next mark and report it. They stop at the ends of the rail.
    HomeMoves to the first mark and reports it.

    Actions

    ActionWhen
    UiAction::Clicked { id } with a mark’s IDA mark is clicked, or reached with the keyboard.

    Accessibility

    The marks are drawn by the tree, not built as controls, so the platform is told nothing of them yet.

    API reference

    The guide covers composition, options and actions. Generate the complete Rust type and builder reference from the checkout:

    cargo doc -p limn --open

    Component API overview · State and actions

    The example is drawn by crates/limn-gallery/src/pages/messages.rs.