Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { DataTableSummaryRowComponent } from './summary/summary-row.component';
</div>
</div>
}
@if (ghostLoadingIndicator && (!rowCount || !virtualization || !scrollbarV)) {
@if (ghostLoadingIndicator && !rows.length && (!rowCount || !virtualization || !scrollbarV)) {
<ghost-loader
class="ghost-overlay"
[columns]="columns"
Expand Down Expand Up @@ -352,7 +352,7 @@ export class DataTableBodyComponent<TRow extends Row = any> implements OnInit, O
this.recalcLayout();
}

get bodyHeight() {
get bodyHeight(): string {
return this._bodyHeight;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<div class="ghost-loader ghost-cell-container" [style.height.px]="ghostBodyHeight">
@for (item of [].constructor(pageSize); track item) {
<div class="ghost-element" [style.height.px]="rowHeight" [class.datatable-body-row]="cellMode">
@for (col of columns; track col) {
<div class="ghost-cell" [class.datatable-body-cell]="cellMode" [style.width.px]="col.width">
<div class="ghost-loader ghost-cell-container" [style.height]="ghostBodyHeight()">
@for (item of [].constructor(pageSize()); track item) {
<div
class="ghost-element"
[style.height]="rowHeightComputed()"
[class.datatable-body-row]="cellMode()"
>
@for (col of columns(); track col) {
<div
class="ghost-cell"
[class.datatable-body-cell]="cellMode()"
[style.width.px]="col.width"
>
@if (!col.ghostCellTemplate) {
<div class="line ghost-cell-strip"></div>
} @else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
inset-block-start: 20px;

.ghost-cell {
padding-block: 0.9rem;
padding-inline: 1.2rem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
booleanAttribute,
ChangeDetectionStrategy,
Component,
Input,
numberAttribute
numberAttribute,
input
} from '@angular/core';

import { TableColumnInternal } from '../../../types/internal.types';
Expand All @@ -17,9 +17,17 @@ import { TableColumnInternal } from '../../../types/internal.types';
imports: [NgTemplateOutlet]
})
export class DataTableGhostLoaderComponent {
@Input() columns!: TableColumnInternal[];
@Input({ transform: numberAttribute }) pageSize!: number;
@Input() rowHeight!: number | 'auto' | ((row?: any) => number);
@Input({ transform: numberAttribute }) ghostBodyHeight?: number;
@Input({ transform: booleanAttribute }) cellMode = false;
readonly columns = input.required<TableColumnInternal[]>();
readonly pageSize = input.required<number, unknown>({ transform: numberAttribute });
readonly rowHeight = input.required<number | 'auto' | ((row?: any) => number)>();
readonly ghostBodyHeight = input<string>();
readonly cellMode = input(false, { transform: booleanAttribute });

protected readonly rowHeightComputed = () => {
const rowHeight = this.rowHeight();
if (typeof rowHeight === 'function') {
return rowHeight() + 'px';
}
return rowHeight === 'auto' ? 'auto' : rowHeight + 'px';
};
}
5 changes: 5 additions & 0 deletions projects/ngx-datatable/src/lib/themes/_ghost.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $datatable-ghost-cell-strip-background-image: linear-gradient(
) !default;
$datatable-ghost-cell-strip-radius: 4px !default;
$datatble-ghost-cell-animation-duration: 10s;
$datatable-ghost-row-border-color: #d9d8d9 !default;

.ghost-cell-container {
background: $datatable-ghost-cell-container-background;
Expand All @@ -20,3 +21,7 @@ $datatble-ghost-cell-animation-duration: 10s;
border-radius: $datatable-ghost-cell-strip-radius;
animation-duration: $datatble-ghost-cell-animation-duration;
}

.ghost-element {
border-block-end: 1px solid $datatable-ghost-row-border-color;
}
1 change: 1 addition & 0 deletions projects/ngx-datatable/src/lib/themes/bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $datatable-ghost-cell-strip-background-image: linear-gradient(
) !default;
$datatable-ghost-cell-strip-radius: 0 !default;
$datatble-ghost-cell-animation-duration: 10s;
$datatable-ghost-row-border-color: #d1d4d7 !default;

@import './ghost';
@import './rows';
Expand Down
1 change: 1 addition & 0 deletions projects/ngx-datatable/src/lib/themes/material.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ $datatable-ghost-cell-strip-background-image: linear-gradient(
) !default;
$datatable-ghost-cell-strip-radius: 0 !default;
$datatble-ghost-cell-animation-duration: 10s;
$datatable-ghost-row-border-color: $datatable-body-row-border-bottom-color !default;

@import './ghost';
@import './rows';
Expand Down
Loading