Create Photos page with filter bar

This commit is contained in:
2021-10-03 22:50:33 +02:00
parent 7d1dab9775
commit de6da7394b
5 changed files with 255 additions and 0 deletions

95
src/routes/photos.svelte Normal file
View File

@@ -0,0 +1,95 @@
<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'
import BoxCTA from '$components/atoms/BoxCTA.svelte'
import PhotoCard from '$components/molecules/PhotoCard.svelte'
import InteractiveGlobe from '$components/organisms/InteractiveGlobe.svelte'
import Locations from '$components/organisms/Locations.svelte'
import Shop from '$components/organisms/Shop.svelte'
import Newsletter from '$components/organisms/Newsletter.svelte'
export let photos: any
const { settings, location, count }: any = getContext('global')
const { path } = $page
</script>
<Metas
title="Photos"
description=""
image=""
/>
<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>
<div class="filter">
<span class="text-label filter__label">Filter photos</span>
<div class="filter__bar">
<ul>
<li>
<div class="select">
<img src="/images/icons/earth.svg" alt="Earth">
<span>Worldwide</span>
<select name="location" id="filter_location">
<option value="worldwide">Worldwide</option>
</select>
</div>
</li>
<li>
<div class="select">
<img src="/images/icons/sort.svg" alt="Sort">
<span>Worldwide</span>
<select name="location" id="filter_location">
<option value="worldwide">Worldwide</option>
</select>
</div>
</li>
</ul>
</div>
<div class="filter__actions">
<a href="#">Reset</a>
<button class="shuffle">
<img src="/images/icons/shuffle.svg" alt="">
</button>
</div>
</div>
</section>
</main>
<script context="module" lang="ts">
import { fetchAPI } from '$utils/api'
export async function load ({ page, session, fetch, context }) {
const res = await fetchAPI(`
query {
photo (limit: 11, sort: ["-date_created"]) {
image {
id
title
}
}
}
`)
const { data } = res
return {
props: {
photos: data.photo,
}
}
}
</script>

View File

@@ -0,0 +1,144 @@
// Photos Page
.photos {
// Intro Section
&__intro {
color: $color-text;
text-align: center;
overflow: hidden;
padding-bottom: clamp(250px, 27vw, 600px);
// Title
h1 {
color: $color-secondary;
line-height: 1;
margin-top: -20px;
@include bp (sm) {
margin-top: -100px;
}
}
// Text
p {
max-width: 350px;
margin: 20px auto 56px;
@include bp (sm) {
margin: 50px auto 72px;
max-width: 524px;
}
}
}
// Filter
.filter {
position: relative;
max-width: 982px;
margin: 0 auto;
padding: 0 32px;
// Span
&__label {
display: block;
color: rgba($color-tertiary, 0.7);
@include bp (sm) {
position: absolute;
left: 64px;
top: 50%;
transform: translateY(-50%);
margin-bottom: 0;
}
}
&__bar {
display: flex;
justify-content: center;
align-items: center;
margin: 20px 0;
padding: 20px 22px;
background: $color-primary-darker;
border-radius: 50vh;
@include bp (sm) {
padding: 28px 32px;
}
ul {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
}
li {
display: block;
margin: 8px 10px;
font-size: rem(16px);
color: #fff;
@include bp (sm) {
margin: 0 16px;
}
}
img {
color: #fff;
margin-right: 12px;
@include bp (sm) {
margin-right: 16px;
}
}
.select {
position: relative;
font-weight: 900;
select {
opacity: 0;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
cursor: pointer;
}
}
}
// Actions
&__actions {
display: flex;
align-items: center;
justify-content: center;
@include bp (sm) {
position: absolute;
right: 64px;
top: 50%;
transform: translateY(-50%);
}
a {
display: block;
text-decoration: none;
color: rgba(#fff, 0.6);
font-size: rem(14px);
font-weight: 900;
line-height: 1;
img {
display: block;
}
}
.shuffle {
display: flex;
align-items: center;
justify-content: center;
height: 32px;
background-color: $color-tertiary;
padding: 0 16px;
border-radius: 50vh;
margin-left: 16px;
}
}
}
}

View File

@@ -21,6 +21,7 @@
// Pages
@import "pages/homepage";
@import "pages/photos";
// Modules
@import "modules/globe";