forked from patternfly/patternfly-quickstarts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus-box.tsx
More file actions
56 lines (48 loc) · 1.56 KB
/
status-box.tsx
File metadata and controls
56 lines (48 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { FC, useContext } from 'react';
import { css } from '@patternfly/react-styles';
import { QuickStartContext, QuickStartContextValues } from '../../../utils/quick-start-context';
export const Box: React.FC<BoxProps> = ({ children, className }) => (
<div className={css('pfext-status-box', className)}>{children}</div>
);
export const Loading: FC<LoadingProps> = ({ className }) => (
<div className={css('pfext-m-loader', className)}>
<div className="pfext-m-loader-dot__one" />
<div className="pfext-m-loader-dot__two" />
<div className="pfext-m-loader-dot__three" />
</div>
);
Loading.displayName = 'Loading';
export const LoadingBox: FC<LoadingBoxProps> = ({ className, message }) => (
<Box className={css('pfext-status-box--loading', className)}>
<Loading />
{message && <div className="pfext-status-box__loading-message">{message}</div>}
</Box>
);
LoadingBox.displayName = 'LoadingBox';
export const EmptyBox: React.FC<EmptyBoxProps> = ({ label }) => {
const { getResource } = useContext<QuickStartContextValues>(QuickStartContext);
return (
<Box>
<div data-test="empty-message" className="text-center">
{label
? getResource('No {{label}} found').replace('{{label}}', label)
: getResource('Not found')}
</div>
</Box>
);
};
EmptyBox.displayName = 'EmptyBox';
interface BoxProps {
children: React.ReactNode;
className?: string;
}
interface LoadingProps {
className?: string;
}
interface LoadingBoxProps {
className?: string;
message?: string;
}
interface EmptyBoxProps {
label?: string;
}