-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Story for the Alert component #645 #653
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright (c) Gridiron Survivor. | ||
// Licensed under the MIT License. | ||
|
||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Alert } from './Alert'; | ||
|
||
const meta: Meta<typeof Alert> = { | ||
title: 'Components/Alert', | ||
component: Alert, | ||
tags: ['autodocs'], | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: ` | ||
The \`Alert\` component is a dynamic UI element from the Shadcn UI library, designed to display important notifications to users. It combines several subcomponents—\`AlertTitle\`, \`AlertDescription\`, and \`AlertDefault\`—into a cohesive \`AlertNotification\` component. This component is exported as \`<Alert variant={variant} message="Whatever message" />\`, making it easy to use across applications. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
### Variants | ||
|
||
- **Success**: Indicates successful operations, such as a successful user sign-in. | ||
- **Error**: Alerts users to errors, like incorrect login information. | ||
- **Warning**: Reserved for potential issues. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you provide an example of when a warning message would occur, like the Success and error variants, for consistency? |
||
- **Default**: Used for general information. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you provide an example of when a default message would occur, like the Success and error variants, for consistency? |
||
|
||
### Usage | ||
|
||
The \`Alert\` component is primarily used to provide users with visual feedback on the status of their actions, such as confirming successful operations or notifying them of errors. It is integrated with \`react-hot-toast\` to enable popup notifications, enhancing user experience by providing immediate feedback. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. popup should be pop-up |
||
|
||
\`\`\`jsx | ||
<Alert variant="success" message="This is a success alert" /> | ||
\`\`\` | ||
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please take a look at how the other stories are being defined in |
||
|
||
### Props | ||
|
||
- **variant**: Determines the type of alert, affecting its title and color. Options include 'success', 'error', 'warning', and 'default'. | ||
- **message**: The content of the alert message, rendered within the \`AlertDescription\`. | ||
Comment on lines
+34
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this be better as a table? |
||
|
||
### Integration with Toast | ||
|
||
The component's notification functionality is powered by \`react-hot-toast\`, a package that handles popup notifications. By wrapping \`toast.custom()\` around \`<Alert variant={} message="" />\`, the component can display alerts as pop-up notifications, providing users with immediate visual feedback.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. popup notifications should be pop-up notifications |
||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
variant: { | ||
options: ['default', 'error', 'warning', 'success'], | ||
control: { type: 'radio' }, | ||
description: 'The variant of the alert.', | ||
}, | ||
children: { | ||
description: 'Content of the alert message.', | ||
}, | ||
}, | ||
args: { | ||
children: 'This is an alert message', | ||
}, | ||
} satisfies Meta<typeof Alert>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
variant: 'default', | ||
}, | ||
}; | ||
|
||
export const Error: Story = { | ||
args: { | ||
variant: 'error', | ||
children: 'This is an error alert', | ||
}, | ||
}; | ||
|
||
export const Warning: Story = { | ||
args: { | ||
variant: 'warning', | ||
children: 'This is a warning alert', | ||
}, | ||
}; | ||
|
||
export const Success: Story = { | ||
args: { | ||
variant: 'success', | ||
children: 'This is a success alert', | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you supposed to write tests for this Alert story? Please confirm with Shashi if this is the case of not