Skip to content

Commit

Permalink
feat: make loading makse configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
FritzHoing committed Jul 3, 2024
1 parent 69e4b04 commit 4d89cc7
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions src/Legend/Legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export interface BaseProps {
* Additional headers to apply for the img request.
*/
headers?: HeadersInit;
/**
* Defines whether the loading mask should be displayed or not. Per default the loading mask is active.
*/
loadingMask?: boolean;
}

export type LegendProps = BaseProps & React.HTMLAttributes<HTMLDivElement>;
Expand All @@ -76,6 +80,7 @@ export const Legend: React.FC<LegendProps> = ({
onError,
errorMsg,
headers,
loadingMask = true,
...passThroughProps
}) => {

Expand Down Expand Up @@ -139,28 +144,30 @@ export const Legend: React.FC<LegendProps> = ({
className={`${CSS_PREFIX}legend ${className ? className : ''}`}
{...passThroughProps}
>
<Spin
spinning={loading}
indicator={(
<FontAwesomeIcon
icon={faCircleNotch}
/>
)}
>
{legendError ?
<div
className='legend-load-error'
>
{errorMsg}
</div>
:
<img
src={imgSrc}
alt={alt}
onError={handleError.bind(this)}
/>
}
</Spin>
{ loadingMask &&
<Spin
spinning={loading}
indicator={(
<FontAwesomeIcon
icon={faCircleNotch}
/>
)}
>
{legendError ?
<div
className='legend-load-error'
>
{errorMsg}
</div>
:
<img
src={imgSrc}
alt={alt}
onError={handleError.bind(this)}
/>
}
</Spin>
}
</div>
);
};
Expand Down

0 comments on commit 4d89cc7

Please sign in to comment.