From 1db9217cd08031cf06ef349d247844320335ef74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Mon, 2 Mar 2020 22:27:39 +0100 Subject: [PATCH] Use a component for the pagination Make the component and the page communicate with events to add more photos --- src/organisms/Pagination.svelte | 67 ++++ .../location/[country]/[location].svelte | 332 +++++++++--------- 2 files changed, 224 insertions(+), 175 deletions(-) create mode 100644 src/organisms/Pagination.svelte diff --git a/src/organisms/Pagination.svelte b/src/organisms/Pagination.svelte new file mode 100644 index 0000000..5bc3bc8 --- /dev/null +++ b/src/organisms/Pagination.svelte @@ -0,0 +1,67 @@ + + +
+ {#if photos.length && currentIndex <= photos.length} +
pageTranslate = pageTranslate - (100 / pagesTotal) * 0.666} + on:mouseleave={() => pageTranslate = pageTranslate + (100 / pagesTotal) * 0.666} + > +
page
+
+
+ {#each pagesArray as page} + {page} + {/each} +
+
+ /{pagesTotal} +
+

See more photos

+ + {:else} + {#if $currentLocation} +
+

That's all folks!

+

Come back later to check out
new photos of {$currentLocation.name}

+
+ {/if} + {/if} +
diff --git a/src/routes/location/[country]/[location].svelte b/src/routes/location/[country]/[location].svelte index 94c68c8..8302f64 100644 --- a/src/routes/location/[country]/[location].svelte +++ b/src/routes/location/[country]/[location].svelte @@ -1,212 +1,194 @@ - Houses Of - Beautiful houses of {location.name}, {location.country.name} + Houses Of – Beautiful houses of {location.name}, {location.country.name} + +
-
-

- Houses of - {location.name} -

+
+

+ Houses of + {location.name} +

- - - - Change - - - - - -
+ + + + Change + + + + + +
-
-
-
-

{$site.description}

-

- Houses Of - - - - {location.description} -

-

- Updated - -

+
+
+
+

{$site.description}

+ {#if location.description} +

+ Houses Of + + + + {location.description} +

+ {/if} - -
-
-
+ {#if photos.length} +

+ Updated + +

-
-
-
-
-
+ + {/if} +
+
+
+ +
+
+
+
+
-
- +
- {#if photos.length} -
- {#each paginatedPhotos as photo, index} - - {/each} -
+ {#if photos.length} +
+ {#each paginatedPhotos as photo, index} + + {/each} +
-
- {#if photos.length && currentIndex <= photos.length} -
pageTranslate = pageTranslate - ((100 / pagesTotal) * 0.666)} - on:mouseleave={() => pageTranslate = pageTranslate + ((100 / pagesTotal) * 0.666)} - > -
page
-
-
- {#each pages as page} - {page} - {/each} -
-
- /{pagesTotal} -
-

See more photos

+ - {:else} -
-

That's all folks!

-

Come back later to check out
new photos of {location.name}

-
- {/if} -
- {/if} + {:else} +
+

No photo for {location.name}

+
+ {/if}