Skip to content

Commit

Permalink
refactor(theme-shared): change the table row hover style
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-erim committed Jan 9, 2020
1 parent 1b2476a commit 4f3df42
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export class PaginationComponent implements OnInit {
return this._value;
}
set value(newValue: number) {
if (this._value === newValue) return;

this._value = newValue;
this.valueChange.emit(newValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<abp-pagination
*ngIf="rows"
[totalPages]="totalPages"
(valueChange)="page = $event; pageChange.emit($event)"
[(value)]="page"
(valueChange)="pageChange.emit($event)"
></abp-pagination>
</div>
</div>
Expand Down Expand Up @@ -60,9 +61,9 @@
<ng-container *ngIf="value && value.length; else emptyTemplate">
<ng-template
#bodyTemplateWrapper
*ngFor="let val of slicedValue; trackBy: trackByFn"
*ngFor="let val of slicedValue; let index = index; trackBy: trackByFn"
[ngTemplateOutlet]="bodyTemplate"
[ngTemplateOutletContext]="{ $implicit: val }"
[ngTemplateOutletContext]="{ $implicit: val, rowIndex: index }"
></ng-template>
</ng-container>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
AfterViewInit,
Component,
ElementRef,
EventEmitter,
Expand All @@ -8,10 +9,7 @@ import {
TrackByFunction,
ViewChild,
ViewEncapsulation,
AfterViewInit,
} from '@angular/core';
import { Observable, of } from 'rxjs';
import { delay } from 'rxjs/operators';

@Component({
selector: 'abp-table',
Expand All @@ -20,11 +18,11 @@ import { delay } from 'rxjs/operators';
`
.ui-table .ui-table-tbody > tr:nth-child(even):hover,
.ui-table .ui-table-tbody > tr:hover {
background-color: #eaeaea;
filter: brightness(90%);
}
.ui-table .ui-table-tbody > tr.empty-row:hover {
background-color: transparent;
filter: none;
}
.ui-table .ui-table-tbody > tr.empty-row > div {
Expand All @@ -35,8 +33,9 @@ import { delay } from 'rxjs/operators';
],
encapsulation: ViewEncapsulation.None,
})
export class TableComponent implements AfterViewInit {
export class TableComponent {
private _totalRecords: number;
bodyScrollLeft = 0;

@Input()
value: any[];
Expand All @@ -59,6 +58,9 @@ export class TableComponent implements AfterViewInit {
@Input()
rows: number;

@Input()
page = 1;

@Input()
trackingProp = 'id';

Expand All @@ -71,16 +73,6 @@ export class TableComponent implements AfterViewInit {
@ViewChild('wrapper', { read: ElementRef, static: false })
wrapperRef: ElementRef<HTMLDivElement>;

page = 1;

bodyScrollLeft = 0;

colspan: number;

trackByFn: TrackByFunction<any> = (_, value) => {
return typeof value === 'object' ? value[this.trackingProp] || value : value;
};

@Input()
get totalRecords(): number {
return this._totalRecords || this.value.length;
Expand Down Expand Up @@ -108,9 +100,7 @@ export class TableComponent implements AfterViewInit {
return this.value.slice(start, start + this.rows);
}

ngAfterViewInit() {
setTimeout(() => {
this.colspan = this.wrapperRef.nativeElement.querySelectorAll('th').length;
}, 0);
}
trackByFn: TrackByFunction<any> = (_, value) => {
return typeof value === 'object' ? value[this.trackingProp] || value : value;
};
}

0 comments on commit 4f3df42

Please sign in to comment.