Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style error notification. #17

Merged
merged 1 commit into from
Feb 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cube_shuffle-wasm/src/components/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum Msg {
UpdatePackSize(Option<i128>),
Pile,
Shuffle,
Error(String),
Error(Option<String>),
}

#[derive(Clone, PartialEq)]
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Component for App {
true
}
Msg::Error(e) => {
self.error_message = Some(e);
self.error_message = e;
true
}
}
Expand All @@ -133,7 +133,7 @@ impl Component for App {
let update_seed = link.callback(Msg::UpdateSeed);
let update_pack_size = link.callback(Msg::UpdatePackSize);
let on_shuffle = link.callback(|_| Msg::Shuffle);
let on_error = link.callback(Msg::Error);
let on_error = link.callback(|e| Msg::Error(Some(e)));
let piles = pile_cards(&self.piles);
html! {
<>
Expand Down Expand Up @@ -188,13 +188,15 @@ impl Component for App {
}
};

let clear_error = link.callback(|_| { Msg::Error(None) });
let error_html: Html = self.error_message
.clone()
.map_or(html! {}, |e| {
return html! {
<>
<div class="notification is-danger">
<button onclick={ clear_error } class="delete"></button>
<p>{ e }</p>
</>
</div>
};
});

Expand Down