-
Notifications
You must be signed in to change notification settings - Fork 13.4k
refactor(core): use Capacitor's new safe area variables #30865
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
Author
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. Diff is only the new toggle button
Member
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. We really should update these tests so all screenshots aren't updated when a new button is added. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,13 @@ | |||||||||||||||||||||||||||||||||||
| --ion-safe-area-bottom: 40px; | ||||||||||||||||||||||||||||||||||||
| --ion-safe-area-left: 40px; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| .safe-area-capacitor { | ||||||||||||||||||||||||||||||||||||
|
Member
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 doesn't seem to add much to this test besides forcing all screenshots to be updated and adding new ones. Even the values are the exact same so there won't be any screenshot difference. Can we not just check that the right value is being used (see my e2e edit)? |
||||||||||||||||||||||||||||||||||||
| --safe-area-inset-top: 40px; | ||||||||||||||||||||||||||||||||||||
| --safe-area-inset-right: 40px; | ||||||||||||||||||||||||||||||||||||
| --safe-area-inset-bottom: 40px; | ||||||||||||||||||||||||||||||||||||
| --safe-area-inset-left: 40px; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| </style> | ||||||||||||||||||||||||||||||||||||
| </head> | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
@@ -48,6 +55,7 @@ | |||||||||||||||||||||||||||||||||||
| </ion-header> | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| <ion-content id="main"> | ||||||||||||||||||||||||||||||||||||
| <button id="toggle-safe-area" onclick="toggleSafeArea()">Toggle Safe Area Classes</button> | ||||||||||||||||||||||||||||||||||||
| <ion-card> | ||||||||||||||||||||||||||||||||||||
| <ion-card-header> | ||||||||||||||||||||||||||||||||||||
| <ion-card-title>Card</ion-card-title> | ||||||||||||||||||||||||||||||||||||
|
|
@@ -143,6 +151,19 @@ | |||||||||||||||||||||||||||||||||||
| document.body.appendChild(toast); | ||||||||||||||||||||||||||||||||||||
| await toast.present(); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // toggle between safe area classes based on button click | ||||||||||||||||||||||||||||||||||||
| function toggleSafeArea() { | ||||||||||||||||||||||||||||||||||||
| console.log('Toggling safe area classes'); | ||||||||||||||||||||||||||||||||||||
| const htmlTag = document.documentElement; | ||||||||||||||||||||||||||||||||||||
| if (htmlTag.classList.contains('safe-area-capacitor')) { | ||||||||||||||||||||||||||||||||||||
| htmlTag.classList.remove('safe-area-capacitor'); | ||||||||||||||||||||||||||||||||||||
| htmlTag.classList.add('safe-area'); | ||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||
| htmlTag.classList.remove('safe-area'); | ||||||||||||||||||||||||||||||||||||
| htmlTag.classList.add('safe-area-capacitor'); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+156
to
+166
Member
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||
| </script> | ||||||||||||||||||||||||||||||||||||
| </body> | ||||||||||||||||||||||||||||||||||||
| </html> | ||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -252,10 +252,12 @@ html.plt-ios.plt-hybrid, html.plt-ios.plt-pwa { | |
|
|
||
| @supports (padding-top: env(safe-area-inset-top)) { | ||
| html { | ||
| --ion-safe-area-top: env(safe-area-inset-top); | ||
| --ion-safe-area-bottom: env(safe-area-inset-bottom); | ||
| --ion-safe-area-left: env(safe-area-inset-left); | ||
| --ion-safe-area-right: env(safe-area-inset-right); | ||
| // `--safe-area-inset-*` are set by Capacitor | ||
| // @see https://capacitorjs.com/docs/apis/system-bars#android-note | ||
| --ion-safe-area-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px)); | ||
|
Member
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. Do we need to fallback to |
||
| --ion-safe-area-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)); | ||
| --ion-safe-area-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px)); | ||
| --ion-safe-area-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px)); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
Rather than adding additional screenshot tests for this, what if we just checked that the value of the CSS variables are being used when set: