const DEFAULT_RESOLUTIONS = [
640,
750,
828,
960,
1080,
1280,
1668,
1920,
2048,
2560,
3200,
3840,
4480,
5120,
6016
];
const LIMITED_RESOLUTIONS = [
640,
750,
828,
1080,
1280,
1668,
2048,
2560
];
const getWidths = ({
width,
layout,
breakpoints = DEFAULT_RESOLUTIONS,
originalWidth
}) => {
const smallerThanOriginal = (w) => !originalWidth || w <= originalWidth;
if (layout === "full-width") {
return breakpoints.filter(smallerThanOriginal);
}
if (!width) {
return [];
}
const doubleWidth = width * 2;
const maxSize = originalWidth ? Math.min(doubleWidth, originalWidth) : doubleWidth;
if (layout === "fixed") {
return originalWidth && width > originalWidth ? [originalWidth] : [width, maxSize];
}
if (layout === "responsive") {
return [
width,
doubleWidth,
...breakpoints
].filter((w) => w <= maxSize).sort((a, b) => a - b);
}
return [];
};
const getSizesAttribute = ({
width,
layout
}) => {
if (!width || !layout) {
return void 0;
}
switch (layout) {
case `responsive`:
return `(min-width: ${width}px) ${width}px, 100vw`;
case `fixed`:
return `${width}px`;
case `full-width`:
return `100vw`;
case "none":
default:
return void 0;
}
};
export {
DEFAULT_RESOLUTIONS,
LIMITED_RESOLUTIONS,
getSizesAttribute,
getWidths
};