Skip to content

Commit

Permalink
adding an error handling element
Browse files Browse the repository at this point in the history
  • Loading branch information
OvidijusParsiunas committed Feb 11, 2024
1 parent 42e51e9 commit 928cf9d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
23 changes: 23 additions & 0 deletions component/src/activeTableStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,13 @@ export const activeTableStyle = css`
width: 100%;
}
.absolute-container {
position: absolute;
top: 0;
height: 100%;
width: 100%;
}
.loading-spinner {
width: 60px;
height: 60px;
Expand All @@ -866,6 +873,22 @@ export const activeTableStyle = css`
animation: rotation 1s linear infinite;
}
#error-container {
position: absolute;
top: 0;
height: 100%;
width: 100%;
background-color: #ff000006;
display: flex;
justify-content: center;
align-items: center;
}
#error-text {
font-size: 24px;
color: red;
}
@keyframes rotation {
0% {
transform: rotate(0deg);
Expand Down
1 change: 1 addition & 0 deletions component/src/types/activeOverlayElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export interface ActiveOverlayElements {
// the reason why this is here and not in ColumnSizerT is because it is more efficient to access these values here
selectedColumnSizer?: SelectedColumnSizerT;
loading?: HTMLElement;
error?: HTMLElement;
}
24 changes: 24 additions & 0 deletions component/src/utils/outerTableComponents/error/errorElement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {OuterContainerElements} from '../outerContainerElements';
import {ActiveTable} from '../../../activeTable';

export class ErrorElement {
public static create() {
const containerElement = document.createElement('div');
containerElement.id = 'error-container';
containerElement.classList.add(OuterContainerElements.ABSOULUTE_FULL_TABLE_CLASS);
const textElement = document.createElement('div');
textElement.id = 'error-text';
textElement.innerHTML = 'Error retrieving data';
containerElement.appendChild(textElement);
return containerElement;
}

public static display(at: ActiveTable) {
const {error} = at._activeOverlayElements;
if (error) at._tableElementRef?.appendChild(error);
}

public static remove(at: ActiveTable) {
at._activeOverlayElements.error?.remove();
}
}

0 comments on commit 928cf9d

Please sign in to comment.