Skip to content
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

Fix paddings not taking unsafe area into account #528

Merged
merged 2 commits into from
Nov 28, 2021
Merged

Fix paddings not taking unsafe area into account #528

merged 2 commits into from
Nov 28, 2021

Conversation

wojtekmaj
Copy link
Contributor

@wojtekmaj wojtekmaj commented Nov 7, 2021

When website on which overlay is displayed uses viewport-fit: cover, website declares it will handle unsafe areas on its own. This also applies to the overlay displayed on top of it.

Before:
Zrzut ekranu 2021-11-7 o 18 49 06

After:
Zrzut ekranu 2021-11-7 o 18 54 05

@wojtekmaj wojtekmaj changed the title Fix paddings not taking safe area into account Fix paddings not taking unsafe area into account Nov 7, 2021
Comment on lines +26 to +27
pageHeaderContainer.style.paddingLeft = 'max(1.5rem, env(safe-area-inset-left))';
pageHeaderContainer.style.paddingRight = 'max(1.5rem, env(safe-area-inset-right))';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem like it would work on IE11? Is it possible to have a graceful fallback?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we need this as well? Thinking about it the answer seems to be no since we have a global wrapper outside of the page header?

pageHeaderContainer.style.paddingBottom = 'max(1rem, env(safe-area-inset-bottom))';
pageHeaderContainer.style.paddingTop = 'max(1rem, env(safe-area-inset-top))';

Copy link
Contributor Author

@wojtekmaj wojtekmaj Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had no intention of changing the behavior in any way other than expanding paddings when needed if they are smaller than env-area-inset-*.

So the answer is: If pageHeaderContainer.style.padding = '1rem 1.5rem'; is not needed, then these two lines also aren't. But if it's to stay, these overrides are also to stay to allow expading paddings beyond 1.5rem if needed.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested on a device with a notch and I just realised that the top bar actually never hit the unsafe area due to the browser address bar, so I think we won't need the top overrides 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not if you display the webpage as PWA with fullscreen mode :)

Comment on lines 23 to 24
footer.style.bottom = '0';
footer.style.bottom = 'env(safe-area-inset-bottom)';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a duplicate rule?

Copy link
Contributor Author

@wojtekmaj wojtekmaj Nov 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Values are ignored by the browsers if they don't understand the syntax, so previous value should be retained, much like in pure CSS:

bottom: 0; /* Fallback for older browsers */
bottom: env(safe-area-inset-bottom);

Try this:

el.style.marginTop = '100px';
el.style.marginTop = 'pee pee poo poo';

and you'll see that because the browser didn't understand the 2nd value, 100px is retained. And that's how IE11 should remain compatible!

@pmmmwh pmmmwh self-requested a review November 14, 2021 02:52
Copy link
Owner

@pmmmwh pmmmwh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have much time to test this on an emulator with a notch currently, can you confirm the behaviour for portrait orientation as well? Otherwise I think this should be good!

(Also - thank you!)

Comment on lines +26 to +27
pageHeaderContainer.style.paddingLeft = 'max(1.5rem, env(safe-area-inset-left))';
pageHeaderContainer.style.paddingRight = 'max(1.5rem, env(safe-area-inset-right))';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we need this as well? Thinking about it the answer seems to be no since we have a global wrapper outside of the page header?

pageHeaderContainer.style.paddingBottom = 'max(1rem, env(safe-area-inset-bottom))';
pageHeaderContainer.style.paddingTop = 'max(1rem, env(safe-area-inset-top))';

Copy link
Owner

@pmmmwh pmmmwh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added more changes for unsafe area, I think this is good to go!

I'll double check tomorrow on a device with IE 😄

Comment on lines +29 to +30
footer.style.paddingBottom = '0';
footer.style.paddingBottom = 'env(safe-area-inset-bottom)';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of moving the fixed button panel up, I opted to add useless padding to the panel so at the background color would bleed into the unsafe area.

Comment on lines +78 to +79
iframe.style.minHeight = '100vh';
iframe.style.minHeight = '-webkit-fill-available';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes an issue where the button panel would be hidden due to how 100vh is calculated on iOS Safari.

@pmmmwh pmmmwh merged commit fc4d7b5 into pmmmwh:main Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants