diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
| commit | f861e6a269ba9f62700776d3cd13b644a9e836d4 (patch) | |
| tree | a5a107e7a6e4ff8b4261fe04349357bc00b783ee /src/components/atoms/layout/notice.tsx | |
| parent | 03331c44276ec56e9f235e4d5ee75030455a753f (diff) | |
refactor: use named export for everything except pages
Next expect a default export for pages so only those components should
use default exports. Everything else should use named exports to
reduce the number of import statements.
Diffstat (limited to 'src/components/atoms/layout/notice.tsx')
| -rw-r--r-- | src/components/atoms/layout/notice.tsx | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/components/atoms/layout/notice.tsx b/src/components/atoms/layout/notice.tsx index a0d1d3e..9f69af2 100644 --- a/src/components/atoms/layout/notice.tsx +++ b/src/components/atoms/layout/notice.tsx @@ -1,13 +1,9 @@ -import { FC } from 'react'; +import { FC, HTMLAttributes } from 'react'; import styles from './notice.module.scss'; export type NoticeKind = 'error' | 'info' | 'success' | 'warning'; -export type NoticeProps = { - /** - * Set additional classnames to the notice wrapper. - */ - className?: string; +export type NoticeProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & { /** * The notice kind. */ @@ -23,16 +19,18 @@ export type NoticeProps = { * * Render a colored message depending on notice kind. */ -const Notice: FC<NoticeProps> = ({ className = '', kind, message }) => { +export const Notice: FC<NoticeProps> = ({ + className = '', + kind, + message, + ...props +}) => { const kindClass = `wrapper--${kind}`; + const noticeClass = `${styles.wrapper} ${styles[kindClass]} ${className}`; - return message ? ( - <div className={`${styles.wrapper} ${styles[kindClass]} ${className}`}> + return ( + <div {...props} className={noticeClass}> {message} </div> - ) : ( - <></> ); }; - -export default Notice; |
