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

feat: add info variant for toast #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
20 changes: 17 additions & 3 deletions src/components/Toast/Toast.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const toastArgTypes = {
},
},
type: {
description: 'Type of toast - `success` | `error` | `warning`',
description: 'Type of toast - `success` | `error` | `warning` | `info`',
},
id: {
table: {
Expand Down Expand Up @@ -73,7 +73,7 @@ Toasts is used as a non blocking notification with short message for users to ge

1. Add `ToastContainer` anywhere in the DOM tree.
2. Call `showToast` method with message as first argument and object with toast configuration props as second argument.
3. You can pass the `type` as `success` | `error` | `warning` or can pass custom `colorConfig` to change the color of the toast.
3. You can pass the `type` as `success` | `error` | `warning` | `info` or can pass custom `colorConfig` to change the color of the toast.

<br />

Expand Down Expand Up @@ -155,6 +155,20 @@ export default ToastDemo;
</Story>
</Canvas>

### Info Toast

<Canvas>
<Story
name="Info Toast"
args={{
content: 'Your request is missing data.',
type: 'info',
}}
>
{ToastTemplate.bind({})}
</Story>
</Canvas>

## Props

`showToast(content: string, options: object)` function takes two arguments
Expand All @@ -175,7 +189,7 @@ export default ToastDemo;
| prop | description | type |
| ---------------- | ---------------------------------------------------------------------------- | --------- |
| `description` | toast subtext | `string` |
| `type` | `success`, `warning`, or `error` - this also decides the color | `string` |
| `type` | `success`, `warning`, `error` or `info` - this also decides the color | `string` |
| `colorConfig` | `{ background: string, color: string }` | `object` |
| `textStyle` | used for passing the font styles for toast content (message) and description | `object` |
| `fullWidth` | toast width with default true | `boolean` |
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toast/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ToastColorConfig = {
color: string;
};

export type ToastTypes = 'success' | 'error' | 'warning';
export type ToastTypes = 'success' | 'error' | 'warning' | 'info';
export interface ToastProps {
id?: string;
content: string;
Expand Down
4 changes: 4 additions & 0 deletions src/primitives/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ const getDarkThemedColors = () => ({
background: mainColors.red,
color: '#F8F8F8',
},
info: {
background: mainColors.blue,
color: '#F8F8F8',
},
},
searchBar: {
border: colorPalette.black[70],
Expand Down
2 changes: 2 additions & 0 deletions src/primitives/toasts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const getToastColor = (type: ToastTypes) => {
return colorGuide.darkComponents.toast.error;
case 'warning':
return colorGuide.darkComponents.toast.warning;
case 'info':
return colorGuide.darkComponents.toast.info;
default:
return colorGuide.darkComponents.toast.error;
}
Expand Down