fix(striker-ui): default MessageBox type to 'info'

main
Tsu-ba-me 3 years ago
parent 1414117ac1
commit 1690349011
  1. 18
      striker-ui/components/MessageBox.tsx

@ -18,11 +18,15 @@ import { BodyText } from './Text';
type MessageBoxType = 'error' | 'info' | 'warning';
type MessageBoxProps = BoxProps & {
text: string;
type: MessageBoxType;
type MessageBoxOptionalProps = {
type?: MessageBoxType;
};
type MessageBoxProps = BoxProps &
MessageBoxOptionalProps & {
text: string;
};
const MESSAGE_BOX_CLASS_PREFIX = 'MessageBox';
const MESSAGE_BOX_CLASSES: Record<MessageBoxType, string> = {
@ -37,8 +41,12 @@ const MESSAGE_BOX_TYPE_MAP_TO_ICON = {
warning: <WarningIcon />,
};
const MESSAGE_BOX_DEFAULT_PROPS: Required<MessageBoxOptionalProps> = {
type: 'info',
};
const MessageBox = ({
type,
type = MESSAGE_BOX_DEFAULT_PROPS.type,
text,
...boxProps
}: MessageBoxProps): JSX.Element => {
@ -105,6 +113,8 @@ const MessageBox = ({
);
};
MessageBox.defaultProps = MESSAGE_BOX_DEFAULT_PROPS;
export type { MessageBoxProps, MessageBoxType };
export default MessageBox;

Loading…
Cancel
Save