-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Conversation
// 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) { |
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.
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)); |
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 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;
}
} |
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. |
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
andpadding-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
andend
. 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 toion-safe-area-left
in ltr andion-safe-area-right
in rtl. Theend
will be added toion-safe-area-right
in ltr andion-safe-area-left
in rtl.The team wouldn't have to manually do the math with the mixin.
Does this introduce a breaking change?
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.