diff --git a/ui/src/components/loaders/CardLoader.tsx b/ui/src/components/loaders/CardLoader.tsx new file mode 100644 index 00000000..bd95e198 --- /dev/null +++ b/ui/src/components/loaders/CardLoader.tsx @@ -0,0 +1,30 @@ +import React from "react"; +import { twMerge } from "tailwind-merge"; + +export interface CardLoaderProps { + className?: string; + variant: "light" | "dark"; +} + +const CardLoader: React.FC = ({ className, variant }) => { + const style = { + light: `bg-[linear-gradient(270deg,_#D8EBFF_0%,_#ECF5FF_100%)] + shadow-light`, + dark: `bg-[linear-gradient(270deg,_#252525_0%,_rgba(68,_67,_67,_0.24)_100%)] + shadow-dark`, + }; + + return ( +
+ ); +}; + +export default CardLoader; diff --git a/ui/src/components/loaders/TableLoader.tsx b/ui/src/components/loaders/TableLoader.tsx new file mode 100644 index 00000000..bca82cd7 --- /dev/null +++ b/ui/src/components/loaders/TableLoader.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import { twMerge } from "tailwind-merge"; + +export interface TableLoaderProps { + className?: string; + variant: "light" | "dark"; +} + +const TableLoader: React.FC = ({ className, variant }) => { + const style = { + light: `bg-[linear-gradient(270deg,_#D8EBFF_0%,_#ECF5FF_100%)]`, + dark: `bg-[linear-gradient(270deg,_#252525_0%,_rgba(68,_67,_67,_0.24)_100%)]`, + }; + + return ( +
+ ); +}; + +export default TableLoader; diff --git a/ui/src/components/tables/Table.tsx b/ui/src/components/tables/Table.tsx index 956ac9b9..56ed9424 100644 --- a/ui/src/components/tables/Table.tsx +++ b/ui/src/components/tables/Table.tsx @@ -9,6 +9,7 @@ import { import { Tooltip } from "react-tooltip"; import Tag from "@/components/tags/Tag"; +import TableLoader from "@/components/loaders/TableLoader"; import ChiliLight from "@/assets/illustrations/ChiliLight"; import ChiliDark from "@/assets/illustrations/ChiliDark"; import CodeBranchIcon from "@/assets/icons/CodeBranchIcon"; @@ -19,12 +20,14 @@ import { Layer, LayerState } from "@/clients/layers/types"; export interface TableProps { className?: string; variant?: "light" | "dark"; + isLoading?: boolean; data: Layer[]; } const Table: React.FC = ({ className, variant = "light", + isLoading, data, }) => { const columnHelper = createColumnHelper(); @@ -211,78 +214,137 @@ const Table: React.FC = ({ ))} - {table.getRowModel().rows.map((row) => ( - - {row.getVisibleCells().map((cell, index) => ( - ( + - {flexRender(cell.column.columnDef.cell, cell.getContext())} - {index === 0 ? ( -
- ) : index === row.getVisibleCells().length - 1 ? ( -
- ) : ( -
+ {table.getAllColumns().map((_, index) => ( + + + {index === 0 ? ( +
+ ) : index === table.getAllColumns().length - 1 ? ( +
+ ) : ( +
+ )} + + ))} + + )) + : table.getRowModel().rows.map((row) => ( + + > + {row.getVisibleCells().map((cell, index) => ( + + {flexRender( + cell.column.columnDef.cell, + cell.getContext() + )} + {index === 0 ? ( +
+ ) : index === row.getVisibleCells().length - 1 ? ( +
+ ) : ( +
+ )} + + ))} + ))} - - ))} { const { theme } = useContext(ThemeContext); @@ -230,21 +231,43 @@ const Layers: React.FC = () => { -
- {layersQuery.isLoading && <>} - {layersQuery.isError && <>} - {layersQuery.isSuccess && - (view === "grid" ? ( -
- {layersQuery.data.results.map((layer, index) => ( +
+ {view === "grid" ? ( +
+ {layersQuery.isLoading ? ( + Array.from({ length: 100 }).map((_, index) => ( + + )) + ) : layersQuery.isError ? ( + An error has occurred + ) : layersQuery.isSuccess ? ( + layersQuery.data.results.map((layer, index) => ( - ))} -
- ) : view === "table" ? ( - - ) : ( - <> - ))} + )) + ) : ( + <> + )} + + ) : view === "table" ? ( +
+ {layersQuery.isLoading ? ( +
+ ) : layersQuery.isError ? ( + An error has occurred + ) : layersQuery.isSuccess ? ( +
+ ) : ( + <> + )} + + ) : ( + <> + )} );