diff --git a/Cargo.toml b/Cargo.toml index 328510e..7e55a1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,13 +21,8 @@ server = [ "dep:ring-compat", ] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [lib] -# The `_lib` suffix may seem redundant but it is necessary -# to make the lib name unique and wouldn't conflict with the bin name. -# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 -name = "bkbh_lib" +name = "bkbh" crate-type = ["staticlib", "cdylib", "rlib"] [build-dependencies] diff --git a/src/bin/leptos.rs b/src/bin/leptos.rs index fbe40b0..ceaf345 100644 --- a/src/bin/leptos.rs +++ b/src/bin/leptos.rs @@ -1,185 +1,9 @@ use leptos::prelude::*; -use bkbh_lib::commands::*; -use leptos::task::spawn_local; -use leptos::web_sys::FormData; -use leptos::form::FromFormData; -use std::collections::HashMap; - -use bkbh_lib::types::*; - -#[component] -fn StoreLogo(store: Store) -> impl IntoView { - view! { - ::into(&store)) - class="logo" - // FIXME: Implement fmt trait for Store - alt=format!("{:?}", store) - /> - } -} - -#[component] -fn SwapButton(store: Store) -> impl IntoView { - view! { - - } -} - -#[component] -fn StoreInput(store: Store) -> impl IntoView { - let txt = format!("{}", Into::::into(&store)); - view! { -
- - -
- } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -struct Cash(i64); - -impl std::str::FromStr for Cash { - type Err = (); - - fn from_str(s: &str) -> Result { - let split: Vec<&str> = s.split(".").collect(); - let i = i64::from_str(split.get(0).ok_or(())?) - .map_err(|e| println!("{:?}", e))?; - let f = match split.get(1) { - None => 0, - Some(fs) => i64::from_str( - &format!("00{}", fs)[0..2] - ) - .map_err(|e| println!("{:?}", e))?, - }; - Ok(Cash(i*100+f)) - } -} - -#[component] -fn CashInput(value: RwSignal) -> impl IntoView { - let txt = "cash"; - view! { -
- - -
- } -} - -#[component] -fn AccRadio(acc: Account) -> impl IntoView { - let txt = format!("{}", Into::::into(&acc)); - let id = format!("acc-{}", txt); - view! { -
- - -
- } -} - -#[component] -fn SubmitButton() -> impl IntoView { - view! { - - } -} - -#[component] -fn InvForm() -> impl IntoView { - let cash = RwSignal::new(String::from("0.00")); - view! { -
- - - - - - - - - - - } -} +use bkbh::leptos::cafe::Cafe; fn main() { console_error_panic_hook::set_once(); - leptos::mount::mount_to_body(|| view! { - -
- -
- }); + leptos::mount::mount_to_body( + || view! { } + ); } diff --git a/src/bin/tauri.rs b/src/bin/tauri.rs index 4d73f4d..3d19dcc 100644 --- a/src/bin/tauri.rs +++ b/src/bin/tauri.rs @@ -2,5 +2,5 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] fn main() { - bkbh_lib::run() + bkbh::run() } diff --git a/src/leptos/cafe.rs b/src/leptos/cafe.rs new file mode 100644 index 0000000..5137ce1 --- /dev/null +++ b/src/leptos/cafe.rs @@ -0,0 +1,184 @@ +use leptos::prelude::*; +use crate::commands::*; +use leptos::task::spawn_local; +use leptos::web_sys::FormData; +use leptos::form::FromFormData; +use std::collections::HashMap; +use crate::types::*; + +#[component] +pub fn Cafe() -> impl IntoView { + view! { + +
+ +
+ } +} + +#[component] +fn StoreLogo(store: Store) -> impl IntoView { + view! { + ::into(&store)) + class="logo" + // FIXME: Implement fmt trait for Store + alt=format!("{:?}", store) + /> + } +} + +#[component] +fn SwapButton(store: Store) -> impl IntoView { + view! { + + } +} + +#[component] +fn StoreInput(store: Store) -> impl IntoView { + let txt = format!("{}", Into::::into(&store)); + view! { +
+ + +
+ } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct Cash(i64); + +impl std::str::FromStr for Cash { + type Err = (); + + fn from_str(s: &str) -> Result { + let split: Vec<&str> = s.split(".").collect(); + let i = i64::from_str(split.get(0).ok_or(())?) + .map_err(|e| println!("{:?}", e))?; + let f = match split.get(1) { + None => 0, + Some(fs) => i64::from_str( + &format!("00{}", fs)[0..2] + ) + .map_err(|e| println!("{:?}", e))?, + }; + Ok(Cash(i*100+f)) + } +} + +#[component] +fn CashInput(value: RwSignal) -> impl IntoView { + let txt = "cash"; + view! { +
+ + +
+ } +} + +#[component] +fn AccRadio(acc: Account) -> impl IntoView { + let txt = format!("{}", Into::::into(&acc)); + let id = format!("acc-{}", txt); + view! { +
+ + +
+ } +} + +#[component] +fn SubmitButton() -> impl IntoView { + view! { + + } +} + +#[component] +fn InvForm() -> impl IntoView { + let cash = RwSignal::new(String::from("0.00")); + view! { +
+ + + + + + + + + + + } +} diff --git a/src/leptos/mod.rs b/src/leptos/mod.rs new file mode 100644 index 0000000..1c34313 --- /dev/null +++ b/src/leptos/mod.rs @@ -0,0 +1 @@ +pub mod cafe; diff --git a/src/lib.rs b/src/lib.rs index 366d39a..3340bcd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,8 @@ pub mod commands; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "leptos")] +pub mod leptos; pub mod types; #[cfg(all(feature = "tauri", feature="server"))] diff --git a/trunk.html b/trunk.html index b03c4b3..26d67d9 100644 --- a/trunk.html +++ b/trunk.html @@ -6,7 +6,7 @@ Darmstadt sagt Nein zur Bezahlkartei! - +