From bd22926c4995b2d953a08aac7125241929f78f9e Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Tue, 8 Oct 2019 16:42:37 -0400 Subject: [PATCH] feat(overlays): add global backdrop opacity variable for animations (#19533) adds `--backdrop-opacity` to all overlays and `--ion-backdrop-opacity` for global control closes #16446 --- core/api.txt | 6 ++++ .../action-sheet/action-sheet.ios.scss | 1 + .../action-sheet/action-sheet.md.scss | 1 + .../components/action-sheet/action-sheet.scss | 2 ++ .../action-sheet/animations/ios.enter.ts | 2 +- .../action-sheet/animations/ios.leave.ts | 2 +- .../action-sheet/animations/md.enter.ts | 2 +- .../action-sheet/animations/md.leave.ts | 2 +- core/src/components/action-sheet/readme.md | 1 + .../components/action-sheet/test/basic/e2e.ts | 8 +++++ .../action-sheet/test/basic/index.html | 11 +++++-- core/src/components/alert/alert.ios.scss | 1 + core/src/components/alert/alert.md.scss | 1 + core/src/components/alert/alert.scss | 2 ++ .../components/alert/animations/ios.enter.ts | 2 +- .../components/alert/animations/ios.leave.ts | 2 +- .../components/alert/animations/md.enter.ts | 2 +- .../components/alert/animations/md.leave.ts | 2 +- core/src/components/alert/readme.md | 19 ++++++------ .../loading/animations/ios.enter.ts | 2 +- .../loading/animations/ios.leave.ts | 2 +- .../components/loading/animations/md.enter.ts | 2 +- .../components/loading/animations/md.leave.ts | 2 +- core/src/components/loading/loading.ios.scss | 1 + core/src/components/loading/loading.md.scss | 1 + core/src/components/loading/loading.scss | 2 ++ core/src/components/loading/readme.md | 21 +++++++------- .../components/modal/animations/ios.enter.ts | 2 +- .../components/modal/animations/ios.leave.ts | 2 +- .../components/modal/animations/md.enter.ts | 2 +- .../components/modal/animations/md.leave.ts | 2 +- core/src/components/modal/modal.ios.scss | 4 +++ core/src/components/modal/modal.md.scss | 4 +++ core/src/components/modal/modal.scss | 1 + core/src/components/modal/readme.md | 27 ++++++++--------- .../components/picker/animations/ios.enter.ts | 2 +- .../components/picker/animations/ios.leave.ts | 2 +- core/src/components/picker/picker.ios.scss | 1 + core/src/components/picker/picker.md.scss | 1 + core/src/components/picker/picker.scss | 2 ++ core/src/components/picker/readme.md | 29 ++++++++++--------- .../popover/animations/ios.enter.ts | 2 +- .../popover/animations/ios.leave.ts | 2 +- .../components/popover/animations/md.enter.ts | 2 +- .../components/popover/animations/md.leave.ts | 2 +- core/src/components/popover/popover.ios.scss | 1 + core/src/components/popover/popover.md.scss | 1 + core/src/components/popover/popover.scss | 2 ++ core/src/components/popover/readme.md | 21 +++++++------- 49 files changed, 136 insertions(+), 80 deletions(-) diff --git a/core/api.txt b/core/api.txt index ca1eb1ea89..dcb44b77d5 100644 --- a/core/api.txt +++ b/core/api.txt @@ -19,6 +19,7 @@ ion-action-sheet,event,ionActionSheetDidDismiss,OverlayEventDetail,true ion-action-sheet,event,ionActionSheetDidPresent,void,true ion-action-sheet,event,ionActionSheetWillDismiss,OverlayEventDetail,true ion-action-sheet,event,ionActionSheetWillPresent,void,true +ion-action-sheet,css-prop,--backdrop-opacity ion-action-sheet,css-prop,--background ion-action-sheet,css-prop,--background-activated ion-action-sheet,css-prop,--background-selected @@ -57,6 +58,7 @@ ion-alert,event,ionAlertDidDismiss,OverlayEventDetail,true ion-alert,event,ionAlertDidPresent,void,true ion-alert,event,ionAlertWillDismiss,OverlayEventDetail,true ion-alert,event,ionAlertWillPresent,void,true +ion-alert,css-prop,--backdrop-opacity ion-alert,css-prop,--background ion-alert,css-prop,--height ion-alert,css-prop,--max-height @@ -589,6 +591,7 @@ ion-loading,event,ionLoadingDidDismiss,OverlayEventDetail,true ion-loading,event,ionLoadingDidPresent,void,true ion-loading,event,ionLoadingWillDismiss,OverlayEventDetail,true ion-loading,event,ionLoadingWillPresent,void,true +ion-loading,css-prop,--backdrop-opacity ion-loading,css-prop,--background ion-loading,css-prop,--height ion-loading,css-prop,--max-height @@ -684,6 +687,7 @@ ion-modal,event,ionModalDidDismiss,OverlayEventDetail,true ion-modal,event,ionModalDidPresent,void,true ion-modal,event,ionModalWillDismiss,OverlayEventDetail,true ion-modal,event,ionModalWillPresent,void,true +ion-modal,css-prop,--backdrop-opacity ion-modal,css-prop,--background ion-modal,css-prop,--border-color ion-modal,css-prop,--border-radius @@ -754,6 +758,7 @@ ion-picker,event,ionPickerDidDismiss,OverlayEventDetail,true ion-picker,event,ionPickerDidPresent,void,true ion-picker,event,ionPickerWillDismiss,OverlayEventDetail,true ion-picker,event,ionPickerWillPresent,void,true +ion-picker,css-prop,--backdrop-opacity ion-picker,css-prop,--background ion-picker,css-prop,--background-rgb ion-picker,css-prop,--border-color @@ -793,6 +798,7 @@ ion-popover,event,ionPopoverDidDismiss,OverlayEventDetail,true ion-popover,event,ionPopoverDidPresent,void,true ion-popover,event,ionPopoverWillDismiss,OverlayEventDetail,true ion-popover,event,ionPopoverWillPresent,void,true +ion-popover,css-prop,--backdrop-opacity ion-popover,css-prop,--background ion-popover,css-prop,--box-shadow ion-popover,css-prop,--height diff --git a/core/src/components/action-sheet/action-sheet.ios.scss b/core/src/components/action-sheet/action-sheet.ios.scss index 69f77b5340..afe9f36cf2 100644 --- a/core/src/components/action-sheet/action-sheet.ios.scss +++ b/core/src/components/action-sheet/action-sheet.ios.scss @@ -8,6 +8,7 @@ --background: #{$action-sheet-ios-background-color}; --background-selected: #{$action-sheet-ios-button-background-selected}; --background-activated: #{$action-sheet-ios-button-background-activated}; + --backdrop-opacity: var(--ion-backdrop-opacity, 0.4); text-align: $action-sheet-ios-text-align; } diff --git a/core/src/components/action-sheet/action-sheet.md.scss b/core/src/components/action-sheet/action-sheet.md.scss index 79d577d9b5..f080453ea9 100644 --- a/core/src/components/action-sheet/action-sheet.md.scss +++ b/core/src/components/action-sheet/action-sheet.md.scss @@ -8,6 +8,7 @@ --background: #{$action-sheet-md-background-color}; --background-selected: #{var(--background, $action-sheet-md-button-background-selected)}; --background-activated: var(--background); + --backdrop-opacity: var(--ion-backdrop-opacity, 0.32); } .action-sheet-title { diff --git a/core/src/components/action-sheet/action-sheet.scss b/core/src/components/action-sheet/action-sheet.scss index b7230b5adb..f93646cea3 100644 --- a/core/src/components/action-sheet/action-sheet.scss +++ b/core/src/components/action-sheet/action-sheet.scss @@ -18,6 +18,8 @@ * @prop --min-height: Minimum height of the action sheet * @prop --height: height of the action sheet * @prop --max-height: Maximum height of the action sheet + * + * @prop --backdrop-opacity: Opacity of the backdrop */ --color: initial; --min-width: auto; diff --git a/core/src/components/action-sheet/animations/ios.enter.ts b/core/src/components/action-sheet/animations/ios.enter.ts index 40fd7abda8..9e4363869d 100644 --- a/core/src/components/action-sheet/animations/ios.enter.ts +++ b/core/src/components/action-sheet/animations/ios.enter.ts @@ -11,7 +11,7 @@ export const iosEnterAnimation = (baseEl: HTMLElement): IonicAnimation => { backdropAnimation .addElement(baseEl.querySelector('ion-backdrop')!) - .fromTo('opacity', 0.01, 0.4); + .fromTo('opacity', 0.01, 'var(--backdrop-opacity)'); wrapperAnimation .addElement(baseEl.querySelector('.action-sheet-wrapper')!) diff --git a/core/src/components/action-sheet/animations/ios.leave.ts b/core/src/components/action-sheet/animations/ios.leave.ts index 52e4ff4523..414ebfebfc 100644 --- a/core/src/components/action-sheet/animations/ios.leave.ts +++ b/core/src/components/action-sheet/animations/ios.leave.ts @@ -11,7 +11,7 @@ export const iosLeaveAnimation = (baseEl: HTMLElement): IonicAnimation => { backdropAnimation .addElement(baseEl.querySelector('ion-backdrop')!) - .fromTo('opacity', 0.4, 0); + .fromTo('opacity', 'var(--backdrop-opacity)', 0); wrapperAnimation .addElement(baseEl.querySelector('.action-sheet-wrapper')!) diff --git a/core/src/components/action-sheet/animations/md.enter.ts b/core/src/components/action-sheet/animations/md.enter.ts index 3ad476c8aa..97288a10d3 100644 --- a/core/src/components/action-sheet/animations/md.enter.ts +++ b/core/src/components/action-sheet/animations/md.enter.ts @@ -11,7 +11,7 @@ export const mdEnterAnimation = (baseEl: HTMLElement): IonicAnimation => { backdropAnimation .addElement(baseEl.querySelector('ion-backdrop')!) - .fromTo('opacity', 0.01, 0.32); + .fromTo('opacity', 0.01, 'var(--backdrop-opacity)'); wrapperAnimation .addElement(baseEl.querySelector('.action-sheet-wrapper')!) diff --git a/core/src/components/action-sheet/animations/md.leave.ts b/core/src/components/action-sheet/animations/md.leave.ts index 468b79f501..b3251b74f6 100644 --- a/core/src/components/action-sheet/animations/md.leave.ts +++ b/core/src/components/action-sheet/animations/md.leave.ts @@ -11,7 +11,7 @@ export const mdLeaveAnimation = (baseEl: HTMLElement): IonicAnimation => { backdropAnimation .addElement(baseEl.querySelector('ion-backdrop')!) - .fromTo('opacity', 0.32, 0); + .fromTo('opacity', 'var(--backdrop-opacity)', 0); wrapperAnimation .addElement(baseEl.querySelector('.action-sheet-wrapper')!) diff --git a/core/src/components/action-sheet/readme.md b/core/src/components/action-sheet/readme.md index 708b67cc30..f916b63d01 100644 --- a/core/src/components/action-sheet/readme.md +++ b/core/src/components/action-sheet/readme.md @@ -321,6 +321,7 @@ Type: `Promise` | Name | Description | | ------------------------ | -------------------------------------------------- | +| `--backdrop-opacity` | Opacity of the backdrop | | `--background` | Background of the action sheet group | | `--background-activated` | Background of the action sheet button when pressed | | `--background-selected` | Background of the selected action sheet button | diff --git a/core/src/components/action-sheet/test/basic/e2e.ts b/core/src/components/action-sheet/test/basic/e2e.ts index 685541bbc1..d96982cd3f 100644 --- a/core/src/components/action-sheet/test/basic/e2e.ts +++ b/core/src/components/action-sheet/test/basic/e2e.ts @@ -34,6 +34,10 @@ test('action-sheet: basic, scroll without cancel', async () => { await testActionSheet(DIRECTORY, '#scrollWithoutCancel'); }); +test('action-sheet: basic, custom backdrop', async () => { + await testActionSheet(DIRECTORY, '#customBackdrop'); +}); + /** * RTL Tests */ @@ -69,3 +73,7 @@ test('action-sheet:rtl: basic, scrollable options', async () => { test('action-sheet:rtl: basic, scroll without cancel', async () => { await testActionSheet(DIRECTORY, '#scrollWithoutCancel', true); }); + +test('action-sheet:rtl: basic, custom backdrop', async () => { + await testActionSheet(DIRECTORY, '#customBackdrop', true); +}); diff --git a/core/src/components/action-sheet/test/basic/index.html b/core/src/components/action-sheet/test/basic/index.html index 52bd855f5c..73199c8e28 100644 --- a/core/src/components/action-sheet/test/basic/index.html +++ b/core/src/components/action-sheet/test/basic/index.html @@ -28,6 +28,7 @@ No Backdrop Dismiss Scrollable Options Scroll Without Cancel + Custom Backdrop Opacity @@ -49,6 +50,10 @@ --height: 325px; } + .custom-backdrop { + --ion-backdrop-opacity: 1; + } +