From 0012392fc22a08a275a624776038db92119ff2a9 Mon Sep 17 00:00:00 2001 From: zuramai Date: Mon, 20 Nov 2023 09:36:23 +0700 Subject: [PATCH 1/7] refactor: use autodocs on Alert components --- packages/alert/src/index.ts | 3 +- packages/alert/src/lib/alert.tsx | 24 +-- packages/alert/src/stories/Alert.stories.tsx | 99 ++++++++++++ packages/alert/src/stories/Types.stories.tsx | 153 ------------------ .../alert/src/stories/Variants.stories.tsx | 139 ---------------- 5 files changed, 113 insertions(+), 305 deletions(-) create mode 100644 packages/alert/src/stories/Alert.stories.tsx delete mode 100644 packages/alert/src/stories/Types.stories.tsx delete mode 100644 packages/alert/src/stories/Variants.stories.tsx diff --git a/packages/alert/src/index.ts b/packages/alert/src/index.ts index 8fa0e4b..5b1f651 100644 --- a/packages/alert/src/index.ts +++ b/packages/alert/src/index.ts @@ -1,3 +1,4 @@ import Alert from "./lib/alert"; -export default Alert; +export * from "./lib/alert"; +export default Alert \ No newline at end of file diff --git a/packages/alert/src/lib/alert.tsx b/packages/alert/src/lib/alert.tsx index 45326ef..90418eb 100644 --- a/packages/alert/src/lib/alert.tsx +++ b/packages/alert/src/lib/alert.tsx @@ -1,8 +1,8 @@ import React, { ReactNode, useState } from 'react'; import { GoInfo, GoXCircle, GoCheckCircle } from 'react-icons/go'; -interface AlertProps { - type: 'warning' | 'danger' | 'success' | 'info'; +export interface AlertProps { + variant: 'warning' | 'error' | 'success' | 'info'; icon?: boolean | ReactNode title?: string; description?: string | ReactNode; @@ -29,7 +29,7 @@ const classes = { link: 'text-green-700 hover:text-green-600', dismissBtn: 'bg-green-50 text-green-500 hover:bg-green-100 focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2 focus:ring-offset-green-50', }, - danger: { + error: { bg: 'bg-red-50', text: 'text-red-800', description: 'text-red-700', @@ -45,8 +45,8 @@ const classes = { }, } -const Alert: React.FC = ({ - type, +export const Alert: React.FC = ({ + variant, title, icon, description, @@ -62,12 +62,12 @@ const Alert: React.FC = ({ return icon } - switch (type) { + switch (variant) { case 'warning': return (