Skip to content

Commit

Permalink
Merge pull request #68 from RiskChallenger/master
Browse files Browse the repository at this point in the history
build: fix the build script and add build test to ci
  • Loading branch information
NetanelBasal authored Jul 20, 2022
2 parents 9b4d845 + 3f1f280 commit a6536b9
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 67 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ jobs:
${{ runner.os }}-node-
- run: npm i
- run: npm run test:lib:headless
- run: npm run build:lib
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, ChangeDetectionStrategy, Inject } from '@angular/core';
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';

import { DialogContentSymbol, DialogContentData } from '../types';
import { DialogConfig } from '../config';
import { DialogRef } from '../dialog-ref';
import { DIALOG_CONFIG, DialogConfig } from '@ngneat/dialog';
import { DIALOG_CONFIG } from '../tokens';
import { DialogContentData, DialogContentSymbol } from '../types';

@Component({
selector: 'ngneat-dialog-base',
Expand Down
58 changes: 58 additions & 0 deletions projects/ngneat/dialog/src/lib/default-config.factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { inject } from '@angular/core';
import { ConfirmDialogComponent, ErrorDialogComponent, SuccessDialogComponent } from './built-in-dialogs';
import { DialogConfig } from './config';
import { DIALOG_DOCUMENT_REF } from './tokens';

export const defaultConfig = (): DialogConfig => {
return {
id: undefined,
container: inject(DIALOG_DOCUMENT_REF).body,
backdrop: true,
closeButton: true,
enableClose: true,
draggable: false,
dragConstraint: 'none',
resizable: false,
size: 'md',
windowClass: undefined,
width: undefined,
height: undefined,
minHeight: undefined,
maxHeight: undefined,
data: undefined,
vcr: undefined,
sizes: {
sm: {
minHeight: '200px',
width: '400px'
},
md: {
minHeight: '280px',
width: '560px'
},
lg: {
minHeight: '350px',
width: '800px'
},
fullScreen: {
height: '100%',
width: '100%'
}
},
success: {
component: SuccessDialogComponent,
confirmText: 'OK'
},
confirm: {
component: ConfirmDialogComponent,
confirmText: 'OK',
cancelText: 'Cancel'
},
error: {
component: ErrorDialogComponent,
confirmText: 'OK'
},
onClose: undefined,
onOpen: undefined
};
};
21 changes: 13 additions & 8 deletions projects/ngneat/dialog/src/lib/dialog.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { ModuleWithProviders, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ModuleWithProviders, NgModule } from '@angular/core';

import { DialogComponent } from './dialog.component';
import { DialogCloseDirective } from './dialog-close.directive';
import { GlobalDialogConfig } from './config';
import { GLOBAL_DIALOG_CONFIG } from './tokens';
import { DialogDraggableDirective } from './draggable.directive';
import {
BaseDialogComponent,
ConfirmDialogComponent,
SuccessDialogComponent,
ErrorDialogComponent
ErrorDialogComponent,
SuccessDialogComponent
} from './built-in-dialogs';
import { GlobalDialogConfig } from './config';
import { defaultConfig } from './default-config.factory';
import { DialogCloseDirective } from './dialog-close.directive';
import { DialogComponent } from './dialog.component';
import { DialogDraggableDirective } from './draggable.directive';
import { DIALOG_CONFIG, GLOBAL_DIALOG_CONFIG } from './tokens';

const BuiltIns = [BaseDialogComponent, SuccessDialogComponent, ConfirmDialogComponent, ErrorDialogComponent];

Expand All @@ -29,6 +30,10 @@ export class DialogModule {
{
provide: GLOBAL_DIALOG_CONFIG,
useValue: config
},
{
provide: DIALOG_CONFIG,
useFactory: defaultConfig
}
]
};
Expand Down
5 changes: 5 additions & 0 deletions projects/ngneat/dialog/src/lib/dialog.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createServiceFactory, SpectatorService } from '@ngneat/spectator';
import { timer } from 'rxjs';
import { mapTo } from 'rxjs/operators';
import { DialogConfig } from './config';
import { defaultConfig } from './default-config.factory';
import { DialogRef, InternalDialogRef } from './dialog-ref';
import { DialogComponent } from './dialog.component';
import { DialogService } from './dialog.service';
Expand Down Expand Up @@ -78,6 +79,10 @@ describe('DialogService', () => {
}
}
},
{
provide: DIALOG_CONFIG,
useFactory: defaultConfig
},
{
provide: ComponentFactoryResolver,
useClass: FakeFactoryResolver
Expand Down
58 changes: 2 additions & 56 deletions projects/ngneat/dialog/src/lib/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { InjectionToken, ViewRef, inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { inject, InjectionToken, ViewRef } from '@angular/core';

import { DialogConfig, GlobalDialogConfig } from './config';
import { SuccessDialogComponent, ConfirmDialogComponent, ErrorDialogComponent } from './built-in-dialogs';

export const DIALOG_DOCUMENT_REF = new InjectionToken(
'A reference to the document. Useful for iframes that want appends to parent window',
Expand All @@ -16,58 +15,5 @@ export const DIALOG_DOCUMENT_REF = new InjectionToken(

export const GLOBAL_DIALOG_CONFIG = new InjectionToken<Partial<GlobalDialogConfig>>('Global dialog config token');

export const DIALOG_CONFIG = new InjectionToken<DialogConfig>('Dialog config token', {
providedIn: 'root',
factory: () => ({
id: undefined,
container: inject(DIALOG_DOCUMENT_REF).body,
backdrop: true,
closeButton: true,
enableClose: true,
draggable: false,
dragConstraint: 'none',
resizable: false,
size: 'md',
windowClass: undefined,
width: undefined,
height: undefined,
minHeight: undefined,
maxHeight: undefined,
data: undefined,
vcr: undefined,
sizes: {
sm: {
minHeight: '200px',
width: '400px'
},
md: {
minHeight: '280px',
width: '560px'
},
lg: {
minHeight: '350px',
width: '800px'
},
fullScreen: {
height: '100%',
width: '100%'
}
},
success: {
component: SuccessDialogComponent,
confirmText: 'OK'
},
confirm: {
component: ConfirmDialogComponent,
confirmText: 'OK',
cancelText: 'Cancel'
},
error: {
component: ErrorDialogComponent,
confirmText: 'OK'
},
onClose: undefined,
onOpen: undefined
})
});
export const DIALOG_CONFIG = new InjectionToken<DialogConfig>('Dialog config token');
export const NODES_TO_INSERT = new InjectionToken<ViewRef>('Nodes inserted into the dialog');

0 comments on commit a6536b9

Please sign in to comment.