Skip to content

Commit

Permalink
feat: add classNames for content/icon elements (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinbaum authored Mar 16, 2024
1 parent 9ddd0e6 commit c5b6f61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
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

0 comments on commit c5b6f61

Please sign in to comment.