From 450de171e64a3739f997308ac09cb22ec57525a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Fri, 14 Feb 2020 12:37:35 +0100 Subject: [PATCH] Code optimization and fixes --- src/atoms/ToggleLayout.svelte | 6 ++--- src/molecules/Location.svelte | 4 ++- src/organisms/Carousel.svelte | 26 ++++++++++--------- .../location/[country]/[location].svelte | 2 +- .../[country]/[location]/[photo].svelte | 18 ++++++++----- src/style/_base.scss | 1 + src/style/molecules/_footer.scss | 6 ++--- src/style/organisms/_carousel.scss | 9 ++++--- src/style/organisms/_photos.scss | 5 +++- src/style/pages/_homepage.scss | 7 ++--- src/style/pages/_viewer.scss | 7 +++++ src/style/tools/_helpers.scss | 8 +++--- 12 files changed, 61 insertions(+), 38 deletions(-) diff --git a/src/atoms/ToggleLayout.svelte b/src/atoms/ToggleLayout.svelte index bde0e4f..c85e7e8 100644 --- a/src/atoms/ToggleLayout.svelte +++ b/src/atoms/ToggleLayout.svelte @@ -35,12 +35,12 @@ case 'grid': grid.classList.add(layoutGridClass) grid.classList.remove(layoutListClass) - break; + break case 'list': grid.classList.add(layoutListClass) grid.classList.remove(layoutGridClass) - break; - default: break; + break + default: break } // Animate the active pill diff --git a/src/molecules/Location.svelte b/src/molecules/Location.svelte index bfee7f3..a51a70c 100644 --- a/src/molecules/Location.svelte +++ b/src/molecules/Location.svelte @@ -2,11 +2,13 @@ export let name export let slug export let country + + const src = country.flag.full_url
- {'Flag + {'Flag

{name}

{country.name}

diff --git a/src/organisms/Carousel.svelte b/src/organisms/Carousel.svelte index 1899a23..8c5015a 100644 --- a/src/organisms/Carousel.svelte +++ b/src/organisms/Carousel.svelte @@ -23,12 +23,17 @@ const button = event.currentTarget.querySelector('button') const photoActive = document.querySelector('.gallery .active') const photoToHover = (to === 'prev') ? photoActive.previousSibling : photoActive.nextSibling - if (event.type === 'mouseenter') { - photoToHover.classList.add('hover') - button.focus() - } else { - photoToHover.classList.remove('hover') - button.blur() + + switch (event.type) { + case 'mouseenter': + photoToHover.classList.add('hover') + button.focus() + break + case 'mouseleave': + photoToHover.classList.remove('hover') + button.blur() + break + default: break } } @@ -87,13 +92,10 @@