From 5ac5d6803f32ab84c86870d4e5a1f3cebfe46a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Tue, 31 Mar 2020 10:35:51 +0200 Subject: [PATCH] Use Destructuring variables to avoid repetitions - Easier to read and write - Also fixes fullscreen when leaving the viewer, my bad --- src/molecules/Location.svelte | 11 +++++++---- src/molecules/Photo.svelte | 33 +++++++++++++++++---------------- src/molecules/Switcher.svelte | 2 +- src/organisms/Carousel.svelte | 32 +++++++++++++++++--------------- src/organisms/Fullscreen.svelte | 10 ++++------ 5 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/molecules/Location.svelte b/src/molecules/Location.svelte index 4f108a8..0756d72 100644 --- a/src/molecules/Location.svelte +++ b/src/molecules/Location.svelte @@ -1,16 +1,19 @@
- - Flag of {location.country.name} + + Flag of {country.name}
-

{location.name}

+

{name}

-

{location.country.name}

+

{country.name}

diff --git a/src/molecules/Photo.svelte b/src/molecules/Photo.svelte index 5722e8c..6f47074 100644 --- a/src/molecules/Photo.svelte +++ b/src/molecules/Photo.svelte @@ -17,8 +17,9 @@ const defaultHeight = Math.ceil(defaultWidth / 1.5) // Reactive variables for location informations - const location = photo.location - const imgAlt = `${photo.name}, ${location.region}, ${location.country.name}` + const { name, date, location } = photo + const { private_hash } = photo.image + const imgAlt = `${name}, ${location.region}, ${location.country.name}` const photoHref = `/viewer/${location.country.slug}/${location.slug}/${photo.slug}` // Photo index @@ -37,8 +38,8 @@

- {photo.name.split(', ')[0]}, - {photo.name.split(', ')[1]} + {name.split(', ')[0]}, + {name.split(', ')[1]}

{location.region}, {location.country.name}

@@ -49,28 +50,28 @@ {#if layout === 'list'} - - - - + + + + {imgAlt} {:else} - - - - - {imgAlt} + + + + + {imgAlt} {/if} -