Skip to content

An opinionated toast component for React.

refactor: remove cn function (#543)

Emil Kowalskibaa7b47f204b
diff --git a/src/index.tsx b/src/index.tsx
index f4f16c0..6a7b8ec 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -41,7 +41,7 @@ const SWIPE_THRESHOLD = 20;
// Equal to exit animation duration
const TIME_BEFORE_UNMOUNT = 200;
-function _cn(...classes: (string | undefined)[]) {
+function cn(...classes: (string | undefined)[]) {
return classes.filter(Boolean).join(' ');
}
@@ -74,7 +74,6 @@ const Toast = (props: ToastProps) => {
icons,
closeButtonAriaLabel = 'Close toast',
pauseWhenPageIsHidden,
- cn,
} = props;
const [mounted, setMounted] = React.useState(false);
const [removed, setRemoved] = React.useState(false);
@@ -530,7 +529,6 @@ const Toaster = forwardRef<HTMLElement, ToasterProps>(function Toaster(props, re
icons,
containerAriaLabel = 'Notifications',
pauseWhenPageIsHidden,
- cn = _cn,
} = props;
const [toasts, setToasts] = React.useState<ToastT[]>([]);
const possiblePositions = React.useMemo(() => {
@@ -785,7 +783,6 @@ const Toaster = forwardRef<HTMLElement, ToasterProps>(function Toaster(props, re
loadingIcon={loadingIcon}
expanded={expanded}
pauseWhenPageIsHidden={pauseWhenPageIsHidden}
- cn={cn}
/>
))}
</ol>
diff --git a/src/types.ts b/src/types.ts
index e80d64a..4add2eb 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -103,8 +103,6 @@ interface ToastOptions {
classNames?: ToastClassnames;
}
-type CnFunction = (...classes: Array<string | undefined>) => string;
-
type Offset =
| {
top?: string | number;
@@ -144,7 +142,6 @@ export interface ToasterProps {
icons?: ToastIcons;
containerAriaLabel?: string;
pauseWhenPageIsHidden?: boolean;
- cn?: CnFunction;
}
export interface ToastProps {
@@ -174,7 +171,6 @@ export interface ToastProps {
icons?: ToastIcons;
closeButtonAriaLabel?: string;
pauseWhenPageIsHidden: boolean;
- cn: CnFunction;
defaultRichColors?: boolean;
}
diff --git a/website/src/pages/toaster.mdx b/website/src/pages/toaster.mdx
index 84f0991..38ebd1b 100644
--- a/website/src/pages/toaster.mdx
+++ b/website/src/pages/toaster.mdx
@@ -67,4 +67,3 @@ Changes the directionality of the toast's text.
| loadingIcon | Changes the default loading icon | `-` |
| pauseWhenPageIsHidden | Pauses toast timers when the page is hidden, e.g., when the tab is backgrounded, the browser is minimized, or the OS is locked. | `false` |
| icons | Changes the default icons | `-` |
-| cn | Custom function for constructing/merging classes. | `classes.filter(Boolean).join(' ')` |