chore: better gallery layout and astro image tags
continuous-integration/drone/push Build is failing Details

main
parent 48bd9e459c
commit 58e8e5d43c

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Before

Width:  |  Height:  |  Size: 238 KiB

After

Width:  |  Height:  |  Size: 238 KiB

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 200 KiB

@ -2,10 +2,11 @@
import { getCollection } from 'astro:content' import { getCollection } from 'astro:content'
import PageLayout from '../layouts/PageLayout.astro' import PageLayout from '../layouts/PageLayout.astro'
import { Content as WhatPhcContent, frontmatter as whatsPhcFrontmatter } from '../content/meta/whats-phc.md' import { Content as WhatPhcContent, frontmatter as whatsPhcFrontmatter } from '../content/meta/whats-phc.md'
import { Image } from 'astro:assets'
const news = await getCollection('news') const news = await getCollection('news')
const galleryCollage = (await Astro.glob('@/assets/gallery/*.jpg')).map(({ default: { src } }) => src) const galleryCollage = await Astro.glob('@/assets/gallery/*.jpg')
--- ---
<PageLayout pageTags="homepage"> <PageLayout pageTags="homepage">
@ -117,19 +118,19 @@ const galleryCollage = (await Astro.glob('@/assets/gallery/*.jpg')).map(({ defau
</div> </div>
</a> </a>
<!-- <a href="#" style="--masonry-height: 2;"> <!-- <a href="#" style="--masonry-height: 2;">
<div class="project"> <div class="project">
<div class="image"> <div class="image">
<div class="box"></div> <div class="box"></div>
</div> </div>
<div class="title">PHC-Bot</div> <div class="title">PHC-Bot</div>
<div class="description"> <div class="description">
Un bot con cui chattare per chiedere informazioni o supporto tecnico. Un bot con cui chattare per chiedere informazioni o supporto tecnico.
</div>
</div> </div>
</div> </a> -->
</a> -->
<a target="_blank" href="https://lab.phc.dm.unipi.it/orario/" style="--masonry-height: 1;"> <a target="_blank" href="https://lab.phc.dm.unipi.it/orario/" style="--masonry-height: 1;">
<div class="project" style="--card-bg: #75ca75;"> <div class="project" style="--card-bg: #75ca75;">
<div class="image auto"> <div class="image">
<img src="https://lab.phc.dm.unipi.it/orario/icon.png" alt="Logo Orario" /> <img src="https://lab.phc.dm.unipi.it/orario/icon.png" alt="Logo Orario" />
</div> </div>
<div class="title">Orario</div> <div class="title">Orario</div>
@ -234,11 +235,24 @@ const galleryCollage = (await Astro.glob('@/assets/gallery/*.jpg')).map(({ defau
</div> </div>
<div class="gallery-collage"> <div class="gallery-collage">
{ {
galleryCollage.map((src, i) => ( galleryCollage.map((module, i) => {
<div class="card"> const src = module.default.src
<img src={src} alt={`gallery image ${i}`} /> const filename = src.split('/').at(-1).split('?').at(0).split('.').at(0)
</div>
)) const [rows, cols] = filename.includes('@')
? filename
.split('@')
.at(-1)
.split('x')
.map(s => parseInt(s))
: [1, 1]
return (
<div class="card" style={`--rows: ${rows}; --cols: ${cols};`}>
<Image src={module.default} alt={`gallery image ${i}`} />
</div>
)
})
} }
</div> </div>
<div class="card large" style="--card-base: #ddd;"> <div class="card large" style="--card-base: #ddd;">

@ -753,35 +753,60 @@
} }
.gallery-collage { .gallery-collage {
display: flex; // display: flex;
// flex-wrap: wrap;
place-content: center; // width: 64rem;
align-items: center; max-width: 100%;
gap: 1rem;
flex-wrap: wrap; --cell-size: 6rem;
width: 100%; display: grid;
grid-template-columns: repeat(auto-fit, calc(var(--cell-size)));
grid-auto-rows: calc(var(--cell-size));
grid-auto-flow: dense;
gap: 1rem;
max-width: 64rem; // place-content: center;
// align-items: center;
@media screen and (max-width: $screen-desktop-min) {
grid-template-columns: auto;
grid-template-rows: auto;
grid-auto-rows: auto;
}
& > .card { & > .card {
padding: 3px; padding: 3px;
overflow: hidden; overflow: hidden;
width: 100%;
height: 100%;
grid-column: span var(--cols, 1);
grid-row: span var(--rows, 1);
@media screen and (max-width: $screen-desktop-min) { @media screen and (max-width: $screen-desktop-min) {
max-width: 100%; max-width: 100%;
grid-column: span 1;
grid-row: span 1;
} }
img { img {
display: grid; display: grid;
max-width: 25rem; width: 100%;
max-height: 25rem; height: 100%;
overflow: hidden;
border-radius: 3px; border-radius: 3px;
object-fit: cover;
@media screen and (max-width: $screen-desktop-min) { @media screen and (max-width: $screen-desktop-min) {
max-height: none; max-height: none;

@ -79,7 +79,7 @@
gap: 4rem; gap: 4rem;
padding: 3rem 0 6rem; padding: 3rem 2rem 6rem;
background: var(--homepage-principal-bg); background: var(--homepage-principal-bg);
@ -103,7 +103,9 @@
& > .logo { & > .logo {
z-index: 2; z-index: 2;
max-width: 640px;
width: 32rem;
position: relative; position: relative;
user-select: none; user-select: none;
@ -114,6 +116,10 @@
// drop-shadow(4px 0 0 var(--palette-black)) drop-shadow(0 4px 0 var(--palette-black)) // drop-shadow(4px 0 0 var(--palette-black)) drop-shadow(0 4px 0 var(--palette-black))
// drop-shadow(-4px 0 0 var(--palette-black)) drop-shadow(0 -4px 0 var(--palette-black)); // drop-shadow(-4px 0 0 var(--palette-black)) drop-shadow(0 -4px 0 var(--palette-black));
} }
max-width: calc(100vw - 3rem);
@media screen and (max-width: $screen-desktop-min) {
}
} }
& > .whats-phc { & > .whats-phc {
@ -177,8 +183,10 @@
padding-bottom: 6rem; padding-bottom: 6rem;
.project-list { .project-list {
width: calc(20rem * 3 + 1.5rem * 2 + 6rem * 2); // width: calc(20rem * 3 + 1.5rem * 2 + 6rem * 2);
max-width: calc(100vw - 2rem); // HACK: capire come si propagano le width per bene // max-width: calc(100vw - 2rem); // HACK: capire come si propagano le width per bene
max-width: calc(20rem * 3 + 1.5rem * 2 + 6rem * 2);
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
@ -228,13 +236,13 @@
background: #0003; background: #0003;
border: 3px solid #0006; border: 3px solid #0006;
border-radius: 6px; border-radius: 6px;
width: 5rem; width: 4rem;
height: 5rem; height: 4rem;
} }
img { img {
width: 5rem; width: 4rem;
height: 5rem; height: 4rem;
} }
&.cover { &.cover {
@ -243,12 +251,12 @@
} }
} }
&.auto { // &.auto {
img { // img {
width: auto; // width: auto;
height: auto; // height: auto;
} // }
} // }
} }
.description { .description {

Loading…
Cancel
Save