Skip to content

Commit

Permalink
First ugly modal screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
ejoepes committed Dec 17, 2024
1 parent 4df9f63 commit cd97940
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ use wasm_bindgen_futures::spawn_local;
use web_sys::{Element, HtmlAnchorElement, HtmlElement, HtmlInputElement};

use crate::{
data::{Aeat720Information, PersonalInformation},
personal_info::PersonalInfoViewer,
table::Table,
utils::{file_importer, web},
css::MODAL_STYLE, data::{Aeat720Information, PersonalInformation}, personal_info::PersonalInfoViewer, table::Table, utils::{file_importer, web}
};

pub struct App {
Expand All @@ -24,6 +21,7 @@ pub struct App {
aeat720_form_path: Mutable<Option<String>>,
personal_info_viewer: Arc<PersonalInfoViewer>,
table: Arc<Table>,
modal_visible: Mutable<bool>,
}

impl App {
Expand All @@ -36,6 +34,7 @@ impl App {
aeat720_form_path: Mutable::new(None),
personal_info_viewer: PersonalInfoViewer::new(personal_info.clone()),
table: Table::new(),
modal_visible: Mutable::new(false),
})
}

Expand All @@ -55,6 +54,7 @@ impl App {
}
Err(error) => {
*this.current_error.lock_mut() = Some(error.to_string());
this.modal_visible.set(true);
}
}
}
Expand All @@ -64,7 +64,7 @@ impl App {
let old_path = old_path.map_or("".to_owned(), |x| x);
let path = web::generate_720(&Aeat720Information {
records: this.table.get_records(),
personal_info: PersonalInformation::default(),
personal_info: this.personal_info.get_cloned(),
})?;
if !old_path.is_empty() {
let _ = web::delete_path(old_path);
Expand Down Expand Up @@ -101,6 +101,7 @@ impl App {
None => {
*this.current_error.lock_mut() = Some(
"Error subiendo fichero".to_string());
this.modal_visible.set(true);
return;
}
};
Expand All @@ -109,6 +110,7 @@ impl App {
None => {
*this.current_error.lock_mut() = Some(
"Error obteniendo fichero".to_string());
this.modal_visible.set(true);
return;
}
};
Expand Down Expand Up @@ -142,7 +144,7 @@ impl App {
html!("span", {
.child(html!("input" => HtmlInputElement, {
.attr("type", "button")
.attr("value", "Insertar movimiento")
.attr("value", "Añadir movimiento")
.with_node!(_element => {
.event(clone!(this => move |_: events::Click| {
this.table.add_default();
Expand Down Expand Up @@ -192,6 +194,14 @@ impl App {

pub fn render(this: Arc<Self>) -> Dom {
html!("div", {
.child(html!("div", {
.class(&*MODAL_STYLE)
.visible_signal(this.modal_visible.signal())
.event(clone!(this => move |_: events::Click| {
this.modal_visible.set_neq(false);
}))
.text_signal(this.current_error.signal_ref(|v| v.clone().unwrap_or("".to_string())))
}))
.child(html!("h2", {
.text("Paso 1: Rellena datos personales.")
}))
Expand Down
13 changes: 13 additions & 0 deletions src/css.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ pub static ROOT_CLASS: LazyLock<String> = LazyLock::new(|| {
}
});

pub static MODAL_STYLE: LazyLock<String> = LazyLock::new(|| {
class! {
.style("position", "fixed")
.style("left", "0")
.style("top", "0")
.style("width", "100%")
.style("height", "100%")
.style("z-index", "1")
.style("color", "red")
.style("background-color", "gray")
}
});

pub static ERROR_PARAGRAPH_CLASS: LazyLock<String> = LazyLock::new(|| {

Check warning on line 23 in src/css.rs

View workflow job for this annotation

GitHub Actions / Format & Clippy (1.80.1)

static `ERROR_PARAGRAPH_CLASS` is never used

Check warning on line 23 in src/css.rs

View workflow job for this annotation

GitHub Actions / Unit Tests on 1.80.1

static `ERROR_PARAGRAPH_CLASS` is never used

Check warning on line 23 in src/css.rs

View workflow job for this annotation

GitHub Actions / Unit Tests on 1.80.1

static `ERROR_PARAGRAPH_CLASS` is never used
class! {
.style("color", "#ba3939")
Expand Down

1 comment on commit cd97940

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.