[fix] Prevent layout shifting on hovering "Who's using Svelte?" (#6639)

pull/6645/head
btvoidx 4 years ago committed by GitHub
parent 5f693c84ee
commit b1621d697d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,10 +1,30 @@
<script> <script>
import { companies } from './WhosUsingSvelte.js'; import { companies } from './WhosUsingSvelte.js';
const randomizer = ({prominent}) => Math.random(); const randomizer = ({ prominent }) => Math.random();
const doSort = (a, b) => randomizer(b) - randomizer(a); const doSort = (a, b) => randomizer(b) - randomizer(a);
const sortedCompanies = companies.sort(doSort); const sortedCompanies = companies.sort(doSort);
</script> </script>
<div class="logos">
{#each sortedCompanies as { href, filename, alt, style, picture, span }, index}
<a target="_blank" rel="noopener" {href} style={style || ""}>
{#if picture}
<picture>
{#each picture as { type, srcset }}
<source {type} {srcset} />
{/each}
<img src="/whos-using-svelte/{filename}" {alt} loading="lazy" />
</picture>
{:else}
<img src="/whos-using-svelte/{filename}" {alt} loading="lazy" />
{#if span}
<span>{span}</span>
{/if}
{/if}
</a>
{/each}
</div>
<style> <style>
.logos { .logos {
margin: 1em 0 0 0; margin: 1em 0 0 0;
@ -17,44 +37,29 @@
display: flex; display: flex;
align-items: center; align-items: center;
border: 2px solid var(--second); border: 2px solid var(--second);
padding: 5px 10px; padding: 0;
border-radius: 20px; border-radius: 20px;
color: var(--text); color: var(--text);
} }
picture, picture,
img { img {
height: 100%; height: 100%;
padding: 5px 10px;
transition: transform 0.2s;
}
picture:hover,
img:hover {
transform: scale(1.2);
} }
@media (min-width: 540px) { @media (min-width: 540px) {
a { a {
height: 60px; height: 60px;
padding: 10px 20px;
border-radius: 30px; border-radius: 30px;
} }
picture,
img {
padding: 10px 20px;
}
} }
</style> </style>
<div class="logos">
{#each sortedCompanies as {href, filename, alt, style, picture, span}, index}
<a
target="_blank"
rel="noopener"
{href}
style="{style || ''}"
>
{#if picture}
<picture>
{#each picture as {type, srcset}}
<source {type} {srcset}>
{/each}
<img src="/whos-using-svelte/{filename}" {alt} loading="lazy">
</picture>
{:else}
<img src="/whos-using-svelte/{filename}" {alt} loading="lazy">
{#if span}
<span>{span}</span>
{/if}
{/if}
</a>
{/each}
</div>

Loading…
Cancel
Save