👀 Rework how House index is displayed

Use grids to place the index instead of position absolute
Add a condition if the index starts with 1 as it has a quite smaller width
This commit is contained in:
2022-06-27 13:28:58 +02:00
parent 465e673715
commit c9053f9757
3 changed files with 51 additions and 35 deletions

View File

@@ -39,9 +39,7 @@
</p> </p>
</div> </div>
<div class="house__photo" <div class="house__photo grid" class:not-landscape={ratio < 1.475}>
class:not-landscape={ratio < 1.475}
>
<a href={url} sveltekit:noscroll tabindex="0"> <a href={url} sveltekit:noscroll tabindex="0">
<figure class="house__image shadow-photo"> <figure class="house__image shadow-photo">
<Image <Image
@@ -57,9 +55,9 @@
alt={photoAlt} alt={photoAlt}
/> />
</figure> </figure>
<span class="house__index title-index"> </a>
<span class="house__index title-index" class:has-one-start={index.startsWith('1')}>
{index} {index}
</span> </span>
</a>
</div> </div>
</div> </div>

View File

@@ -267,7 +267,7 @@
</section> </section>
{#if photos.length} {#if photos.length}
<section class="location-page__houses grid" bind:this={photosListEl}> <section class="location-page__houses" bind:this={photosListEl}>
{#each photos as { title, image: { id, title: alt, width, height }, slug, city, date_taken }, index} {#each photos as { title, image: { id, title: alt, width, height }, slug, city, date_taken }, index}
<House <House
{title} {title}

View File

@@ -1,19 +1,6 @@
.house { .house {
position: relative; position: relative;
@include bp (sm) {
--columns: 20;
grid-column-start: 3;
}
& > a {
display: block;
width: 100%;
height: 100%;
text-decoration: none;
cursor: zoom-in;
}
// Information // Information
&__info { &__info {
--delay: 0.2s; --delay: 0.2s;
@@ -26,7 +13,7 @@
max-width: min(540px, 85vw); max-width: min(540px, 85vw);
} }
@include bp (sm) { @include bp (sm) {
grid-column: 4 / span 14; grid-column: 6 / span 14;
margin-bottom: 56px; margin-bottom: 56px;
padding: 0; padding: 0;
max-width: 800px; max-width: 800px;
@@ -81,11 +68,23 @@
// Photo // Photo
&__photo { &__photo {
position: relative; position: relative;
display: block; grid-column: span var(--columns);
grid-column: 1 / span 17;
opacity: 0; opacity: 0;
transition: opacity 2s var(--ease-quart); transition: opacity 2s var(--ease-quart);
& > a {
grid-column: span var(--columns);
width: 100%;
height: 100%;
text-decoration: none;
cursor: zoom-in;
@include bp (sm) {
grid-column: 3 / span 17;
grid-row: 1;
}
}
:global(figure) { :global(figure) {
position: relative; position: relative;
z-index: 5; z-index: 5;
@@ -143,7 +142,7 @@
a:hover { a:hover {
:global(img) { :global(img) {
opacity: 0.7; opacity: 0.7;
transform: scale3d(1.03, 1.03, 1.03) !important; transform: scale3d(1.03, 1.03, 1.03);
transition-duration: 1.2s; transition-duration: 1.2s;
} }
} }
@@ -156,28 +155,44 @@
z-index: 1; z-index: 1;
bottom: -64px; bottom: -64px;
right: 20px; right: 20px;
display: block;
text-align: right; text-align: right;
pointer-events: none; pointer-events: none;
user-select: none; user-select: none;
@include bp (sm) { @include bp (sm) {
left: 112.5%; position: relative;
width: 400px; grid-column: 19 / span 6;
top: 50%; grid-row: 1;
white-space: nowrap;
bottom: auto; bottom: auto;
right: auto;
align-self: center;
background: none;
text-align: left; text-align: left;
transform: translate3d(-50%, -50%, 0); }
// Specific cases
&.has-one-start {
@include bp (sm) {
transform: translate3d(15%, 0, 0);
}
} }
} }
// Even photos // Even photos
&:nth-child(even) { &:nth-child(even) {
.house { .house {
// Photo
&__photo { &__photo {
& > a {
@include bp (sm) { @include bp (sm) {
grid-column-start: 4; grid-column: 6 / span 17;
grid-row: 1;
} }
} }
}
// Info
&__info { &__info {
@include bp (sm) { @include bp (sm) {
margin-left: auto; margin-left: auto;
@@ -185,14 +200,17 @@
} }
} }
&__index { &__index {
left: auto;
right: 20px;
@include bp (sm) { @include bp (sm) {
right: auto; grid-column-start: 1;
left: -12%;
text-align: right; text-align: right;
} }
// Specific cases
&.has-one-start {
@include bp (sm) {
transform: translate3d(-8%, 0, 0);
}
}
} }
} }
} }