diff --git a/src/animations/crossfade.ts b/src/animations/crossfade.ts new file mode 100644 index 0000000..b110bf9 --- /dev/null +++ b/src/animations/crossfade.ts @@ -0,0 +1,26 @@ +import { crossfade } from 'svelte/transition' +import { quartOut } from 'svelte/easing' + +// Crossfade transition +export const [send, receive] = crossfade({ + // duration: 1200, + duration: d => Math.sqrt(d * 200), + fallback (node, params) { + const { + duration = 600, + easing = quartOut, + start = 0.85 + } = params + const style = getComputedStyle(node) + const transform = style.transform === 'none' ? '' : style.transform + const sd = 1 - start + return { + duration, + easing, + css: (t, u) => ` + transform: ${transform} scale(${1 - (sd * u)}); + opacity: ${t} + ` + } + } +}) \ No newline at end of file diff --git a/src/components/molecules/Location.svelte b/src/components/molecules/Location.svelte index 9fdb512..fda8b23 100644 --- a/src/components/molecules/Location.svelte +++ b/src/components/molecules/Location.svelte @@ -10,11 +10,10 @@ export let location: any const { settings: { limit_new }}: any = getContext('global') - const { name, slug, country, date_updated } = location // Location date limit const dateNowOffset = dayjs().subtract(limit_new, 'day') - const dateLocationUpdated = dayjs(date_updated) + const dateLocationUpdated = dayjs(location.date_updated) const isNew = dateLocationUpdated.isAfter(dateNowOffset) let locationEl: HTMLElement @@ -51,19 +50,19 @@
- - Flag of {country.name} + Flag of {location.country.name}
- {name} + {location.name}
- {country.name} + {location.country.name}
{#if isNew} @@ -73,10 +72,10 @@
{#if location.photos.length}
- {#each location.photos as photo, index} + {#each location.photos as { image }, index} {photo.image.title} {/each} diff --git a/src/components/organisms/Locations.svelte b/src/components/organisms/Locations.svelte index 2eeb484..9f15ced 100644 --- a/src/components/organisms/Locations.svelte +++ b/src/components/organisms/Locations.svelte @@ -1,5 +1,9 @@
@@ -16,17 +44,24 @@ -
- {#each locations as location} - +
    + {#each filteredLocations as location (location)} +
  • + +
  • {/each} -
+
\ No newline at end of file diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte index c1978f6..4d06a7e 100644 --- a/src/routes/__layout.svelte +++ b/src/routes/__layout.svelte @@ -37,6 +37,7 @@ name slug flag { id } + continent { slug } } date_updated photos (sort: "-date_created", limit: ${import.meta.env.VITE_PREVIEW_COUNT}) { diff --git a/src/style/organisms/_locations.scss b/src/style/organisms/_locations.scss index 0325d5e..2397060 100644 --- a/src/style/organisms/_locations.scss +++ b/src/style/organisms/_locations.scss @@ -31,6 +31,12 @@ li { display: block; margin: 0 8px; + transition: opacity 0.5s var(--ease-quart); + } + + // Disabled button + .is-disabled { + opacity: 0.4; } } @@ -56,7 +62,8 @@ margin-top: 104px; } - .location { + li { + display: block; margin-bottom: 40px; @include bp (mob-lg) { diff --git a/svelte.config.js b/svelte.config.js index d0f8adb..a587510 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -17,6 +17,7 @@ const config = { resolve: { alias: { $components: resolve('src/components'), + $animations: resolve('src/animations'), $modules: resolve('src/modules'), $utils: resolve('src/utils'), }