Skip to content

Commit

Permalink
Style error notification.
Browse files Browse the repository at this point in the history
  • Loading branch information
philipborg committed Feb 6, 2022
1 parent 3a5f49c commit eca76da
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit eca76da

Please sign in to comment.