Skip to content
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: overflow functionality #121

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ bootstrapApplication(AppComponent, {
backdrop: boolean,
resizable: boolean,
draggable: boolean,
overflow: boolean,
draggableConstraint: none | bounce | constrain,
sizes,
size: sm | md | lg | fullScreen | string,
Expand Down
4 changes: 4 additions & 0 deletions apps/playground/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ <h2>Configure your dialog</h2>
<label>Close Button</label>
<input type="checkbox" formControlName="closeButton" />
</div>
<div>
<label>Overflow ❌</label>
<input type="checkbox" formControlName="overflow" />
</div>
<ng-container formGroupName="enableClose">
<div>
<label>Escape to Close ❌</label>
Expand Down
2 changes: 1 addition & 1 deletion apps/playground/src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ button {
}

form {
max-height: 260px;
max-height: 300px;
display: flex;
flex-direction: column;
flex-wrap: wrap;
Expand Down
4 changes: 4 additions & 0 deletions apps/playground/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class AppComponent {
backdrop: [true],
resizable: [false],
draggable: [false],
overflow: [true],
dragConstraint: ['none'],
size: [''],
windowClass: [''],
Expand Down Expand Up @@ -76,6 +77,9 @@ export class AppComponent {
this.backDropClicked = false;
this.cleanConfig = this.normalizeConfig(config);

if (this.cleanConfig.overflow) document.body.style.setProperty('--dialog-overflow', 'visible');
else document.body.style.setProperty('--dialog-overflow', 'hidden');

const ref = this.dialog.open(compOrTemplate as any, this.cleanConfig);

ref?.backdropClick$.subscribe({
Expand Down
6 changes: 4 additions & 2 deletions libs/dialog/src/lib/dialog.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
flex-direction: column;
overflow: hidden;
position: relative;

@keyframes dialog-open {
0% {
transform: translateX(50px);
}

100% {
transform: none;
}
Expand Down Expand Up @@ -97,6 +99,6 @@
}
}

body.ngneat-dialog-hidden {
overflow: hidden;
body {
overflow: var(--dialog-overflow, hidden);
}
4 changes: 4 additions & 0 deletions libs/dialog/src/lib/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export class DialogComponent implements OnInit, OnDestroy {
}
}

if (this.config.overflow) {
document.body.style.setProperty('--dialog-overflow', 'visible');
}

this.host.id = this.config.id;
}

Expand Down
1 change: 1 addition & 0 deletions libs/dialog/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface GlobalDialogConfig {
backdrop: CloseStrategy;
};
resizable: boolean;
overflow: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we need this property?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the config to allow the user to choose whether they want overflow on the body when the dialog is open or not.

width: string | number;
minWidth: string | number;
maxWidth: string | number;
Expand Down
Loading