-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ResponsiveLayout): nested ResponsiveLayout background takes precedence #909
Changes from 2 commits
25a9304
f143ed6
cd90d50
19ab818
e22bb3d
bba51a2
c4e2c97
a524acd
ba3fbf2
dae987a
a1f692a
4518827
6b93cc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,57 +6,52 @@ import {vars as skinVars} from './skins/skin-contract.css'; | |
export const MOBILE_SIDE_MARGIN = 16; | ||
export const TABLET_SIDE_MARGIN = 32; | ||
export const SMALL_DESKTOP_SIDE_MARGIN = 40; | ||
export const LARGE_DESKTOP_MAX_WIDTH = 1224; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you have broken the large desktop max width: try this snippet in master and in your branch playroom: <ResponsiveLayout>
<Placeholder/>
</ResponsiveLayout> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'll check, and add a test for this case, to better cover this situation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes it would be nice to have some screenshot tests for these cases too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pladaria this !! |
||
|
||
const sideMargin = createVar(); | ||
export const vars = {sideMargin}; | ||
|
||
export const container = sprinkles({width: '100%'}); | ||
export const container = style([ | ||
sprinkles({width: '100%'}), | ||
{ | ||
vars: { | ||
[sideMargin]: '0px', | ||
}, | ||
'@media': { | ||
[mq.desktopOrBigger]: { | ||
vars: { | ||
[sideMargin]: `${SMALL_DESKTOP_SIDE_MARGIN}px`, | ||
}, | ||
}, | ||
[mq.tablet]: { | ||
vars: { | ||
[sideMargin]: `${TABLET_SIDE_MARGIN}px`, | ||
}, | ||
}, | ||
[mq.mobile]: { | ||
vars: { | ||
[sideMargin]: `${MOBILE_SIDE_MARGIN}px`, | ||
}, | ||
}, | ||
}, | ||
selectors: { | ||
'& &': { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This causes a bug, that is already broken in master: if you place a I've detected some cases in webapp, where some developers are trying to workaround it by adding their own paddings by hand 🤦 because they don't know the problem is the nested There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, I'll try to fix that ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please post here a code snippet for the playroom that reproduces the issue ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @atabel is it the same problem with sheets? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've fixed using couple css variables, I don't know if there is any better option, any advice welcome. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm... I think the css variables approach is too convoluted. I'd prefer a prop in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would go for a different component, for internal responsive layout, becuase it wont needs to handle large desktop extra margins, for example (that makes everything lot complex). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done ! |
||
margin: `0 calc(-1 * ${sideMargin})`, | ||
width: 'auto', | ||
}, | ||
}, | ||
}, | ||
]); | ||
|
||
export const backgroundVariant = { | ||
inverse: sprinkles({background: skinVars.colors.backgroundBrand}), | ||
alternative: sprinkles({background: skinVars.colors.backgroundAlternative}), | ||
}; | ||
|
||
export const responsiveLayout = style({ | ||
margin: 'auto', | ||
paddingLeft: 'env(safe-area-inset-left)', | ||
paddingRight: 'env(safe-area-inset-right)', | ||
|
||
vars: { | ||
[sideMargin]: '0px', | ||
}, | ||
|
||
'@media': { | ||
[mq.largeDesktop]: { | ||
width: LARGE_DESKTOP_MAX_WIDTH, | ||
maxWidth: `calc(100% - ${SMALL_DESKTOP_SIDE_MARGIN * 2}px)`, // to make ResponsiveLayout work inside desktop modals | ||
}, | ||
[mq.desktop]: { | ||
margin: `0 ${SMALL_DESKTOP_SIDE_MARGIN}px`, | ||
}, | ||
[mq.tablet]: { | ||
margin: `0 ${TABLET_SIDE_MARGIN}px`, | ||
|
||
vars: { | ||
[sideMargin]: `${TABLET_SIDE_MARGIN}px`, | ||
}, | ||
}, | ||
[mq.mobile]: { | ||
margin: `0 ${MOBILE_SIDE_MARGIN}px`, | ||
|
||
vars: { | ||
[sideMargin]: `${MOBILE_SIDE_MARGIN}px`, | ||
}, | ||
}, | ||
}, | ||
|
||
selectors: { | ||
'& &': { | ||
margin: 0, | ||
width: 'auto', | ||
}, | ||
}, | ||
margin: `0 ${sideMargin}`, | ||
}); | ||
|
||
export const fullWidth = style([ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry but I don't like this. These are a bunch of workarounds to allow compositions that should be forbidden.
ResponsiveLayouts shouldn't be nested. This is not an issue of the component, it is a problem from the part that uses this component to compose pages or sections in unexpected ways.
If I understand this PR, now you can place ResponsiveLayouts inside dialogs, sheets, footers, other ResponsiveLayouts... It makes no sense to me.
Perhaps the modules shouldn't use a ResponsiveLayout and it should be added by the piece that composes those modules when needed. I guess I'm missing a lot of context about your needs and your implementation details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I don't like nested ResponsiveLayouts either, and I think we should found a way to avoid that. But this PR is not about that, we already supported nested ResponsiveLayouts but we had a bug with background color that this PR fixes.
If we want to discuss a better approach for modular pages in novum webapp or other use cases where we are nesting ResponsiveLayouts, ok. But I'd keep that discussion outside of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, its another discussion, we can talk about that. This PR gets enmarronated because the large desktop extra margins, this makes everything worse, if we had another component, or a prop to specify that we should add these extra magins, the component would be really small and simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because of the large desktop extra margins :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented the props approach to fix the button fixed footer layout bug.