Define small PostCard from photo index

This commit is contained in:
2021-10-24 15:10:59 +02:00
parent c2f7ad108a
commit 18726f6798
3 changed files with 73 additions and 24 deletions

View File

@@ -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
@@ -262,8 +281,8 @@
<div class="grid container">
{#if photos.length}
<div class="photos__grid">
{#each photos as { image, slug, location, title }}
<div class="photo shadow-photo">
{#each photos as { image, slug, location, title }, index}
<figure class="photo shadow-photo">
<a href="/{location.country.slug}/{location.slug}/{slug}">
<Image
id={image.id}
@@ -276,15 +295,18 @@
ratio={1.5}
alt={image.title}
/>
</a>
<figcaption>
<PostCard
street={title}
location={location.name}
region={location.region}
country={location.country.name}
flagId={location.country.flag.id}
size={isSmall(index) ? 'small' : null}
/>
</a>
</div>
</figcaption>
</figure>
{/each}
</div>

View File

@@ -113,13 +113,11 @@
*/
// Small size
&--small {
opacity: 1 !important;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 0;
transform: none !important;
max-width: 100%;
max-height: 100%;
grid-template: 1fr 2fr / 1fr;

View File

@@ -204,11 +204,16 @@
background-color: $color-tertiary;
@include bp (sm) {
padding: clamp(40px, 5vw, 64px) 24px;
}
@include bp (md) {
margin: 0 30px;
padding: clamp(40px, 5vw, 64px) 0;
padding-left: 0;
padding-right: 0;
}
&:before, &:after {
@include bp (md) {
content: "";
display: block;
position: absolute;
@@ -219,17 +224,22 @@
background: $color-tertiary;
transition: transform 0.8s var(--ease-quart);
}
}
&:before {
@include bp (md) {
border-radius: var(--corners) 0 0 var(--corners);
left: 0;
transform: translate3d(calc(-1 * var(--margin-sides)), 0, 0);
}
}
&:after {
@include bp (md) {
border-radius: 0 var(--corners) var(--corners) 0;
right: 0;
transform: translate3d(var(--margin-sides), 0, 0);
}
}
}
// Photo Grid
&__grid {
@@ -254,6 +264,20 @@
// Photo
.photo {
position: relative;
a {
display: block;
}
figcaption {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
/**
* Photo sizes
*/
@@ -330,7 +354,8 @@
transition: opacity 0.4s var(--ease-quart), transform 1.0s var(--ease-quart);
&--small {
border-radius: 0;
border-radius: 6px 6px 0 0;
transform: translate3d(8%, 12%, 0) rotate(-3deg);
}
}
@@ -339,6 +364,10 @@
.postcard {
opacity: 1;
transform: translate3d(3%, 3%, 0) rotate(2deg);
&--small {
transform: translate3d(0,0,0);
}
}
}
}