diff --git a/web/src/inputs.rs b/web/src/inputs.rs index a39bcc0..02a7291 100644 --- a/web/src/inputs.rs +++ b/web/src/inputs.rs @@ -470,16 +470,14 @@ pub fn svg_input() -> Html { ); } app.reduce(move |app| { - app.svgs.clear(); + // Clear any errors from previous entry, add new successfully parsed SVGs (*parsed_state_cloned).borrow_mut().clear(); for result in results.iter() { (*parsed_state_cloned) .borrow_mut() .push(result.clone().map(|_| ())); } - if results.iter().all(Result::is_ok) { - app.svgs.extend(results.drain(..).filter_map(Result::ok)); - } + app.svgs.extend(results.drain(..).filter_map(Result::ok)); }); } }); diff --git a/web/src/main.rs b/web/src/main.rs index d6e1325..a7b32c1 100644 --- a/web/src/main.rs +++ b/web/src/main.rs @@ -23,7 +23,7 @@ use spectre::*; use state::*; struct App { - _app_dispatch: Dispatch, + app_dispatch: Dispatch, app_state: Rc, form_dispatch: Dispatch, form_state: Rc, @@ -45,7 +45,7 @@ impl Component for App { fn create(_props: Self::Properties, link: ComponentLink) -> Self { Self { - _app_dispatch: Dispatch::bridge_state(link.callback(AppMsg::AppState)), + app_dispatch: Dispatch::bridge_state(link.callback(AppMsg::AppState)), app_state: Default::default(), form_dispatch: Dispatch::bridge_state(link.callback(AppMsg::FormState)), form_state: Default::default(), @@ -173,6 +173,39 @@ impl Component for App { { env!("CARGO_PKG_DESCRIPTION") }

+
+ { + for self.app_state.svgs.iter().enumerate().map(|(i, svg)| { + let svg_base64 = base64::encode(svg.content.as_bytes()); + let remove_svg_onclick = self.app_dispatch.reduce_callback_once(move |app| { + app.svgs.remove(i); + }); + let footer = html!{ +