Skip to content

Commit

Permalink
feat(modal): allow any string as modal size option
Browse files Browse the repository at this point in the history
Size type now incudes 'string' and changes to `size?: 'sm' | 'lg' | 'xl' | string;`

Fixes #3013
  • Loading branch information
maxokorokov committed Jan 13, 2020
1 parent b97bd9f commit 24ea370
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion demo/src/app/components/modal/demos/options/modal-options.ts
Expand Up @@ -39,7 +39,9 @@ export class NgbdModalOptions {
this.modalService.open(content, { size: 'lg' });
}

openXl(content) { this.modalService.open(content, {size: 'xl'}); }
openXl(content) {
this.modalService.open(content, { size: 'xl' });
}

openVerticallyCentered(content) {
this.modalService.open(content, { centered: true });
Expand Down
4 changes: 2 additions & 2 deletions src/modal/modal-config.ts
Expand Up @@ -70,7 +70,7 @@ export interface NgbModalOptions {
/**
* Size of a new modal window.
*/
size?: 'sm' | 'lg' | 'xl';
size?: 'sm' | 'lg' | 'xl' | string;

/**
* A custom class to append to the modal window.
Expand Down Expand Up @@ -103,7 +103,7 @@ export class NgbModalConfig implements Required<NgbModalOptions> {
injector: Injector;
keyboard = true;
scrollable: boolean;
size: 'sm' | 'lg' | 'xl';
size: 'sm' | 'lg' | 'xl' | string;
windowClass: string;
backdropClass: string;
}
11 changes: 11 additions & 0 deletions src/modal/modal.spec.ts
Expand Up @@ -482,6 +482,17 @@ describe('ngb-modal', () => {
expect(fixture.nativeElement).not.toHaveModal();
});

it('should accept any strings as modal size', () => {
const modalInstance = fixture.componentInstance.open('foo', {size: 'ginormous'});
fixture.detectChanges();
expect(fixture.nativeElement).toHaveModal('foo');
expect(document.querySelector('.modal-dialog')).toHaveCssClass('modal-ginormous');

modalInstance.close();
fixture.detectChanges();
expect(fixture.nativeElement).not.toHaveModal();
});

});

describe('window custom class options', () => {
Expand Down

0 comments on commit 24ea370

Please sign in to comment.