From 5154a4f200a957a4add3efa9a9db37a5ea99f7b8 Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Thu, 16 Nov 2023 16:27:43 +0100 Subject: [PATCH] Backend: Updated database for Education with a picture URL. Frontend: Slideshow logic is now independent of the width of each slide. --- backend/src/db.rs | 1 + backend/src/main.rs | 2 +- frontend/src/lib/components/education.svelte | 5 ++--- frontend/src/lib/components/slideshow.svelte | 16 +++++++++------- frontend/src/lib/css/education.css | 3 ++- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/backend/src/db.rs b/backend/src/db.rs index 61200d1..a4e5e5c 100644 --- a/backend/src/db.rs +++ b/backend/src/db.rs @@ -21,6 +21,7 @@ pub struct Education { pub speciality: Option, pub school_location: Option, pub school_options: Option, + pub picture_url: Option } #[derive(Deserialize, Serialize)] diff --git a/backend/src/main.rs b/backend/src/main.rs index 234f1d0..a832777 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -51,7 +51,7 @@ async fn info(State(pool): State) -> Result>> { async fn education(State(pool): State) -> Result>> { let datas = sqlx::query_as!( Education, - "SELECT id, start_year, end_year, school, speciality, school_location, school_options FROM public.education" + "SELECT * FROM public.education" ) .fetch_all(&pool) .await?; diff --git a/frontend/src/lib/components/education.svelte b/frontend/src/lib/components/education.svelte index ea95891..8bd3dfb 100644 --- a/frontend/src/lib/components/education.svelte +++ b/frontend/src/lib/components/education.svelte @@ -5,13 +5,12 @@ export let active = false; export let data; - export let picture = - "https://bib.insa-toulouse.fr/_resource/info_pratiques/INSA-Venir-Bib-photo-8_0.jpg"; - + const title = data.school; const location = data.school_location; const speciality = data.speciality; const option = data.school_options; + const picture = data.picture_url;
diff --git a/frontend/src/lib/components/slideshow.svelte b/frontend/src/lib/components/slideshow.svelte index 9fe6d4e..41c3818 100644 --- a/frontend/src/lib/components/slideshow.svelte +++ b/frontend/src/lib/components/slideshow.svelte @@ -17,14 +17,16 @@ slideshow_hidden.push(slideshow_index); slideshow_index++; } - let transformValue; - slideshowElements.forEach((element, id) => { - if (slideshow_hidden.includes(id)) { - transformValue = slideshow_index * 60; - } else { - transformValue = slideshow_index * 54.75; + let transformValue = 0; + for (const id of slideshow_hidden) { + transformValue += (slideshowElements[id].clientWidth+(5*16)); } - element.style.transform = `translateX(-${transformValue}rem)`; + slideshowElements.forEach((element, id) => { + let newtransformValue = transformValue; + if(slideshow_hidden.includes(id)) { + newtransformValue*=1.1; + } + element.style.transform = `translateX(-${newtransformValue}px)`; }); } diff --git a/frontend/src/lib/css/education.css b/frontend/src/lib/css/education.css index 1ad30f6..475ba2d 100644 --- a/frontend/src/lib/css/education.css +++ b/frontend/src/lib/css/education.css @@ -18,7 +18,8 @@ } .education-img { - max-height: 12.5rem; + max-height: 15rem; + min-width: 20rem; } .education-text-container {