PluginProbe
Code Snippets / 3.10.2
Code Snippets v3.10.2
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 3.10.2, at js/components/common/LoadingStatusNotices.tsx

42 lines 943 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 { ReactNode } from 'react'
5
6 export interface LoadingStatusNoticesProps {
7 isLoading: boolean
8 errorMessage: string | undefined
9 loadingNotice: ReactNode
10 noticeLabel: string
11 }
12
13 export const LoadingStatusNotices: React.FC<LoadingStatusNoticesProps> = ({
14 isLoading,
15 errorMessage,
16 loadingNotice,
17 noticeLabel
18 }) => {
19 switch (true) {
20 case isLoading:
21 return (
22 <Notice aria-label={noticeLabel} className="inline">
23 <p>{loadingNotice}</p>
24 </Notice>
25 )
26
27 case errorMessage !== undefined:
28 return (
29 <Notice aria-label={noticeLabel} className="inline" type="error">
30 <p>{errorMessage}</p>
31 </Notice>
32 )
33
34 default:
35 return (
36 <Notice aria-label={noticeLabel} className="inline" type="warning">
37 <p>{__('An unknown error occurred. Please try again.', 'code-snippets')}</p>
38 </Notice>
39 )
40 }
41 }
42