Skip to content

Commit

Permalink
fix: ensure page content layout columns have the correct sizes (#3560)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmenko authored Jul 2, 2024
1 parent ec43ee7 commit 03ae4b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-icons-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-frontend/application-components': patch
---

Ensure that the page content layouts with two columns maintain the correct sizes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@ const Content = styled.section<
grid-template-areas: ${(props) =>
props.columns === '1' ? 'none' : '"left-column right-column"'};
grid-template-columns: ${(props) => {
// NOTE: using only `?fr` can cause the layout the "break" as `fr`
// is all about distribution of the available space.
// If the content of a column becomes "bigger", the system tries
// to compensate for the lack of space by reducing the width of the
// other column (it does not overflow).
// To fix that, we can use `minmax` to instruct the system that
// the column size has to be maintained. However, this will cause
// some overflow if the content is bigger.
// For us, it's important to ensure that the columns layout maintains
// the correct dimensions and sizes, thus using `minmax`.
switch (props.columns) {
case '1/1':
return '1fr 1fr';
return 'repeat(2, minmax(0, 1fr))';
case '2/1':
return '2fr 1fr';
return 'minmax(0, 2fr) minmax(0, 1fr)';
default:
return '1fr';
return 'minmax(0, 1fr)';
}
}};
gap: ${(props) =>
Expand Down

0 comments on commit 03ae4b2

Please sign in to comment.