Skip to content

Commit 6ae74c1

Browse files
feat(datagrid-web): add RefreshIndicator component and styles for loading state
1 parent 71a789b commit 6ae74c1

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

packages/modules/data-widgets/src/themesource/datawidgets/web/_datagrid.scss

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,82 @@ $root: ".widget-datagrid";
429429
display: contents;
430430
}
431431

432+
&-refresh-container {
433+
grid-column: 1 / -1;
434+
padding: 0;
435+
}
436+
437+
&-refresh-indicator {
438+
-webkit-appearance: none;
439+
-moz-appearance: none;
440+
appearance: none;
441+
background-color: var(--border-color-default, #ced0d3);
442+
border: none;
443+
border-radius: 2px;
444+
color: var(--brand-primary, $dg-brand-primary);
445+
height: 4px;
446+
width: 100%;
447+
448+
&::-webkit-progress-bar {
449+
background-color: transparent;
450+
}
451+
452+
&::-webkit-progress-value {
453+
background-color: currentColor;
454+
transition: all 0.2s;
455+
}
456+
457+
&::-moz-progress-bar {
458+
background-color: currentColor;
459+
transition: all 0.2s;
460+
}
461+
462+
&::-ms-fill {
463+
border: none;
464+
background-color: currentColor;
465+
transition: all 0.2s;
466+
}
467+
468+
&:indeterminate {
469+
background-size: 200% 100%;
470+
background-image: linear-gradient(
471+
to right,
472+
transparent 50%,
473+
currentColor 50%,
474+
currentColor 60%,
475+
transparent 60%,
476+
transparent 71.5%,
477+
currentColor 71.5%,
478+
currentColor 84%,
479+
transparent 84%
480+
);
481+
animation: progress-linear 2s infinite linear;
482+
}
483+
484+
&:indeterminate::-moz-progress-bar {
485+
background-color: transparent;
486+
}
487+
488+
&:indeterminate::-ms-fill {
489+
animation-name: none;
490+
}
491+
492+
@keyframes progress-linear {
493+
0% {
494+
background-size: 200% 100%;
495+
background-position: left -31.25% top 0%;
496+
}
497+
50% {
498+
background-size: 800% 100%;
499+
background-position: left -49% top 0%;
500+
}
501+
100% {
502+
background-size: 400% 100%;
503+
background-position: left -102% top 0%;
504+
}
505+
}
506+
}
507+
432508
&.widget-datagrid-selection-method-click {
433509
.tr.tr-selected .td {
434510
background-color: $dg-grid-selected-row-background;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { createElement, ReactElement } from "react";
2+
3+
export function RefreshIndicator(): ReactElement {
4+
return (
5+
<div className="tr" role="row">
6+
<div className="th widget-datagrid-refresh-container">
7+
<progress className="widget-datagrid-refresh-indicator" />
8+
</div>
9+
</div>
10+
);
11+
}

packages/pluggableWidgets/datagrid-web/src/components/Widget.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { FocusTargetController } from "@mendix/widget-plugin-grid/keyboard-navig
2525
import { observer } from "mobx-react-lite";
2626
import { RowsRenderer } from "./RowsRenderer";
2727
import { GridHeader } from "./GridHeader";
28+
import { RefreshIndicator } from "./RefreshIndicator";
2829

2930
export interface WidgetProps<C extends GridColumn, T extends ObjectItem = ObjectItem> {
3031
CellComponent: CellComponent<C>;
@@ -189,6 +190,7 @@ const Main = observer(<C extends GridColumn>(props: WidgetProps<C>): ReactElemen
189190
isLoading={props.columnsLoading}
190191
preview={props.preview}
191192
/>
193+
<RefreshIndicator />
192194
<GridBody
193195
isLoading={props.isLoading}
194196
isFetchingNextBatch={props.isFetchingNextBatch}

0 commit comments

Comments
 (0)