Skip to content

Commit 8116ed5

Browse files
krishnakumarpmpalourdio
authored andcommitted
Added ability to set the background-color of the spinner backdrop.
1 parent 707fc07 commit 8116ed5

File tree

6 files changed

+30
-3
lines changed

6 files changed

+30
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ You can customize the following parameters:
9191
- The **extra duration** (ie. how many extra milliseconds should the spinner be visible).
9292
- The **minimum duration** (ie. how many milliseconds should the spinner be visible at least).
9393
- The spinner **opacity**.
94+
- The spinner **background-color** (ie. the color of the spinner backdrop).
9495
- The **spinner type**.
9596

9697
```xml
@@ -101,6 +102,7 @@ You can customize the following parameters:
101102
[extraDuration]="300"
102103
[minDuration]="300"
103104
[opacity]=".6"
105+
[backdropBackgroundColor]="#777777"
104106
[spinner]="spinkit.skWave">
105107
</ng-http-loader>
106108
```

src/lib/components/_variables.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ $spinkit-top: 50% !default;
44
$spinkit-position: relative !default;
55

66
$spinner-color: #333 !default;
7-
$backdrop-background-color: #f1f1f1 !default;

src/lib/components/ng-http-loader.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<div id="spinner"
22
*ngIf="isVisible$ | async"
33
[class.backdrop]="backdrop"
4-
[style.opacity]="opacity">
4+
[style.opacity]="opacity"
5+
[style.backgroundColor]="backdropBackgroundColor">
56

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

src/lib/components/ng-http-loader.component.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
left: 0;
1313
height: 100%;
1414
width: 100%;
15-
background-color: $backdrop-background-color;
1615
display: flex;
1716
align-items: center;
1817
justify-content: center;

src/lib/components/ng-http-loader.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class NgHttpLoaderComponent implements OnInit {
3535
@Input() public filteredUrlPatterns: string[] = [];
3636
@Input() public minDuration = 0;
3737
@Input() public opacity = '.7';
38+
@Input() public backdropBackgroundColor = '#f1f1f1';
3839
@Input() public spinner: string | null = Spinkit.skWave;
3940

4041
constructor(private pendingRequestsInterceptor: PendingRequestsInterceptor, private spinnerVisibility: SpinnerVisibilityService) {

src/test/components/ng-http-loader.component.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,4 +798,29 @@ describe('NgHttpLoaderComponent', () => {
798798

799799
expect(element.style.opacity).toBe(`0${component.opacity}`);
800800
});
801+
802+
it('should have a default backdrop background color', () => {
803+
component.isVisible$ = of(true);
804+
fixture.detectChanges();
805+
806+
const element: HTMLElement = fixture
807+
.debugElement
808+
.query(By.css('#spinner'))
809+
.nativeElement;
810+
811+
expect(element.style.backgroundColor).toBe('rgb(241, 241, 241)');
812+
});
813+
814+
it('should be possible to override backdrop background color', () => {
815+
component.isVisible$ = of(true);
816+
component.backdropBackgroundColor = '#777777';
817+
fixture.detectChanges();
818+
819+
const element: HTMLElement = fixture
820+
.debugElement
821+
.query(By.css('#spinner'))
822+
.nativeElement;
823+
824+
expect(element.style.backgroundColor).toBe('rgb(119, 119, 119)');
825+
});
801826
});

0 commit comments

Comments
 (0)