Skip to content
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ You can customize the following parameters:
- The **extra duration** (ie. how many extra milliseconds should the spinner be visible).
- The **minimum duration** (ie. how many milliseconds should the spinner be visible at least).
- The spinner **opacity**.
- The backdrop **background-color** (ie. the color of the spinner backdrop, if enabled).
- The **spinner type**.

```xml
Expand All @@ -101,6 +102,7 @@ You can customize the following parameters:
[extraDuration]="300"
[minDuration]="300"
[opacity]=".6"
[backdropBackgroundColor]="#777777"
[spinner]="spinkit.skWave">
</ng-http-loader>
```
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ $spinkit-top: 50% !default;
$spinkit-position: relative !default;

$spinner-color: #333 !default;
$backdrop-background-color: #f1f1f1 !default;
3 changes: 2 additions & 1 deletion src/lib/components/ng-http-loader.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<div id="spinner"
*ngIf="isVisible$ | async"
[class.backdrop]="backdrop"
[style.opacity]="opacity">
[style.opacity]="opacity"
[ngStyle]="{'background-color': backdrop ? backdropBackgroundColor : 'transparent'}">

<ng-container *ngComponentOutlet="entryComponent"></ng-container>

Expand Down
1 change: 0 additions & 1 deletion src/lib/components/ng-http-loader.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
left: 0;
height: 100%;
width: 100%;
background-color: $backdrop-background-color;
display: flex;
align-items: center;
justify-content: center;
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/ng-http-loader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class NgHttpLoaderComponent implements OnInit {
@Input() public filteredUrlPatterns: string[] = [];
@Input() public minDuration = 0;
@Input() public opacity = '.7';
@Input() public backdropBackgroundColor = '#f1f1f1';
@Input() public spinner: string | null = Spinkit.skWave;

constructor(private pendingRequestsInterceptor: PendingRequestsInterceptor, private spinnerVisibility: SpinnerVisibilityService) {
Expand Down
38 changes: 38 additions & 0 deletions src/test/components/ng-http-loader.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,4 +798,42 @@ describe('NgHttpLoaderComponent', () => {

expect(element.style.opacity).toBe(`0${component.opacity}`);
});

it('should have a default backdrop background color if backdrop is true', () => {
component.isVisible$ = of(true);
fixture.detectChanges();

const element: HTMLElement = fixture
.debugElement
.query(By.css('#spinner'))
.nativeElement;

expect(element.style.backgroundColor).toBe('rgb(241, 241, 241)');
});

it('should be possible to override backdrop background color when backdrop is true', () => {
component.isVisible$ = of(true);
component.backdropBackgroundColor = '#777777';
fixture.detectChanges();

const element: HTMLElement = fixture
.debugElement
.query(By.css('#spinner'))
.nativeElement;

expect(element.style.backgroundColor).toBe('rgb(119, 119, 119)');
});

it('should not have a transparent backdrop background color if backdrop is false', () => {
component.isVisible$ = of(true);
component.backdrop = false;
fixture.detectChanges();

const element: HTMLElement = fixture
.debugElement
.query(By.css('#spinner'))
.nativeElement;

expect(element.style.backgroundColor).toBe('transparent');
});
});