From 32fb36623b6fd38acf01f3eba8fb09bb479c1ad8 Mon Sep 17 00:00:00 2001 From: Vinod J M Date: Sun, 4 Dec 2022 10:12:17 +0530 Subject: [PATCH] v0.15-WORKINGV2 --- frontend/css/index.css | 47 ++++++++++++++++++++++-------------------- frontend/index.html | 2 +- frontend/src/main.rs | 18 +++++++++++----- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/frontend/css/index.css b/frontend/css/index.css index 3a28349..5600947 100644 --- a/frontend/css/index.css +++ b/frontend/css/index.css @@ -89,45 +89,39 @@ body { .card { box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); /* this adds the "card" effect */ padding: 16px; - text-align: center; + text-align: left; height: 400px; overflow: hidden; text-overflow: ellipsis; background-color: #f1f1f1; - #content img { - position: absolute; - top: 0px; - right: 0px; - } } /* Style the counter cards */ .card-openlibrary { box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); /* this adds the "card" effect */ padding: 16px; - text-align: center; + text-align: left; height: 200px; overflow: hidden; text-overflow: ellipsis; background-color: #f1f1f1; - #content img { - position: absolute; - top: 0px; - right: 0px; - } } -/* -.card-image { - padding: 16px; - position: relative; - top: 0px; - right: 0px; - width: 40%; + +.card img { + float: right; + width: 100px; + padding: 0 20px 20px 0; } -*/ + +.card-openlibrary img { + float: right; + width: 100px; + padding: 0 20px 20px 0; +} + + .card-title { padding: 16px; - float: left; text-align: left; width: 60%; font-weight: bold; @@ -136,12 +130,17 @@ body { .card-authors { padding: 16px; - float: left; text-align: left; width: 60%; font-size: large; } +.card-desc { + padding: 2px; + text-align: left; + width: 100%; +} + .input-field { padding: 4px; @@ -208,4 +207,8 @@ body { .main { margin-top: 80px; /* Add a top margin to avoid content overlay */ } + + .input-field { + width: 100%; + } } diff --git a/frontend/index.html b/frontend/index.html index 0f259e1..6bb5f46 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -3,7 +3,7 @@ - + Book Manager diff --git a/frontend/src/main.rs b/frontend/src/main.rs index 27e5d79..ce05840 100644 --- a/frontend/src/main.rs +++ b/frontend/src/main.rs @@ -167,6 +167,7 @@ pub fn Header(cx: Scope) -> View { app_state.internalsearch.set(false); info!("Fetching search {}\n", task.clone()); + app_state.books.set(Vec::new()); value.set("".to_string()); input_ref .get::() @@ -188,7 +189,7 @@ pub fn Header(cx: Scope) -> View { app_state.search.set(task); app_state.openlibrary.set(false); app_state.internalsearch.set(true); - + app_state.books.set(Vec::new()); info!("Fetching search 2\n"); } } @@ -310,7 +311,6 @@ async fn ListDB(cx: Scope<'_>) -> View { app_state.openlibrary.track(); app_state.internalsearch.track(); app_state.refreshing.track(); - app_state.pagenum.track(); info!( "The state changed. New value: {}", @@ -391,6 +391,8 @@ pub fn BookDB(cx: Scope, bookitem: BookUIProp) -> View { let loctitle = bookitem.bookitem.clone().title.clone(); let locauthors = bookitem.bookitem.clone().author_name.clone().unwrap_or(vec!["".to_string()]).join(", "); let locdesc = bookitem.bookitem.clone().description.unwrap_or("".to_string()); + let locloc = bookitem.bookitem.clone().location.unwrap_or("".to_string()); + let coverurl = bookdisplay.clone().cover.clone().unwrap_or("None".to_string()); @@ -427,6 +429,7 @@ pub fn BookDB(cx: Scope, bookitem: BookUIProp) -> View { button(class="info", on:click=handle_display){ "INFO+" } } div(class="card-main"){ + img(src=coverurl,width="100") div(class="card-title"){ (format!("{}",loctitle)) @@ -435,11 +438,12 @@ pub fn BookDB(cx: Scope, bookitem: BookUIProp) -> View { (format!("{}",locauthors)) } //div(class="card-image"){ - img(src=coverurl,width="100") //} } div(class="card-desc"){ + (format!("{}",locloc)) + br{}br{} (format!("{}",locdesc)) } @@ -453,6 +457,7 @@ pub fn BookDB(cx: Scope, bookitem: BookUIProp) -> View { async fn ListOL(cx: Scope<'_>) -> View { let app_state = use_context::(cx); + /* create_effect(cx, || { app_state.search.track(); @@ -461,6 +466,7 @@ async fn ListOL(cx: Scope<'_>) -> View { app_state.search.get(), ); }); + */ let docs = create_memo(cx, || app_state.books.get().iter().cloned().collect::>()); view! {cx, @@ -503,6 +509,7 @@ pub fn BookOL(cx: Scope, bookitem: BookUIProp) -> View { div(class="card-openlibrary"){ button(class="add", on:click=handle_add){ "ADD+" } div(class="card-main"){ + img(src=coverurl,width="100") div(class="card-title"){ (format!("{}",loctitle)) @@ -511,7 +518,6 @@ pub fn BookOL(cx: Scope, bookitem: BookUIProp) -> View { (format!("{}",locauthors)) } //div(class="card-image"){ - img(src=coverurl,width="100") //} } } @@ -619,9 +625,10 @@ info!("Adding book"); println!("{}",temp.status()); }); } - app_state.addingbook.set(BookUI::default()); + app_state.addingbook.set(BookUI::default()); app_state.updating.set(false); app_state.adding.set(false); + //app_state.books.set(vec![BookUI::default()]); app_state.refreshing.set(true); @@ -913,6 +920,7 @@ async fn PageBar(cx: Scope<'_>) -> View { view!{ cx, label{"PAGE "} input(ref=input_ref,bind:value=currpg,on:keyup=handle_submit,class="page-input") + label{(format!(" / {}",*app_state.maxpage.get()))} (if *app_state.pagenum.get()>1 { view!{cx, button(class="page", on:click=handle_sub){ "-" }} } else {