Skip to content

Commit

Permalink
Merge pull request #3700 from owid/homepage-thumbnail-size
Browse files Browse the repository at this point in the history
🐛 increase the resolution of homepage intro primary thumbnails
  • Loading branch information
ikesau authored Jun 10, 2024
2 parents 572c04a + 9e34b7d commit 6002b04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
12 changes: 9 additions & 3 deletions site/gdocs/components/HomepageIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { formatAuthors, groupBy } from "@ourworldindata/utils"
import { Button } from "@ourworldindata/components"
import { useLinkedDocument } from "../utils.js"
import { DocumentContext } from "../OwidGdoc.js"
import Image from "./Image.js"
import Image, { ImageParentContainer } from "./Image.js"
import { BlockErrorFallback } from "./BlockErrorBoundary.js"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js"
import { faArrowRight } from "@fortawesome/free-solid-svg-icons"
Expand All @@ -17,6 +17,7 @@ import { BAKED_BASE_URL } from "../../../settings/clientSettings.js"
type FeaturedWorkTileProps = EnrichedBlockHomepageIntroPost & {
isTertiary?: boolean
className?: string
thumbnailSize?: ImageParentContainer
}

function FeaturedWorkTile({
Expand All @@ -28,6 +29,7 @@ function FeaturedWorkTile({
url,
filename,
className = "",
thumbnailSize = "thumbnail",
}: FeaturedWorkTileProps) {
const { linkedDocument, errorMessage } = useLinkedDocument(url)
const { isPreviewing } = useContext(DocumentContext)
Expand Down Expand Up @@ -74,7 +76,7 @@ function FeaturedWorkTile({
<Image
shouldLightbox={false}
filename={thumbnailFilename}
containerType="thumbnail"
containerType={thumbnailSize}
/>
)}
{kicker && (
Expand Down Expand Up @@ -177,7 +179,11 @@ export function HomepageIntro({ className, featuredWork }: HomepageIntroProps) {
<div className="grid grid-cols-9 span-cols-9 span-md-cols-12 homepage-intro__featured-work-container">
<div className="homepage-intro__primary-tiles span-cols-6">
{primary.map((work, i) => (
<FeaturedWorkTile key={i} {...work} />
<FeaturedWorkTile
thumbnailSize="span-6"
key={i}
{...work}
/>
))}
</div>
<div className="homepage-intro__secondary-tiles span-cols-3 col-start-7">
Expand Down
13 changes: 12 additions & 1 deletion site/gdocs/components/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ const gridSpan6 = generateResponsiveSizes(6)
const gridSpan7 = generateResponsiveSizes(7)
const gridSpan8 = generateResponsiveSizes(8)

type ImageParentContainer = Container | "thumbnail" | "full-width"
export type ImageParentContainer =
| Container
| "thumbnail"
| "full-width"
| "span-5"
| "span-6"
| "span-7"
| "span-8"

const containerSizes: Record<ImageParentContainer, string> = {
["default"]: gridSpan8,
Expand All @@ -46,6 +53,10 @@ const containerSizes: Record<ImageParentContainer, string> = {
["full-width"]: "100vw",
["key-insight"]: gridSpan5,
["author-header"]: gridSpan2,
["span-5"]: gridSpan5,
["span-6"]: gridSpan6,
["span-7"]: gridSpan7,
["span-8"]: gridSpan8,
}

export default function Image(props: {
Expand Down

0 comments on commit 6002b04

Please sign in to comment.