MOBILE-3807 usermenu: Make lateal modal wider

main
Pau Ferrer Ocaña 2021-10-22 12:57:59 +02:00
parent ab10d42b75
commit 357d23c082
5 changed files with 71 additions and 21 deletions

View File

@ -22,37 +22,61 @@ import { Platform } from '@singletons';
export function CoreModalLateralTransitionEnter(baseEl: HTMLElement): Animation { export function CoreModalLateralTransitionEnter(baseEl: HTMLElement): Animation {
const OFF_RIGHT = Platform.isRTL ? '-100%' : '100%'; const OFF_RIGHT = Platform.isRTL ? '-100%' : '100%';
const backdropAnimation = createAnimation() const otherAnimations: Animation[] = [];
.addElement(baseEl.querySelector('ion-backdrop')!)
.fromTo('opacity', 0.01, 0.4);
const wrapperAnimation = createAnimation() const backdrop = baseEl.querySelector('ion-backdrop');
.addElement(baseEl.querySelector('.modal-wrapper')!) if (backdrop) {
.fromTo('transform', 'translateX(' + OFF_RIGHT + ')', 'translateX(0)') const backdropAnimation = createAnimation()
.fromTo('opacity', 0.8, 1); .addElement(backdrop)
.fromTo('opacity', 0.01, 0.4);
otherAnimations.push(backdropAnimation);
}
const wrapper = baseEl.querySelector('.modal-wrapper');
if (wrapper) {
const wrapperAnimation = createAnimation()
.addElement(wrapper)
.fromTo('transform', 'translateX(' + OFF_RIGHT + ')', 'translateX(0)')
.fromTo('opacity', 0.8, 1);
otherAnimations.push(wrapperAnimation);
}
return createAnimation() return createAnimation()
.addElement(baseEl) .addElement(baseEl)
.easing('cubic-bezier(0.36,0.66,0.04,1)') .easing('cubic-bezier(0.36,0.66,0.04,1)')
.duration(300) .duration(300)
.addAnimation([backdropAnimation, wrapperAnimation]); .addAnimation(otherAnimations);
} }
export function CoreModalLateralTransitionLeave(baseEl: HTMLElement): Animation { export function CoreModalLateralTransitionLeave(baseEl: HTMLElement): Animation {
const OFF_RIGHT = Platform.isRTL ? '-100%' : '100%'; const OFF_RIGHT = Platform.isRTL ? '-100%' : '100%';
const backdropAnimation = createAnimation() const otherAnimations: Animation[] = [];
.addElement(baseEl.querySelector('ion-backdrop')!)
.fromTo('opacity', 0.4, 0.0);
const wrapperAnimation = createAnimation() const backdrop = baseEl.querySelector('ion-backdrop');
.addElement(baseEl.querySelector('.modal-wrapper')!) if (backdrop) {
.beforeStyles({ opacity: 1 }) const backdropAnimation = createAnimation()
.fromTo('transform', 'translateX(0)', 'translateX(' + OFF_RIGHT + ')'); .addElement(backdrop)
.fromTo('opacity', 0.4, 0.0);
otherAnimations.push(backdropAnimation);
}
const wrapper = baseEl.querySelector('.modal-wrapper');
if (wrapper) {
const wrapperAnimation = createAnimation()
.addElement(wrapper)
.beforeStyles({ opacity: 1 })
.fromTo('transform', 'translateX(0)', 'translateX(' + OFF_RIGHT + ')');
otherAnimations.push(wrapperAnimation);
}
return createAnimation() return createAnimation()
.addElement(baseEl) .addElement(baseEl)
.easing('cubic-bezier(0.36,0.66,0.04,1)') .easing('cubic-bezier(0.36,0.66,0.04,1)')
.duration(300) .duration(300)
.addAnimation([backdropAnimation, wrapperAnimation]); .addAnimation(otherAnimations);
} }

View File

@ -47,8 +47,9 @@ export class CoreMainMenuUserButtonComponent {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
CoreDomUtils.openModal<void>({ CoreDomUtils.openSideModal<void>({
component: CoreMainMenuUserMenuComponent, component: CoreMainMenuUserMenuComponent,
cssClass: 'core-modal-lateral-sm',
}); });
} }

View File

@ -1677,13 +1677,13 @@ export class CoreDomUtilsProvider {
modalOptions: ModalOptions, modalOptions: ModalOptions,
): Promise<T | undefined> { ): Promise<T | undefined> {
modalOptions = Object.assign(modalOptions, { modalOptions = Object.assign({
cssClass: 'core-modal-lateral', cssClass: 'core-modal-lateral',
showBackdrop: true, showBackdrop: true,
backdropDismiss: true, backdropDismiss: true,
enterAnimation: CoreModalLateralTransitionEnter, enterAnimation: CoreModalLateralTransitionEnter,
leaveAnimation: CoreModalLateralTransitionLeave, leaveAnimation: CoreModalLateralTransitionLeave,
}); }, modalOptions);
return await this.openModal<T>(modalOptions); return await this.openModal<T>(modalOptions);
} }

View File

@ -102,6 +102,8 @@ $screen-breakpoints: (
xl: 1200px xl: 1200px
) !default; ) !default;
$modal-lateral-width: 360px;
$core-course-image-background: #81ecec, #74b9ff, #a29bfe, #dfe6e9, #00b894, #0984e3, #b2bec3, #fdcb6e, #fd79a8, #6c5ce7 !default; $core-course-image-background: #81ecec, #74b9ff, #a29bfe, #dfe6e9, #00b894, #0984e3, #b2bec3, #fdcb6e, #fd79a8, #6c5ce7 !default;
$core-dd-question-colors: #FFFFFF, #B0C4DE, #DCDCDC, #D8BFD8, #87CEFA, #DAA520, #FFD700, #F0E68C !default; $core-dd-question-colors: #FFFFFF, #B0C4DE, #DCDCDC, #D8BFD8, #87CEFA, #DAA520, #FFD700, #F0E68C !default;
$core-text-hightlight-background-color: lighten($blue, 40%) !default; $core-text-hightlight-background-color: lighten($blue, 40%) !default;

View File

@ -508,7 +508,7 @@ body.core-iframe-fullscreen ion-router-outlet {
z-index: 100000 !important; z-index: 100000 !important;
} }
@media only screen and (min-height: 400px) and (min-width: 300px) { @media only screen and (min-height: 400px) and (min-width: #{$modal-lateral-width}) {
.core-modal-lateral { .core-modal-lateral {
--ion-safe-area-left: 0px; --ion-safe-area-left: 0px;
--ion-safe-area-right: 0px; --ion-safe-area-right: 0px;
@ -519,7 +519,7 @@ body.core-iframe-fullscreen ion-router-outlet {
display: block; display: block;
height: 100% !important; height: 100% !important;
width: auto; width: auto;
min-width: 300px; min-width: #{$modal-lateral-width};
box-shadow: 0 28px 48px rgba(0, 0, 0, 0.4); box-shadow: 0 28px 48px rgba(0, 0, 0, 0.4);
} }
ion-backdrop { ion-backdrop {
@ -528,6 +528,29 @@ body.core-iframe-fullscreen ion-router-outlet {
} }
} }
@each $breakpoint, $width in $screen-breakpoints {
@media only screen and (min-height: 400px) and (min-width: #{$width}) {
.core-modal-lateral-#{$breakpoint} {
--ion-safe-area-left: 0px;
--ion-safe-area-right: 0px;
.modal-wrapper {
position: absolute;
@include position(0 !important, 0 !important, 0 !important, unset !important);
display: block;
height: 100% !important;
width: auto;
min-width: #{$width};
box-shadow: 0 28px 48px rgba(0, 0, 0, 0.4);
}
ion-backdrop {
visibility: visible;
}
}
}
}
// Hidden submit button. // Hidden submit button.
.core-submit-hidden-enter { .core-submit-hidden-enter {
position: absolute; position: absolute;