mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-15 05:31:33 +03:00
7ff9abee1a
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): --------- Co-authored-by: Stan Girard <girard.stanislas@gmail.com>
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import { useUserSettingsContext } from "@/lib/context/UserSettingsProvider/hooks/useUserSettingsContext";
|
|
import { iconList } from "@/lib/helpers/iconList";
|
|
import { Color } from "@/lib/types/Colors";
|
|
|
|
import styles from "./MessageInfoBox.module.scss";
|
|
|
|
import { Icon } from "../Icon/Icon";
|
|
|
|
export type MessageInfoBoxProps = {
|
|
children: React.ReactNode;
|
|
type: "info" | "success" | "warning" | "error" | "tutorial";
|
|
unforceWhite?: boolean;
|
|
};
|
|
|
|
export const MessageInfoBox = ({
|
|
children,
|
|
type,
|
|
unforceWhite,
|
|
}: MessageInfoBoxProps): JSX.Element => {
|
|
const getIconProps = (): {
|
|
iconName: keyof typeof iconList;
|
|
iconColor: Color;
|
|
} => {
|
|
switch (type) {
|
|
case "info":
|
|
return { iconName: "info", iconColor: "primary" };
|
|
case "success":
|
|
return { iconName: "check", iconColor: "success" };
|
|
case "warning":
|
|
return { iconName: "warning", iconColor: "warning" };
|
|
case "tutorial":
|
|
return { iconName: "step", iconColor: "gold" };
|
|
default:
|
|
return { iconName: "info", iconColor: "primary" };
|
|
}
|
|
};
|
|
|
|
const { isDarkMode } = useUserSettingsContext();
|
|
|
|
return (
|
|
<div
|
|
className={`${styles.message_info_box_wrapper} ${styles[type]} ${
|
|
isDarkMode && !unforceWhite ? styles.dark : ""
|
|
}`}
|
|
>
|
|
<Icon
|
|
name={getIconProps().iconName}
|
|
size="normal"
|
|
color={getIconProps().iconColor}
|
|
/>
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|