Skip to content

Commit

Permalink
fix(toast): statusbarPadding
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Aug 9, 2018
1 parent 6e3e07b commit 3da1bf4
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 55 deletions.
2 changes: 0 additions & 2 deletions core/.stylelintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ rules:
- margin
- margin-left
- margin-right
- margin-top
- margin-bottom
- border-radius
- border-top-left-radius
- border-top-right-radius
Expand Down
3 changes: 1 addition & 2 deletions core/src/components/action-sheet/action-sheet.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
}

.action-sheet-wrapper {
@include margin(constant(safe-area-inset-top), auto, constant(safe-area-inset-bottom), auto);
@include margin(env(safe-area-inset-top), auto, env(safe-area-inset-bottom), auto);
@include margin(var(--ion-statusbar-padding), auto, var(--ion-bottom-padding), auto);
}


Expand Down
4 changes: 4 additions & 0 deletions core/src/components/action-sheet/test/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
</ion-content>

<style>
:root {
--ion-statusbar-padding: 20px;
--ion-bottom-padding: 40px;
}
.my-custom-class {
--max-width: 300px;
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/components/app/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ ion-app.statusbar-padding {
@supports (padding-top: constant(safe-area-inset-top)) {
ion-app.statusbar-padding {
--ion-statusbar-padding: constant(safe-area-inset-top);
--ion-bottom-padding: constant(safe-area-inset-bottom);
}
}

@supports (padding-top: env(safe-area-inset-top)) {
ion-app.statusbar-padding {
--ion-statusbar-padding: env(safe-area-inset-top);
--ion-bottom-padding: env(safe-area-inset-bottom);
}
}
8 changes: 3 additions & 5 deletions core/src/components/footer/footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ ion-footer {
z-index: $z-index-toolbar;
}

@supports (padding-top: env(safe-area-inset-top)) {
ion-footer ion-toolbar:last-child {
padding-bottom: env(safe-area-inset-bottom);
}
}
ion-footer ion-toolbar:last-child {
padding-bottom: var(--ion-bottom-padding);
}
5 changes: 2 additions & 3 deletions core/src/components/picker/picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ ion-picker {
}

.picker-columns {
@include margin(null, null, constant(safe-area-inset-bottom), null);
@include margin(null, null, env(safe-area-inset-bottom), null);

@include rtl() {
// Date is the same format in both directions
flex-direction: row-reverse;
Expand All @@ -56,6 +53,8 @@ ion-picker {

justify-content: center;

margin-bottom: var(--ion-bottom-padding);

contain: strict;
overflow: hidden;
}
Expand Down
6 changes: 2 additions & 4 deletions core/src/components/tabbar/tabbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@
order: -1;
}

@supports (padding-top: env(safe-area-inset-top)) {
:host(.placement-bottom) {
@include padding(null, null, env(safe-area-inset-bottom));
}
:host(.placement-bottom) {
padding-bottom: var(--ion-bottom-padding);
}


Expand Down
12 changes: 2 additions & 10 deletions core/src/components/toast/animations/ios.enter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@ export function iosEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, po
const wrapperEle = baseEl.querySelector('.toast-wrapper') as HTMLElement;
wrapperAnimation.addElement(wrapperEle);

let variable;

if (CSS.supports('bottom', 'env(safe-area-inset-bottom)')) {
variable = 'env';
} else if (CSS.supports('bottom', 'constant(safe-area-inset-bottom)')) {
variable = 'constant';
}

const bottom = variable ? 'calc(-10px - ' + variable + '(safe-area-inset-bottom))' : '-10px';
const top = variable ? 'calc(' + variable + '(safe-area-inset-top) + 10px)' : '10px';
const bottom = `calc(-10px - var(--ion-bottom-padding, 0px))`;
const top = `calc(10px + var(--ion-statusbar-padding, 0px))`;

switch (position) {
case 'top':
Expand Down
12 changes: 2 additions & 10 deletions core/src/components/toast/animations/ios.leave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@ export function iosLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement, po
const wrapperEle = baseEl.querySelector('.toast-wrapper') as HTMLElement;
wrapperAnimation.addElement(wrapperEle);

let variable;

if (CSS.supports('bottom', 'env(safe-area-inset-bottom)')) {
variable = 'env';
} else if (CSS.supports('bottom', 'constant(safe-area-inset-bottom)')) {
variable = 'constant';
}

const bottom = variable ? 'calc(-10px - ' + variable + '(safe-area-inset-bottom))' : '-10px';
const top = variable ? 'calc(' + variable + '(safe-area-inset-top) + 10px)' : '10px';
const bottom = `calc(-10px - var(--ion-bottom-padding, 0px))`;
const top = `calc(10px + var(--ion-statusbar-padding, 0px))`;

switch (position) {
case 'top':
Expand Down
5 changes: 5 additions & 0 deletions core/src/components/toast/test/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
</script>

<style>
:root {
--ion-statusbar-padding: 20px;
--ion-bottom-padding: 40px;
}

f {
display: block;
background: blue;
Expand Down
12 changes: 0 additions & 12 deletions core/src/components/toast/toast.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@
backdrop-filter: $toast-ios-translucent-filter;
}

.toast-ios .toast-wrapper.toast-top {
@include transform(translate3d(0, -100%, 0));

top: 0;
}

.toast-ios .toast-wrapper.toast-bottom {
@include transform(translate3d(0, 100%, 0));

bottom: 0;
}

.toast-ios .toast-wrapper.toast-middle {
opacity: .01;
}
Expand Down
8 changes: 2 additions & 6 deletions core/src/components/toast/toast.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@
}

.toast-md .toast-wrapper.toast-top {
@include transform(translate3d(0, -100%, 0));

top: 0;
padding-top: var(--ion-statusbar-padding);
}

.toast-md .toast-wrapper.toast-bottom {
@include transform(translate3d(0, 100%, 0));

bottom: 0;
padding-bottom: var(--ion-bottom-padding);
}

.toast-md .toast-wrapper.toast-middle {
Expand Down
14 changes: 13 additions & 1 deletion core/src/components/toast/toast.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ion-toast {
* @prop --button-color: Color of the button text
* @prop --color: Color of the toast text
*/

@include position(0, null, null, 0);

display: block;
Expand All @@ -29,6 +28,19 @@ ion-toast {
background: var(--background);
}

.toast-wrapper.toast-top {
@include transform(translate3d(0, -100%, 0));

top: 0;
}

.toast-wrapper.toast-bottom {
@include transform(translate3d(0, 100%, 0));

bottom: 0;
}


.toast-container {
display: flex;

Expand Down

0 comments on commit 3da1bf4

Please sign in to comment.