Allow children-only InfoBox without msg prop
This commit is contained in:
parent
ec6e892aeb
commit
b225a21f41
@ -1,27 +1,19 @@
|
|||||||
import React, { Fragment } from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
interface InfoBoxProps {
|
interface InfoBoxProps {
|
||||||
msg: string;
|
msg?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const InfoBox: React.FC<InfoBoxProps> = (props) => (
|
const InfoBox: React.FC<InfoBoxProps> = (props) => (
|
||||||
<Fragment>
|
<>
|
||||||
{
|
{
|
||||||
(props.msg || props.children)?
|
(props.msg || props.children) &&
|
||||||
(
|
|
||||||
<div className="alert alert-info" role="alert">
|
<div className="alert alert-info" role="alert">
|
||||||
{
|
{ props.msg ?? '' }
|
||||||
typeof props.msg === 'string' ?
|
{ props.children }
|
||||||
props.msg
|
|
||||||
: 'Enjoy the colouring! Usual service should resume shortly.'
|
|
||||||
}
|
|
||||||
{
|
|
||||||
props.children
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
) : null
|
|
||||||
}
|
}
|
||||||
</Fragment>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default InfoBox;
|
export default InfoBox;
|
||||||
|
Loading…
Reference in New Issue
Block a user