Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/components/Image.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
eager: true,
import: 'default',
query: {
enhanced: true
enhanced: true,
w: '520;640;800;1280;1920;2560;3840'
}
}
)
Expand Down
6 changes: 5 additions & 1 deletion src/lib/components/LatestNews.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import { onMount } from 'svelte'

const pageSize = 6
// Matches the 1/2/3-column grid below so browsers choose thumbnail-sized
// responsive image variants rather than downloading page-width images.
const newsCardImageSizes =
'(max-width: 500px) calc(100vw - 1rem), (max-width: 850px) calc((100vw - 3rem) / 2), 13rem'
let newsItems: NewsItem[] = $state(Array.from({ length: pageSize }))
let loading = $state(true)
let currentPage = $state(1)
Expand Down Expand Up @@ -40,7 +44,7 @@
{#if newsItems.length > 0}
<div class="news-grid">
{#each newsItems as item}
<NewsCard {item} {loading} imageSizes="500px" />
<NewsCard {item} {loading} imageSizes={newsCardImageSizes} />
{/each}
</div>

Expand Down
4 changes: 4 additions & 0 deletions src/lib/components/NewsCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
interface Props {
item?: NewsItem
loading?: boolean
/**
* Passed by the parent layout so responsive images download a variant close to the
* card's rendered width instead of the image component's broad default.
*/
imageSizes?: string
id?: string
}
Expand Down
7 changes: 6 additions & 1 deletion src/lib/components/PressCoveragePanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
loading?: boolean
}

// Matches the 1/2/3-column grid below so browsers choose thumbnail-sized
// responsive image variants rather than downloading page-width images.
const newsCardImageSizes =
'(max-width: 500px) calc(100vw - 1rem), (max-width: 850px) calc((100vw - 3rem) / 2), 13rem'

let { coverage = [], typeOrder = [], outletOrder = [], loading = false }: Props = $props()

function toNewsItem(item: PressCoverage): NewsItem {
Expand Down Expand Up @@ -75,7 +80,7 @@

<div class="coverage-cards">
{#each filteredCoverage as item (item.id)}
<NewsCard id={item.id} item={toNewsItem(item)} />
<NewsCard id={item.id} item={toNewsItem(item)} imageSizes={newsCardImageSizes} />
{/each}
</div>
{/if}
Expand Down
Loading