Skip to content

Commit 78a81b5

Browse files
committed
feat: enhance GenericSectionErrorState to support ReactNode for subTitle and description
1 parent 83be291 commit 78a81b5

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/Shared/Components/GenericSectionErrorState/GenericSectionErrorState.component.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { ReactNode } from 'react'
1718
import { ComponentSizeType } from '@Shared/constants'
1819
import { Progressing } from '@Common/Progressing'
19-
import { ReactComponent as ErrorIcon } from '../../../Assets/Icon/ic-error-exclamation.svg'
20-
import { ReactComponent as ICInfoOutline } from '../../../Assets/Icon/ic-info-outline.svg'
20+
import { ReactComponent as ErrorIcon } from '@Icons/ic-error-exclamation.svg'
21+
import { ReactComponent as ICInfoOutline } from '@Icons/ic-info-outline.svg'
22+
import { ReactComponent as ICArrowCounterClockwise } from '@Icons/ic-arrow-counter-clockwise.svg'
2123
import { Button, ButtonVariantType } from '../Button'
2224
import { GenericSectionErrorStateProps } from './types'
2325

@@ -44,6 +46,18 @@ const GenericSectionErrorState = ({
4446
return <ErrorIcon className="icon-dim-24 alert-icon-r5-imp" />
4547
}
4648

49+
const renderSubHeading = (content: ReactNode) => {
50+
if (!content) {
51+
return null
52+
}
53+
54+
if (typeof content === 'string') {
55+
return <p className="m-0 dc__truncate--clamp-6">{content}</p>
56+
}
57+
58+
return content
59+
}
60+
4761
return (
4862
<div className={`flex column dc__gap-8 p-16 ${withBorder ? 'dc__border br-4' : ''} ${rootClassName || ''}`}>
4963
{renderMarker()}
@@ -52,14 +66,15 @@ const GenericSectionErrorState = ({
5266
<h3 className="fs-13 lh-20 fw-6 cn-9 m-0">{title}</h3>
5367
{(subTitle || description) && (
5468
<div className="flex column fs-13 lh-20 fw-4 cn-7">
55-
{subTitle && <p className="m-0">{subTitle}</p>}
56-
{description && <p className="m-0">{description}</p>}
69+
{renderSubHeading(subTitle)}
70+
{renderSubHeading(description)}
5771
</div>
5872
)}
5973
</div>
6074

6175
{reload && (
6276
<Button
77+
startIcon={<ICArrowCounterClockwise className="dc__flip" />}
6378
text={buttonText}
6479
onClick={reload}
6580
variant={ButtonVariantType.text}

src/Shared/Components/GenericSectionErrorState/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { ReactNode } from 'react'
1718
import { ProgressingProps } from '@Common/Types'
1819

1920
export interface GenericSectionErrorStateProps {
@@ -34,11 +35,11 @@ export interface GenericSectionErrorStateProps {
3435
/**
3536
* @default 'We could not load the information on this page.'
3637
*/
37-
subTitle?: string
38+
subTitle?: ReactNode
3839
/**
3940
* @default 'Please reload or try again later'
4041
*/
41-
description?: string
42+
description?: ReactNode
4243
/**
4344
* @default 'Reload'
4445
*/

0 commit comments

Comments
 (0)