# Conflicts:
#	src/routes/photos.svelte
This commit is contained in:
2021-10-05 16:44:02 +02:00
10 changed files with 146 additions and 114 deletions

View File

@@ -28,7 +28,7 @@
export async function load ({ page, session, fetch, context }) {
const res = await fetchAPI(`
query {
location {
location (filter: { status: { _eq: "published" }}) {
name
slug
coordinates
@@ -48,7 +48,7 @@
}
}
country {
country (filter: { status: { _eq: "published" }}) {
name
slug
flag {

View File

@@ -5,6 +5,7 @@
import Metas from '$components/Metas.svelte'
import Button from '$components/atoms/Button.svelte'
import BoxCTA from '$components/atoms/BoxCTA.svelte'
import DiscoverText from '$components/atoms/DiscoverText.svelte'
import PhotoCard from '$components/molecules/PhotoCard.svelte'
import InteractiveGlobe from '$components/organisms/InteractiveGlobe.svelte'
import Locations from '$components/organisms/Locations.svelte'
@@ -13,7 +14,7 @@
export let photos: any
const { settings, location, count }: any = getContext('global')
const { settings, location }: any = getContext('global')
const { path } = $page
</script>
@@ -43,11 +44,7 @@
</section>
<div class="homepage__ctas" id="ctas">
<p class="discover">
Discover <strong>{count.photos} homes</strong><br>
from <strong>{count.locations} cities</strong>
of <strong>{count.countries} countries</strong>
</p>
<DiscoverText />
<div class="cards">
<BoxCTA

View File

@@ -1,6 +1,5 @@
<script lang="ts">
import { getContext } from 'svelte'
import { page } from '$app/stores'
// Components
import Metas from '$components/Metas.svelte'
import Button from '$components/atoms/Button.svelte'
@@ -11,8 +10,25 @@
export let photos: any
const { settings, location, count }: any = getContext('global')
const { path } = $page
const { country: countries }: any = getContext('global')
let filtered: boolean = false
let buttonReset: HTMLElement
let buttonShuffle: HTMLElement
/**
* Select change events
*/
// Location select
const handleLocationChange = ({ detail: value }) => {
console.log(value)
}
// Sort select
const handleSortChange = ({ detail: value }) => {
console.log(value)
}
</script>
<Metas
@@ -24,11 +40,8 @@
<main class="photos">
<section class="photos__intro">
<h1 class="title-huge">Houses</h1>
<p class="discover">
Discover <strong>{count.photos} homes</strong><br>
from <strong>{count.locations} cities</strong>
of <strong>{count.countries} countries</strong>
</p>
<DiscoverText />
<div class="filter">
<span class="text-label filter__label">Filter photos</span>
@@ -36,29 +49,44 @@
<div class="filter__bar">
<ul>
<li>
<div class="select">
<Select
name="location" id="filter_location"
base={{ value: 'all', name: 'Worldwide' }}
options={[
{ value: 'all', name: 'Worldwide' },
...countries.map(({ slug, name }) => ({
value: slug,
name
}))
]}
on:change={handleLocationChange}
>
<img src="/images/icons/earth.svg" alt="Earth">
<span>Worldwide</span>
<select name="location" id="filter_location">
<option value="worldwide">Worldwide</option>
</select>
</div>
</Select>
</li>
<li>
<div class="select">
<Select
name="sort" id="filter_sort"
base={{ value: 'all', name: 'Worldwide' }}
options={[
{ value: 'latest', name: 'Latest photos' },
{ value: 'oldest', name: 'Oldest photos' },
]}
on:change={handleSortChange}
>
<img src="/images/icons/sort.svg" alt="Sort">
<span>Worldwide</span>
<select name="location" id="filter_location">
<option value="worldwide">Worldwide</option>
</select>
</div>
</Select>
</li>
</ul>
</div>
<div class="filter__actions">
<a href="#">Reset</a>
<button class="shuffle">
{#if filtered}
<button class="reset button-link" bind:this={buttonReset}>
Reset
</button>
{/if}
<button class="shuffle" bind:this={buttonShuffle}>
<img src="/images/icons/shuffle.svg" alt="">
</button>
</div>