view.rs 626 Bytes
use mogwai::prelude::*;

use crate::component::imageselector::PatchReceiver;

pub(super) fn image_preview_view(image_url :String) -> ViewBuilder<Dom> {
    builder! {
        <li><img src=image_url/></li>
    }
}

pub(super) fn selector_view( tx_dom :broadcast::Sender<Dom>
                           , rx_previews :PatchReceiver) -> ViewBuilder<Dom> {
    let post_build = move |dom: &mut Dom| {
        tx_dom.try_broadcast(dom.clone()).unwrap();
    };

    builder! {
        <div class="selector">
            <ul patch:children=rx_previews
                post:build=post_build>
            </ul>
        </div>
    }
}