-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [DIALOG] configuration token (#31)
- Loading branch information
Showing
7 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './lib/dialog/dialog.component'; | ||
export * from './lib/directives'; | ||
export * from './lib/dialog.module'; | ||
export * from './lib/core'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { NgxDialogConfig } from './dialog-config'; | ||
|
||
describe('DialogConfig', () => { | ||
it('should create an instance', () => { | ||
expect(new NgxDialogConfig()).toBeTruthy(); | ||
}); | ||
|
||
it('should be the same', () => { | ||
const config1 = new NgxDialogConfig(); | ||
const config2 = new NgxDialogConfig(config1); | ||
|
||
expect(config1).toEqual(config2); | ||
}); | ||
|
||
it('should rewrite fields', () => { | ||
const config = new NgxDialogConfig({ | ||
backdropClass: 'backdrop', | ||
contentClass: 'content', | ||
closeOnBackdropClick: false, | ||
animationDisabled: false | ||
}); | ||
|
||
expect(config.backdropClass).toBe('backdrop'); | ||
expect(config.contentClass).toBe('content'); | ||
expect(config.closeOnBackdropClick).toBe(false); | ||
expect(config.animationDisabled).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export interface DialogConfig { | ||
animationDisabled: boolean; | ||
contentClass: string; | ||
backdropClass: string; | ||
closeOnBackdropClick: boolean; | ||
} | ||
|
||
export class NgxDialogConfig implements DialogConfig { | ||
animationDisabled = false; | ||
contentClass = ''; | ||
backdropClass = ''; | ||
closeOnBackdropClick = true; | ||
|
||
constructor( | ||
config: Partial<DialogConfig> = {} | ||
) { | ||
Object.assign(this, config); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
import { NgxDialogConfig } from './dialog-config'; | ||
|
||
export const NGX_DIALOG_CONFIG = new InjectionToken('NGX_DIALOG_CONFIG', { | ||
providedIn: 'root', | ||
factory: () => new NgxDialogConfig() | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './dialog.injectors'; | ||
export * from './dialog-config'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters