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 classNames for content/icon elements #372

Merged
merged 1 commit into from
Mar 16, 2024
Merged
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
15 changes: 8 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import React from 'react';
import ReactDOM from 'react-dom';

import './styles.css';
import DOMPurify from "dompurify";
import { getAsset, Loader } from './assets';
import { useIsDocumentHidden } from './hooks';
import type { HeightT, ToastT, ToastToDismiss, ExternalToast, ToasterProps, ToastProps } from './types';
import { ToastState, toast } from './state';
import DOMPurify from "dompurify";
import { toast, ToastState } from './state';
import './styles.css';
import type { ExternalToast, HeightT, ToasterProps, ToastProps, ToastT, ToastToDismiss } from './types';

// Visible toasts amount
const VISIBLE_TOASTS_AMOUNT = 3;
Expand Down Expand Up @@ -369,15 +369,15 @@ const Toast = (props: ToastProps) => {
) : (
<>
{toastType || toast.icon || toast.promise ? (
<div data-icon="">
<div data-icon="" className={cn(classNames?.icon)}>
{toast.promise || (toast.type === 'loading' && !toast.icon)
? toast.icon || getLoadingIcon()
: null}
{toast.type !== 'loading' ? toast.icon || icons?.[toastType] || getAsset(toastType) : null}
</div>
) : null}

<div data-content="">
<div data-content="" className={cn(classNames?.content)}>
<div data-title="" className={cn(classNames?.title, toast?.classNames?.title)}
dangerouslySetInnerHTML={sanitizeHTML(toast.title as string)}
></div>
Expand Down Expand Up @@ -697,4 +697,5 @@ const Toaster = (props: ToasterProps) => {
</section>
);
};
export { toast, Toaster, type ToastT, type ExternalToast };
export { toast, Toaster, type ExternalToast, type ToastT };

2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface ToastClassnames {
warning?: string;
loading?: string;
default?: string;
content?: string;
icon?: string;
}

export interface ToastIcons {
Expand Down
Loading