Skip to content
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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions components/Alert/Alert.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

Copy link
Contributor

@choir241 choir241 Nov 14, 2024

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

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shadcn UI library link to the Shadcn UI library docs


### 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.
Copy link
Contributor

@choir241 choir241 Nov 14, 2024

Choose a reason for hiding this comment

The 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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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 stories.tsx files


### 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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.`,
Copy link
Contributor

Choose a reason for hiding this comment

The 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',
},
};