Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a z-index input property on ng-http-loader component #189

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 @@ -130,6 +130,7 @@ export class InlineComponent {
You can customize the following parameters:
- The spinner **backdrop** (visible by default).
- The **background-color** (ie. the color of the spinner itself).
- The spinner and its backdrop **z-index**.
- The **debounce delay** (ie. after how many milliseconds the spinner will be visible, if needed).
- 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).
Expand All @@ -141,6 +142,7 @@ You can customize the following parameters:
<ng-http-loader
[backdrop]="false"
[backgroundColor]="'#ff0000'"
[zIndex]=50
[debounceDelay]="100"
[extraDuration]="300"
[minDuration]="300"
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/ng-http-loader.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*ngIf="isVisible$ | async"
[class.backdrop]="backdrop"
[style.opacity]="opacity"
[style.z-index]="zIndex"
[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 @@ -5,7 +5,6 @@
left: 50%;
transform: translate(-50%, -50%);
position: fixed;
z-index: 9999;

&.backdrop {
top: 0;
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 @@ -27,6 +27,7 @@ export class NgHttpLoaderComponent implements OnInit {

@Input() backdrop = true;
@Input() backgroundColor!: string;
@Input() zIndex = 9999;
@Input() debounceDelay = 0;
@Input() entryComponent: any = null;
@Input() extraDuration = 0;
Expand Down
25 changes: 25 additions & 0 deletions src/test/components/ng-http-loader.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,4 +836,29 @@ describe('NgHttpLoaderComponent', () => {

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

it("should have a default specified z-index of 9999 for the background", () => {
component.isVisible$ = of(true);
fixture.detectChanges();

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

expect(element.style.zIndex).toBe('9999');
})

it("should have the specified z-index set for the background", () => {
component.isVisible$ = of(true);
component.zIndex = 50;
fixture.detectChanges();

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

expect(element.style.zIndex).toBe('50');
})
});