Improve aspect ratios on mobile
This commit is contained in:
@@ -92,6 +92,7 @@ export interface GridArrangement {
|
|||||||
const tileMinHeight = 130;
|
const tileMinHeight = 130;
|
||||||
const tileMaxAspectRatio = 17 / 9;
|
const tileMaxAspectRatio = 17 / 9;
|
||||||
const tileMinAspectRatio = 4 / 3;
|
const tileMinAspectRatio = 4 / 3;
|
||||||
|
const tileMobileMinAspectRatio = 2 / 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the ideal arrangement of tiles into a grid of a particular size.
|
* Determine the ideal arrangement of tiles into a grid of a particular size.
|
||||||
@@ -136,12 +137,18 @@ export function arrangeTiles(
|
|||||||
tileHeight = (minHeight - (rows - 1) * gap) / rows;
|
tileHeight = (minHeight - (rows - 1) * gap) / rows;
|
||||||
}
|
}
|
||||||
if (tileHeight < tileMinHeight) tileHeight = tileMinHeight;
|
if (tileHeight < tileMinHeight) tileHeight = tileMinHeight;
|
||||||
|
|
||||||
// Impose a minimum and maximum aspect ratio on the tiles
|
// Impose a minimum and maximum aspect ratio on the tiles
|
||||||
const tileAspectRatio = tileWidth / tileHeight;
|
const tileAspectRatio = tileWidth / tileHeight;
|
||||||
|
// We enforce a different min aspect ratio in 1:1s on mobile
|
||||||
|
const minAspectRatio =
|
||||||
|
tileCount === 1 && width < 600
|
||||||
|
? tileMobileMinAspectRatio
|
||||||
|
: tileMinAspectRatio;
|
||||||
if (tileAspectRatio > tileMaxAspectRatio)
|
if (tileAspectRatio > tileMaxAspectRatio)
|
||||||
tileWidth = tileHeight * tileMaxAspectRatio;
|
tileWidth = tileHeight * tileMaxAspectRatio;
|
||||||
else if (tileAspectRatio < tileMinAspectRatio)
|
else if (tileAspectRatio < minAspectRatio)
|
||||||
tileHeight = tileWidth / tileMinAspectRatio;
|
tileHeight = tileWidth / minAspectRatio;
|
||||||
// TODO: We might now be hitting the minimum height or width limit again
|
// TODO: We might now be hitting the minimum height or width limit again
|
||||||
|
|
||||||
return { tileWidth, tileHeight, gap, columns };
|
return { tileWidth, tileHeight, gap, columns };
|
||||||
|
|||||||
@@ -27,11 +27,18 @@ limitations under the License.
|
|||||||
|
|
||||||
.local {
|
.local {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inline-size: 180px;
|
inline-size: 135px;
|
||||||
block-size: 135px;
|
block-size: 160px;
|
||||||
inset: var(--cpd-space-4x);
|
inset: var(--cpd-space-4x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (min-width: 600px) {
|
||||||
|
.local {
|
||||||
|
inline-size: 170px;
|
||||||
|
block-size: 110px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.spotlight {
|
.spotlight {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inline-size: 404px;
|
inline-size: 404px;
|
||||||
|
|||||||
Reference in New Issue
Block a user