Skip to content

Commit

Permalink
Merge pull request #121 from vicky-polatov/feature/overflow-functiona…
Browse files Browse the repository at this point in the history
…lity

feat: overflow functionality
  • Loading branch information
NetanelBasal authored Apr 30, 2024
2 parents b93df6c + db8731b commit f8da4bf
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 3 deletions.
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;
width: string | number;
minWidth: string | number;
maxWidth: string | number;
Expand Down

0 comments on commit f8da4bf

Please sign in to comment.