Backend: Updated database for Education with a picture URL. Frontend: Slideshow logic is now independent of the width of each slide.

This commit is contained in:
Yohan Boujon 2023-11-16 16:27:43 +01:00
parent c5903c6079
commit 5154a4f200
5 changed files with 15 additions and 12 deletions

View file

@ -21,6 +21,7 @@ pub struct Education {
pub speciality: Option<String>, pub speciality: Option<String>,
pub school_location: Option<String>, pub school_location: Option<String>,
pub school_options: Option<String>, pub school_options: Option<String>,
pub picture_url: Option<String>
} }
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]

View file

@ -51,7 +51,7 @@ async fn info(State(pool): State<PgPool>) -> Result<Json<Vec<Info>>> {
async fn education(State(pool): State<PgPool>) -> Result<Json<Vec<Education>>> { async fn education(State(pool): State<PgPool>) -> Result<Json<Vec<Education>>> {
let datas = sqlx::query_as!( let datas = sqlx::query_as!(
Education, Education,
"SELECT id, start_year, end_year, school, speciality, school_location, school_options FROM public.education" "SELECT * FROM public.education"
) )
.fetch_all(&pool) .fetch_all(&pool)
.await?; .await?;

View file

@ -5,13 +5,12 @@
export let active = false; export let active = false;
export let data; 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 title = data.school;
const location = data.school_location; const location = data.school_location;
const speciality = data.speciality; const speciality = data.speciality;
const option = data.school_options; const option = data.school_options;
const picture = data.picture_url;
</script> </script>
<div class="education-main {active ? '' : 'education-unactive'}"> <div class="education-main {active ? '' : 'education-unactive'}">

View file

@ -17,14 +17,16 @@
slideshow_hidden.push(slideshow_index); slideshow_hidden.push(slideshow_index);
slideshow_index++; slideshow_index++;
} }
let transformValue; let transformValue = 0;
slideshowElements.forEach((element, id) => { for (const id of slideshow_hidden) {
if (slideshow_hidden.includes(id)) { transformValue += (slideshowElements[id].clientWidth+(5*16));
transformValue = slideshow_index * 60;
} else {
transformValue = slideshow_index * 54.75;
} }
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)`;
}); });
} }
</script> </script>

View file

@ -18,7 +18,8 @@
} }
.education-img { .education-img {
max-height: 12.5rem; max-height: 15rem;
min-width: 20rem;
} }
.education-text-container { .education-text-container {