Skip to content

Commit

Permalink
refactor: remove cn function (#543)
Browse files Browse the repository at this point in the history
* Remove cn function

* fix
  • Loading branch information
emilkowalski authored Jan 15, 2025
1 parent 927e8fe commit baa7b47
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 9 deletions.
5 changes: 1 addition & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -785,7 +783,6 @@ const Toaster = forwardRef<HTMLElement, ToasterProps>(function Toaster(props, re
loadingIcon={loadingIcon}
expanded={expanded}
pauseWhenPageIsHidden={pauseWhenPageIsHidden}
cn={cn}
/>
))}
</ol>
Expand Down
4 changes: 0 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ interface ToastOptions {
classNames?: ToastClassnames;
}

type CnFunction = (...classes: Array<string | undefined>) => string;

type Offset =
| {
top?: string | number;
Expand Down Expand Up @@ -144,7 +142,6 @@ export interface ToasterProps {
icons?: ToastIcons;
containerAriaLabel?: string;
pauseWhenPageIsHidden?: boolean;
cn?: CnFunction;
}

export interface ToastProps {
Expand Down Expand Up @@ -174,7 +171,6 @@ export interface ToastProps {
icons?: ToastIcons;
closeButtonAriaLabel?: string;
pauseWhenPageIsHidden: boolean;
cn: CnFunction;
defaultRichColors?: boolean;
}

Expand Down
1 change: 0 additions & 1 deletion website/src/pages/toaster.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ')` |

0 comments on commit baa7b47

Please sign in to comment.