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

feat(safe-area): safe area mixin #28224

Closed
wants to merge 6 commits into from
Closed

feat(safe-area): safe area mixin #28224

wants to merge 6 commits into from

Conversation

thetaPC
Copy link
Contributor

@thetaPC thetaPC commented Sep 23, 2023

Issue number: N/A


What is the current behavior?

The safe area defines the area within a view that isn't covered by a navigation bar, tab bar, toolbar, or other views a view controller might provide.

The safe areas are reliant on the device's direction, not the app's. This leads to using styles like padding-right and padding-left. However, this can cause issues with the app's direction (LTR/RTL). The team needs to add the correct styles, which can lead to either a bigger block of code or forgetting about the fact that it's based on device direction.

What is the new behavior?

I added a new mixin that will take accept two values: start and end. These values are the additional values that the developer wants to add to either --ion-safe-area-left or --ion-safe-area-right. For example, start will be added to ion-safe-area-left in ltr and ion-safe-area-right in rtl. The end will be added to ion-safe-area-right in ltr and ion-safe-area-left in rtl.

The team wouldn't have to manually do the math with the mixin.

Does this introduce a breaking change?

  • Yes
  • No

Other information

I only updated the .item-divider-inner style to use the mixin to start with. The point of this PR is to introduce the mixin. Another PR will be created to add the mixin to the styles.

@github-actions github-actions bot added the package: core @ionic/core package label Sep 23, 2023
@thetaPC thetaPC changed the title style(safe-area): safe area mixin feat(safe-area): safe area mixin Jan 25, 2024
@thetaPC thetaPC marked this pull request as ready for review January 25, 2024 19:26
@thetaPC thetaPC requested review from brandyscarney and a team as code owners January 25, 2024 19:26
// Add padding for the safe areas on the left and right of the device.
// @param {string} $start - amount to add to start.
// @param {string} $end - amount to add to end.
@mixin safe-area-padding($start, $end) {
Copy link
Member

Choose a reason for hiding this comment

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

Is the goal to eventually include the top and bottom padding in this mixin as well? If not I think this should be called safe-area-padding-horizontal.

padding-left: calc(var(--ion-safe-area-left, 0px) + var(--inner-padding-end));
}
/* stylelint-enable */
@include safe-area-padding(null, var(--inner-padding-end));
Copy link
Member

Choose a reason for hiding this comment

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

This is no longer using the --inner-padding-start property:

Before After
.item-divider-inner {
  padding-right: calc(var(--ion-safe-area-right, 0px) + var(--inner-padding-end));
  padding-left: var(--inner-padding-start);
}

:host-context([dir=rtl]) .item-divider-inner {
  padding-right: var(--inner-padding-start);
  padding-left: calc(var(--ion-safe-area-left, 0px) + var(--inner-padding-end));
}

[dir=rtl] .item-divider-inner {
  padding-right: var(--inner-padding-start);
  padding-left: calc(var(--ion-safe-area-left, 0px) + var(--inner-padding-end));
}

@supports selector(:dir(rtl)) {
  .item-divider-inner:dir(rtl) {
    padding-right: var(--inner-padding-start);
    padding-left: calc(var(--ion-safe-area-left, 0px) + var(--inner-padding-end));
  }
}
.item-divider-inner {
  padding-right: calc(var(--ion-safe-area-right, 0) + var(--inner-padding-end));
}

:host-context([dir=rtl]) .item-divider-inner {
  padding-left: calc(var(--ion-safe-area-left, 0) + var(--inner-padding-end));
  padding-right: unset;
}

[dir=rtl] .item-divider-inner {
  padding-left: calc(var(--ion-safe-area-left, 0) + var(--inner-padding-end));
  padding-right: unset;
}

@supports selector(:dir(rtl)) {
  .item-divider-inner:dir(rtl) {
    padding-left: calc(var(--ion-safe-area-left, 0) + var(--inner-padding-end));
    padding-right: unset;
  }
}

@thetaPC
Copy link
Contributor Author

thetaPC commented Mar 28, 2024

Closing this because it's starting to get more complex. The complexity doesn't justify the amount of times that safe area is being used in Ionic.

@thetaPC thetaPC closed this Mar 28, 2024
@thetaPC thetaPC deleted the safe-area-mixin branch March 28, 2024 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants