feat(kanban): prove accessible local reorder
req: client_local/013\nreq: accessibility/002\nreq: accessibility/003\nreq: accessibility/004\nreq: accessibility/006\nreq: milestone/001
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
print!("{}", hemx_kanban_example::render_client_fixture());
|
||||
}
|
||||
@@ -1,6 +1,66 @@
|
||||
#[hemx::surface]
|
||||
pub mod ui {}
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
#[hemx::handler(client)]
|
||||
pub fn reorder_card(
|
||||
event: hemx::wasm::ClientEvent,
|
||||
state: hemx::wasm::ClientState,
|
||||
) -> impl hemx::IntoEffect {
|
||||
let card = event.value.unwrap_or_else(|| "1".to_owned());
|
||||
let order = state.encoded.split('|').collect::<Vec<_>>();
|
||||
let move_effect = if card == order.first().copied().unwrap_or("1") {
|
||||
ui::client_board::client_cards.move_to_end(card.clone())
|
||||
} else {
|
||||
ui::client_board::client_cards.move_before(
|
||||
card.clone(),
|
||||
order.first().copied().unwrap_or("1").to_owned(),
|
||||
)
|
||||
};
|
||||
vec![
|
||||
move_effect,
|
||||
ui::client_board::client_notice.text(format!("Moved {card} with {}", event.kind)),
|
||||
]
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "fixture", not(target_arch = "wasm32")))]
|
||||
mod fixture {
|
||||
use super::ui;
|
||||
use hemplate::Hemplate;
|
||||
use hemx::Html;
|
||||
|
||||
#[derive(Hemplate)]
|
||||
struct ClientBoard {
|
||||
cards: Vec<ClientCard>,
|
||||
}
|
||||
|
||||
#[derive(Hemplate)]
|
||||
struct ClientCard {
|
||||
id: u64,
|
||||
title: &'static str,
|
||||
}
|
||||
|
||||
pub fn render() -> Html {
|
||||
ui::client_board::page(&ClientBoard {
|
||||
cards: vec![
|
||||
ClientCard {
|
||||
id: 1,
|
||||
title: "First",
|
||||
},
|
||||
ClientCard {
|
||||
id: 2,
|
||||
title: "Second",
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "fixture", not(target_arch = "wasm32")))]
|
||||
pub fn render_client_fixture() -> hemx::Html {
|
||||
fixture::render()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ui::{board, board_card};
|
||||
|
||||
Reference in New Issue
Block a user