File tree 8 files changed +72
-9
lines changed
8 files changed +72
-9
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,12 @@ export const AvatarData: FC<PropsWithChildren<AvatarDataProps>> = ({
23
23
}
24
24
25
25
return (
26
- < Stack spacing = { 1.5 } direction = "row" alignItems = "center" >
26
+ < Stack
27
+ spacing = { 1.5 }
28
+ direction = "row"
29
+ alignItems = "center"
30
+ className = { styles . root }
31
+ >
27
32
{ avatar }
28
33
29
34
< Stack spacing = { 0 } >
@@ -35,6 +40,10 @@ export const AvatarData: FC<PropsWithChildren<AvatarDataProps>> = ({
35
40
}
36
41
37
42
const useStyles = makeStyles ( ( theme ) => ( {
43
+ root : {
44
+ minHeight : theme . spacing ( 5 ) , // Make it predictable for the skeleton
45
+ } ,
46
+
38
47
title : {
39
48
color : theme . palette . text . primary ,
40
49
fontWeight : 600 ,
Original file line number Diff line number Diff line change
1
+ import { FC } from "react"
2
+ import { Stack } from "components/Stack/Stack"
3
+ import { Skeleton } from "@material-ui/lab"
4
+
5
+ export const AvatarDataSkeleton : FC = ( ) => {
6
+ return (
7
+ < Stack spacing = { 1.5 } direction = "row" alignItems = "center" >
8
+ < Skeleton variant = "circle" width = { 36 } height = { 36 } />
9
+
10
+ < Stack spacing = { 0 } >
11
+ < Skeleton variant = "text" width = { 100 } />
12
+ < Skeleton variant = "text" width = { 60 } />
13
+ </ Stack >
14
+ </ Stack >
15
+ )
16
+ }
Original file line number Diff line number Diff line change 1
1
import { makeStyles } from "@material-ui/core/styles"
2
2
import TableCell from "@material-ui/core/TableCell"
3
3
import TableRow from "@material-ui/core/TableRow"
4
+ import Skeleton from "@material-ui/lab/Skeleton"
5
+ import { AvatarDataSkeleton } from "components/AvatarData/AvatarDataSkeleton"
4
6
import { FC } from "react"
5
7
import { Loader } from "../Loader/Loader"
6
8
@@ -22,3 +24,36 @@ const useStyles = makeStyles((theme) => ({
22
24
height : theme . spacing ( 20 ) ,
23
25
} ,
24
26
} ) )
27
+
28
+ export const TableLoaderSkeleton : FC < {
29
+ columns : number
30
+ rows ?: number
31
+ useAvatarData ?: boolean
32
+ } > = ( { columns, rows = 4 , useAvatarData = false } ) => {
33
+ const placeholderColumns = Array ( columns ) . fill ( undefined )
34
+ const placeholderRows = Array ( rows ) . fill ( undefined )
35
+
36
+ return (
37
+ < >
38
+ { placeholderRows . map ( ( _ , rowIndex ) => (
39
+ < TableRow key = { rowIndex } role = "progressbar" data-testid = "loader" >
40
+ { placeholderColumns . map ( ( _ , columnIndex ) => {
41
+ if ( useAvatarData && columnIndex === 0 ) {
42
+ return (
43
+ < TableCell key = { columnIndex } >
44
+ < AvatarDataSkeleton />
45
+ </ TableCell >
46
+ )
47
+ }
48
+
49
+ return (
50
+ < TableCell key = { columnIndex } >
51
+ < Skeleton variant = "text" width = "25%" />
52
+ </ TableCell >
53
+ )
54
+ } ) }
55
+ </ TableRow >
56
+ ) ) }
57
+ </ >
58
+ )
59
+ }
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import * as TypesGen from "../../api/typesGenerated"
11
11
import { combineClasses } from "../../util/combineClasses"
12
12
import { AvatarData } from "../AvatarData/AvatarData"
13
13
import { EmptyState } from "../EmptyState/EmptyState"
14
- import { TableLoader } from "../TableLoader/TableLoader"
14
+ import { TableLoaderSkeleton } from "../TableLoader/TableLoader"
15
15
import { TableRowMenu } from "../TableRowMenu/TableRowMenu"
16
16
import { EditRolesButton } from "components/EditRolesButton/EditRolesButton"
17
17
import { Stack } from "components/Stack/Stack"
@@ -70,7 +70,7 @@ export const UsersTableBody: FC<
70
70
return (
71
71
< ChooseOne >
72
72
< Cond condition = { Boolean ( isLoading ) } >
73
- < TableLoader />
73
+ < TableLoaderSkeleton columns = { 4 } useAvatarData />
74
74
</ Cond >
75
75
< Cond condition = { ! users || users . length === 0 } >
76
76
< ChooseOne >
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { TableEmpty } from "components/TableEmpty/TableEmpty"
8
8
import { FC } from "react"
9
9
import { useTranslation } from "react-i18next"
10
10
import { Link as RouterLink } from "react-router-dom"
11
- import { TableLoader } from "../TableLoader/TableLoader"
11
+ import { TableLoaderSkeleton } from "../TableLoader/TableLoader"
12
12
import { WorkspacesRow } from "./WorkspacesRow"
13
13
14
14
interface TableBodyProps {
@@ -29,7 +29,7 @@ export const WorkspacesTableBody: FC<
29
29
}
30
30
31
31
if ( ! workspaces ) {
32
- return < TableLoader />
32
+ return < TableLoaderSkeleton columns = { 4 } useAvatarData />
33
33
}
34
34
35
35
if ( workspaces . length === 0 ) {
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import { AvatarData } from "components/AvatarData/AvatarData"
15
15
import { ChooseOne , Cond } from "components/Conditionals/ChooseOne"
16
16
import { EmptyState } from "components/EmptyState/EmptyState"
17
17
import { Stack } from "components/Stack/Stack"
18
- import { TableLoader } from "components/TableLoader/TableLoader"
18
+ import { TableLoaderSkeleton } from "components/TableLoader/TableLoader"
19
19
import { UserAvatar } from "components/UserAvatar/UserAvatar"
20
20
import { FC } from "react"
21
21
import { Link as RouterLink , useNavigate } from "react-router-dom"
@@ -83,7 +83,7 @@ export const GroupsPageView: FC<GroupsPageViewProps> = ({
83
83
< TableBody >
84
84
< ChooseOne >
85
85
< Cond condition = { isLoading } >
86
- < TableLoader />
86
+ < TableLoaderSkeleton columns = { 2 } useAvatarData />
87
87
</ Cond >
88
88
89
89
< Cond condition = { isEmpty } >
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ import {
26
26
PageHeaderTitle ,
27
27
} from "../../components/PageHeader/PageHeader"
28
28
import { Stack } from "../../components/Stack/Stack"
29
- import { TableLoader } from "../../components/TableLoader/TableLoader"
29
+ import { TableLoaderSkeleton } from "../../components/TableLoader/TableLoader"
30
30
import {
31
31
HelpTooltip ,
32
32
HelpTooltipLink ,
@@ -210,7 +210,7 @@ export const TemplatesPageView: FC<
210
210
</ TableHead >
211
211
< TableBody >
212
212
< Maybe condition = { isLoading } >
213
- < TableLoader />
213
+ < TableLoaderSkeleton columns = { 4 } useAvatarData />
214
214
</ Maybe >
215
215
216
216
< ChooseOne >
Original file line number Diff line number Diff line change @@ -41,4 +41,7 @@ export const props = {
41
41
MuiPaper : {
42
42
elevation : 0 ,
43
43
} ,
44
+ MuiSkeleton : {
45
+ animation : "wave" ,
46
+ } ,
44
47
} as ComponentsProps
You can’t perform that action at this time.
0 commit comments