PluginProbe
Code Snippets / trunk
Code Snippets vtrunk
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / common / LoadingStatusNotices.tsx

LoadingStatusNotices.tsx in Code Snippets trunk, at js/components/common/LoadingStatusNotices.tsx

41 lines 973 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from 'react'
2 import { __ } from '@wordpress/i18n'
3 import { Notice } from './Notice'
4 import type { LoadingStatus } from '../../hooks/useFetchData'
5 import type { ReactNode } from 'react'
6
7 export interface LoadingStatusNoticesProps extends LoadingStatus {
8 loadingNotice: ReactNode
9 noticeLabel: string
10 }
11
12 export const LoadingStatusNotices: React.FC<LoadingStatusNoticesProps> = ({
13 isLoading,
14 errorMessage,
15 loadingNotice,
16 noticeLabel
17 }) => {
18 switch (true) {
19 case isLoading:
20 return (
21 <Notice aria-label={noticeLabel} className="inline">
22 <p>{loadingNotice}</p>
23 </Notice>
24 )
25
26 case errorMessage !== undefined:
27 return (
28 <Notice aria-label={noticeLabel} className="inline" type="error">
29 <p>{errorMessage}</p>
30 </Notice>
31 )
32
33 default:
34 return (
35 <Notice aria-label={noticeLabel} className="inline" type="warning">
36 <p>{__('An unknown error occurred. Please try again.', 'code-snippets')}</p>
37 </Notice>
38 )
39 }
40 }
41