From 5b5281e50c06276cbaea9d814f62685c0c0b23ee Mon Sep 17 00:00:00 2001 From: Prathamesh Gursal Date: Wed, 9 Oct 2024 01:28:54 +0530 Subject: [PATCH] added customize loader for each section --- frontend/src/settings/APIKeys.tsx | 2 +- frontend/src/settings/Analytics.tsx | 6 +- frontend/src/settings/Documents.tsx | 2 +- frontend/src/settings/Logs.tsx | 2 +- frontend/src/utils/loader.tsx | 138 +++++++++++++++++++++------- 5 files changed, 112 insertions(+), 38 deletions(-) diff --git a/frontend/src/settings/APIKeys.tsx b/frontend/src/settings/APIKeys.tsx index eb9c14e8..07370541 100644 --- a/frontend/src/settings/APIKeys.tsx +++ b/frontend/src/settings/APIKeys.tsx @@ -107,7 +107,7 @@ export default function APIKeys() {
{loading ? ( - + ) : ( diff --git a/frontend/src/settings/Analytics.tsx b/frontend/src/settings/Analytics.tsx index b6948d70..6103c35e 100644 --- a/frontend/src/settings/Analytics.tsx +++ b/frontend/src/settings/Analytics.tsx @@ -223,7 +223,7 @@ export default function Analytics() { className="flex flex-row items-center justify-end" > {loadingMessages ? ( - + ) : ( {loadingTokens ? ( - + ) : ( {loadingFeedback ? ( - + ) : ( = ({
{loading ? ( - + ) : (
diff --git a/frontend/src/settings/Logs.tsx b/frontend/src/settings/Logs.tsx index 28bca57f..1e2bd953 100644 --- a/frontend/src/settings/Logs.tsx +++ b/frontend/src/settings/Logs.tsx @@ -105,7 +105,7 @@ export default function Logs() {
{loadingLogs ? ( - + ) : ( )} diff --git a/frontend/src/utils/loader.tsx b/frontend/src/utils/loader.tsx index de9cf766..a9548d6d 100644 --- a/frontend/src/utils/loader.tsx +++ b/frontend/src/utils/loader.tsx @@ -2,9 +2,13 @@ import React, { useState, useEffect } from 'react'; interface SkeletonLoaderProps { count?: number; + component?: 'default' | 'analysis' | 'chatbot' | 'logs'; } -const SkeletonLoader: React.FC = ({ count = 1 }) => { +const SkeletonLoader: React.FC = ({ + count = 1, + component = 'default', +}) => { const [skeletonCount, setSkeletonCount] = useState(count); useEffect(() => { @@ -30,38 +34,108 @@ const SkeletonLoader: React.FC = ({ count = 1 }) => { return (
- {[...Array(skeletonCount)].map((_, idx) => ( -
-
-
-
{' '} -
{' '} -
{' '} -
{' '} -
{' '} + {component === 'default' + ? [...Array(skeletonCount)].map((_, idx) => ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
{' '} -
-
{' '} -
{' '} -
{' '} -
-
{' '} -
-
{' '} -
{' '} -
{' '} -
{' '} -
-
{' '} -
{' '} -
{' '} -
-
- ))} + )) + : component === 'analysis' + ? [...Array(skeletonCount)].map((_, idx) => ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )) + : component === 'chatbot' + ? [...Array(skeletonCount)].map((_, idx) => ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )) + : [...Array(skeletonCount)].map((_, idx) => ( +
+
+
+
+
+
+
+
+
+ ))}
); };