Try fixing profile photo sizing
This commit is contained in:
parent
66ea93f0fa
commit
0c8abbabbd
2 changed files with 6 additions and 4 deletions
|
|
@ -30,6 +30,7 @@ export const create = (): Array<PageElement> => [
|
||||||
photo: Image({
|
photo: Image({
|
||||||
imageWebP: meWebP,
|
imageWebP: meWebP,
|
||||||
alt: `a picture of me`,
|
alt: `a picture of me`,
|
||||||
|
imageScreenRatio: 0.3,
|
||||||
}),
|
}),
|
||||||
about: [
|
about: [
|
||||||
`
|
`
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,13 @@ export const Image = ({
|
||||||
alt,
|
alt,
|
||||||
container = false,
|
container = false,
|
||||||
isIgnoredByImageViewer = false,
|
isIgnoredByImageViewer = false,
|
||||||
|
imageScreenRatio = 0.8,
|
||||||
}: {
|
}: {
|
||||||
imageWebP: ResponsiveImage;
|
imageWebP: ResponsiveImage;
|
||||||
alt: string;
|
alt: string;
|
||||||
container?: boolean;
|
container?: boolean;
|
||||||
isIgnoredByImageViewer?: boolean;
|
isIgnoredByImageViewer?: boolean;
|
||||||
|
imageScreenRatio?: number;
|
||||||
}): html => `
|
}): html => `
|
||||||
${
|
${
|
||||||
container
|
container
|
||||||
|
|
@ -28,7 +30,7 @@ export const Image = ({
|
||||||
<picture loading="lazy">
|
<picture loading="lazy">
|
||||||
<source
|
<source
|
||||||
srcset="${imageWebP.srcSet}"
|
srcset="${imageWebP.srcSet}"
|
||||||
sizes="${getSizes(imageWebP)}"
|
sizes="${getSizes(imageWebP, imageScreenRatio)}"
|
||||||
type="image/webp"
|
type="image/webp"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
|
|
@ -45,9 +47,8 @@ export const Image = ({
|
||||||
${container ? `</div>` : ''}
|
${container ? `</div>` : ''}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const IMAGE_SCREEN_RATIO = 0.8;
|
const getSizes = (image: ResponsiveImage, imageScreenRatio: number): string =>
|
||||||
const getSizes = (image: ResponsiveImage): string =>
|
|
||||||
image.images
|
image.images
|
||||||
.slice(0, -1)
|
.slice(0, -1)
|
||||||
.map((d) => `(max-width: ${d.width / IMAGE_SCREEN_RATIO}px) ${d.width}px,`)
|
.map((d) => `(max-width: ${d.width / imageScreenRatio}px) ${d.width}px,`)
|
||||||
.join('\n') + `\n${last(image.images)!.width}px`;
|
.join('\n') + `\n${last(image.images)!.width}px`;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue