diff --git a/packages/frontend/src/components/shared/InlineNotification/InlineNotification.tsx b/packages/frontend/src/components/shared/InlineNotification/InlineNotification.tsx index e98c4ea3..573d9d12 100644 --- a/packages/frontend/src/components/shared/InlineNotification/InlineNotification.tsx +++ b/packages/frontend/src/components/shared/InlineNotification/InlineNotification.tsx @@ -10,11 +10,29 @@ import { cloneIcon } from 'utils/cloneIcon'; export interface InlineNotificationProps extends ComponentPropsWithoutRef<'div'>, InlineNotificationTheme { + /** + * The title of the notification + */ title: string; + /** + * The description of the notification + */ description?: string; + /** + * The icon to display in the notification + * @default + */ icon?: ReactNode; } +/** + * A notification that is displayed inline with the content + * + * @example + * ```tsx + * + * ``` + */ export const InlineNotification = ({ className, title, @@ -32,6 +50,7 @@ export const InlineNotification = ({ icon: iconClass, } = inlineNotificationTheme({ size, variant, hasDescription: !!description }); + // Render custom icon or default icon const renderIcon = useCallback(() => { if (!icon) return ; return cloneIcon(icon, { className: iconClass() }); diff --git a/packages/frontend/src/pages/components/index.tsx b/packages/frontend/src/pages/components/index.tsx index 456f433e..d2611141 100644 --- a/packages/frontend/src/pages/components/index.tsx +++ b/packages/frontend/src/pages/components/index.tsx @@ -6,6 +6,10 @@ import { Checkbox } from 'components/shared/Checkbox'; import { PlusIcon } from 'components/shared/CustomIcon'; import React, { useState } from 'react'; import { Value } from 'react-calendar/dist/cjs/shared/types'; +import { + renderInlineNotificationWithDescriptions, + renderInlineNotifications, +} from './renders/inlineNotifications'; const avatarSizes: AvatarVariants['size'][] = [18, 20, 24, 28, 32, 36, 40, 44]; const avatarVariants: AvatarVariants['type'][] = ['gray', 'orange', 'blue']; @@ -40,7 +44,7 @@ const Page = () => { return (
-
+

Manual Storybook

Get started by editing{' '} @@ -197,6 +201,19 @@ const Page = () => {

+ +
+ + {/* Inline notification */} +
+

Inline Notification

+
+ {renderInlineNotifications()} +
+
+ {renderInlineNotificationWithDescriptions()} +
+
diff --git a/packages/frontend/src/pages/components/renders/inlineNotifications.tsx b/packages/frontend/src/pages/components/renders/inlineNotifications.tsx new file mode 100644 index 00000000..fc36b914 --- /dev/null +++ b/packages/frontend/src/pages/components/renders/inlineNotifications.tsx @@ -0,0 +1,43 @@ +import { InlineNotification } from 'components/shared/InlineNotification'; +import { InlineNotificationTheme } from 'components/shared/InlineNotification/InlineNotification.theme'; +import React from 'react'; + +const inlineNotificationVariants = [ + 'info', + 'danger', + 'warning', + 'success', + 'generic', +]; +const inlineNotificationSizes = ['md', 'sm']; + +export const renderInlineNotifications = () => { + return inlineNotificationVariants.map((variant) => ( +
+ {inlineNotificationSizes.map((size) => ( + + ))} +
+ )); +}; + +export const renderInlineNotificationWithDescriptions = () => { + return inlineNotificationVariants.map((variant) => ( +
+ {inlineNotificationSizes.map((size) => ( + + ))} +
+ )); +};