From b52b8183ce299b5a2d3c3b2f4f8cb94bb443d746 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Mon, 2 Oct 2023 18:07:34 +0200
Subject: refactor(components): rewrite Notice component

* Rename message prop to children prop and set ReactNode as type
---
 src/components/atoms/notice/notice.tsx | 36 ++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 src/components/atoms/notice/notice.tsx

(limited to 'src/components/atoms/notice/notice.tsx')

diff --git a/src/components/atoms/notice/notice.tsx b/src/components/atoms/notice/notice.tsx
new file mode 100644
index 0000000..0c8a60c
--- /dev/null
+++ b/src/components/atoms/notice/notice.tsx
@@ -0,0 +1,36 @@
+import type { FC, HTMLAttributes, ReactNode } from 'react';
+import styles from './notice.module.scss';
+
+export type NoticeKind = 'error' | 'info' | 'success' | 'warning';
+
+export type NoticeProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
+  /**
+   * The notice body.
+   */
+  children: ReactNode;
+  /**
+   * The notice kind.
+   */
+  kind: NoticeKind;
+};
+
+/**
+ * Notice component
+ *
+ * Render a colored message depending on notice kind.
+ */
+export const Notice: FC<NoticeProps> = ({
+  className = '',
+  children,
+  kind,
+  ...props
+}) => {
+  const kindClass = styles[`notice--${kind}`];
+  const noticeClass = `${styles.notice} ${kindClass} ${className}`;
+
+  return (
+    <div {...props} className={noticeClass}>
+      {children}
+    </div>
+  );
+};
-- 
cgit v1.2.3

