✨ Define small PostCard from photo index
This commit is contained in:
@@ -75,6 +75,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define small photo size from index
|
||||||
|
* With different grid patterns depending on window width
|
||||||
|
*/
|
||||||
|
$: isSmall = (index: number) => {
|
||||||
|
let modulo = index % 5
|
||||||
|
let notOn = [0]
|
||||||
|
|
||||||
|
// Change pattern on small desktop
|
||||||
|
if (innerWidth >= 768 && innerWidth < 1200) {
|
||||||
|
modulo = index % 11
|
||||||
|
notOn = [0, 7, 10]
|
||||||
|
} else if (innerWidth >= 1200) {
|
||||||
|
// Disable on larger desktop
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return !notOn.includes(modulo)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select change events
|
* Select change events
|
||||||
@@ -262,8 +281,8 @@
|
|||||||
<div class="grid container">
|
<div class="grid container">
|
||||||
{#if photos.length}
|
{#if photos.length}
|
||||||
<div class="photos__grid">
|
<div class="photos__grid">
|
||||||
{#each photos as { image, slug, location, title }}
|
{#each photos as { image, slug, location, title }, index}
|
||||||
<div class="photo shadow-photo">
|
<figure class="photo shadow-photo">
|
||||||
<a href="/{location.country.slug}/{location.slug}/{slug}">
|
<a href="/{location.country.slug}/{location.slug}/{slug}">
|
||||||
<Image
|
<Image
|
||||||
id={image.id}
|
id={image.id}
|
||||||
@@ -276,15 +295,18 @@
|
|||||||
ratio={1.5}
|
ratio={1.5}
|
||||||
alt={image.title}
|
alt={image.title}
|
||||||
/>
|
/>
|
||||||
|
</a>
|
||||||
|
<figcaption>
|
||||||
<PostCard
|
<PostCard
|
||||||
street={title}
|
street={title}
|
||||||
location={location.name}
|
location={location.name}
|
||||||
region={location.region}
|
region={location.region}
|
||||||
country={location.country.name}
|
country={location.country.name}
|
||||||
flagId={location.country.flag.id}
|
flagId={location.country.flag.id}
|
||||||
|
size={isSmall(index) ? 'small' : null}
|
||||||
/>
|
/>
|
||||||
</a>
|
</figcaption>
|
||||||
</div>
|
</figure>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -113,13 +113,11 @@
|
|||||||
*/
|
*/
|
||||||
// Small size
|
// Small size
|
||||||
&--small {
|
&--small {
|
||||||
opacity: 1 !important;
|
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
transform: none !important;
|
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
grid-template: 1fr 2fr / 1fr;
|
grid-template: 1fr 2fr / 1fr;
|
||||||
|
|||||||
@@ -204,11 +204,16 @@
|
|||||||
background-color: $color-tertiary;
|
background-color: $color-tertiary;
|
||||||
|
|
||||||
@include bp (sm) {
|
@include bp (sm) {
|
||||||
|
padding: clamp(40px, 5vw, 64px) 24px;
|
||||||
|
}
|
||||||
|
@include bp (md) {
|
||||||
margin: 0 30px;
|
margin: 0 30px;
|
||||||
padding: clamp(40px, 5vw, 64px) 0;
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:before, &:after {
|
&:before, &:after {
|
||||||
|
@include bp (md) {
|
||||||
content: "";
|
content: "";
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -219,17 +224,22 @@
|
|||||||
background: $color-tertiary;
|
background: $color-tertiary;
|
||||||
transition: transform 0.8s var(--ease-quart);
|
transition: transform 0.8s var(--ease-quart);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
&:before {
|
&:before {
|
||||||
|
@include bp (md) {
|
||||||
border-radius: var(--corners) 0 0 var(--corners);
|
border-radius: var(--corners) 0 0 var(--corners);
|
||||||
left: 0;
|
left: 0;
|
||||||
transform: translate3d(calc(-1 * var(--margin-sides)), 0, 0);
|
transform: translate3d(calc(-1 * var(--margin-sides)), 0, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
&:after {
|
&:after {
|
||||||
|
@include bp (md) {
|
||||||
border-radius: 0 var(--corners) var(--corners) 0;
|
border-radius: 0 var(--corners) var(--corners) 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
transform: translate3d(var(--margin-sides), 0, 0);
|
transform: translate3d(var(--margin-sides), 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Photo Grid
|
// Photo Grid
|
||||||
&__grid {
|
&__grid {
|
||||||
@@ -254,6 +264,20 @@
|
|||||||
|
|
||||||
// Photo
|
// Photo
|
||||||
.photo {
|
.photo {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
figcaption {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Photo sizes
|
* Photo sizes
|
||||||
*/
|
*/
|
||||||
@@ -330,7 +354,8 @@
|
|||||||
transition: opacity 0.4s var(--ease-quart), transform 1.0s var(--ease-quart);
|
transition: opacity 0.4s var(--ease-quart), transform 1.0s var(--ease-quart);
|
||||||
|
|
||||||
&--small {
|
&--small {
|
||||||
border-radius: 0;
|
border-radius: 6px 6px 0 0;
|
||||||
|
transform: translate3d(8%, 12%, 0) rotate(-3deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +363,11 @@
|
|||||||
&:hover {
|
&:hover {
|
||||||
.postcard {
|
.postcard {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translate3d(3%,3%,0) rotate(2deg);
|
transform: translate3d(3%, 3%, 0) rotate(2deg);
|
||||||
|
|
||||||
|
&--small {
|
||||||
|
transform: translate3d(0,0,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user