feat(blocksAntd): refactor Alert with visible icon default

This commit is contained in:
Gervwyk 2020-11-17 16:37:38 +02:00
parent 729dd42cae
commit 37f7c72375

View File

@ -20,25 +20,30 @@ import { blockDefaultProps } from '@lowdefy/block-tools';
import Icon from '../Icon/Icon';
const AlertBlock = ({ blockId, methods, properties }) => (
<Alert
afterClose={() => methods.callAction({ action: 'afterClose' })}
banner={properties.banner}
closable={properties.closable}
closeText={properties.closeText}
description={properties.description}
id={blockId}
message={properties.message}
onClose={() => methods.callAction({ action: 'onClose' })}
showIcon={!!properties.icon}
type={properties.type}
icon={
properties.icon && (
<Icon blockId={`${blockId}_icon`} methods={methods} properties={properties.icon} />
)
}
/>
);
const AlertBlock = ({ blockId, methods, properties }) => {
const additionalProps = {};
if (properties.icon) {
additionalProps.icon = (
<Icon blockId={`${blockId}_icon`} methods={methods} properties={properties.icon} />
);
}
return (
<Alert
afterClose={() => methods.callAction({ action: 'afterClose' })}
banner={properties.banner}
closable={properties.closable}
closeText={properties.closeText}
description={properties.description}
id={blockId}
message={properties.message || <div style={{ height: '1.5175em' }}></div>}
description={properties.description}
onClose={() => methods.callAction({ action: 'onClose' })}
showIcon={properties.showIcon === false ? false : true}
type={properties.type}
{...additionalProps}
/>
);
};
AlertBlock.defaultProps = blockDefaultProps;