File size: 591 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { Spinner } from '@wordpress/components';
import { Notice, NoticeType } from '../notice';
import './styles.scss';

type TabViewProps = {
	children: React.ReactNode;
	errorMessage?: string;
	isLoading?: boolean;
};

const TabView = ( { children, errorMessage, isLoading = false }: TabViewProps ) => {
	if ( errorMessage ) {
		return <Notice type={ NoticeType.Error }>{ errorMessage }</Notice>;
	}

	if ( isLoading ) {
		return (
			<div className="loading-container">
				<Spinner />
			</div>
		);
	}

	return <div className="tab-view">{ children }</div>;
};

export default TabView;