Skip to content

Commit

Permalink
Merge pull request #15294 from opf/bug/54307-show-dialogs-in-the-cent…
Browse files Browse the repository at this point in the history
…er-of-the-screen-on-mobile

[54307] Show dialogs in the center of the screen on mobile
  • Loading branch information
HDinger committed Apr 17, 2024
2 parents d15b7f9 + 1707df6 commit d4d14a4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class WorkPackageShareButtonComponent extends UntilDestroyedMixin impleme
}

openModal():void {
this.opModalService.show(WorkPackageShareModalComponent, 'global', { workPackage: this.workPackage });
this.opModalService.show(WorkPackageShareModalComponent, 'global', { workPackage: this.workPackage }, false, true);
}

private countShares():Observable<number> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ export class ShareCellbuilder {
}

private showShareModal(workPackage:WorkPackageResource) {
this.opModalService.show(WorkPackageShareModalComponent, 'global', { workPackage });
this.opModalService.show(WorkPackageShareModalComponent, 'global', { workPackage }, false, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
class="spot-modal-overlay"
[class.spot-modal-overlay_active]="(activeModalInstance$ | async) !== null"
[class.spot-modal-overlay_not-full-screen]="notFullscreen"
[class.spot-modal-overlay_top]="mobileTopPosition"
#overlay
tabindex="0"
cdkFocusInitial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export const opModalOverlaySelector = 'op-modal-overlay';
export class OpModalOverlayComponent {
public notFullscreen = false;

mobileTopPosition = false;

public portalOutlet:CdkPortalOutlet;

@ViewChild(CdkPortalOutlet) set portalOutletContainer(v:CdkPortalOutlet) {
Expand Down Expand Up @@ -124,8 +126,9 @@ export class OpModalOverlayComponent {
}

private createAndAttachPortalInstance(data:ModalData):void {
const { modal, injector, notFullscreen } = data;
const { modal, injector, notFullscreen, mobileTopPosition } = data;
this.notFullscreen = notFullscreen;
this.mobileTopPosition = mobileTopPosition;
const portal = new ComponentPortal(modal, null, injector);
const ref = this.portalOutlet.attach(portal);
const instance = ref.instance;
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/app/shared/components/modal/modal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface ModalData {
modal:ComponentType<OpModalComponent>;
injector:Injector;
notFullscreen:boolean;
mobileTopPosition:boolean;
}

@Injectable({ providedIn: 'root' })
Expand Down Expand Up @@ -72,12 +73,14 @@ export class OpModalService {
* Can be passed 'global' to take the default (global!) injector of this service.
* @param locals A map to be injected via token into the component.
* @param notFullscreen
* @param mobileTopPosition
*/
public show<T extends OpModalComponent>(
modal:ComponentType<T>,
injector:Injector|'global',
locals:Record<string, unknown> = {},
notFullscreen = false,
mobileTopPosition = false,
):Observable<T> {
this.close();

Expand All @@ -90,6 +93,7 @@ export class OpModalService {
modal,
injector: this.injectorFor(injector, locals),
notFullscreen,
mobileTopPosition,
});

return this.activeModalInstance$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
flex-direction: column-reverse

@media (max-width: 680px)
justify-content: flex-end
justify-content: center

@media (max-height: 480px)
// reorder elements to be displayed in row on very small heights
flex-direction: row-reverse

&_top
@media (max-width: 680px)
justify-content: flex-end
padding-top: 10px

&_not-full-screen
background: transparent
right: unset
Expand Down

0 comments on commit d4d14a4

Please sign in to comment.