Skip to content

Commit

Permalink
replaced getToastAnimation with mapping const
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-defi committed Nov 14, 2024
1 parent 183aeca commit fad0490
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 48 deletions.
10 changes: 8 additions & 2 deletions src/internal/components/Toast.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect } from 'react';
import { background, cn } from '../../styles/theme';
import { closeSvg } from '../svg/closeSvg';
import { getToastAnimation } from '../utils/getToastAnimation';
import { getToastPosition } from '../utils/getToastPosition';

type ToastProps = {
Expand All @@ -14,6 +13,13 @@ type ToastProps = {
children: React.ReactNode;
};

const defaultAnimationByPosition = {
'top-center': 'animate-enterDown',
'top-right': 'animate-enterRight',
'bottom-center': 'animate-enterUp',
'bottom-right': 'animate-enterRight',
};

export function Toast({
className,
durationMs = 3000,
Expand All @@ -24,7 +30,7 @@ export function Toast({
children,
}: ToastProps) {
const positionClass = getToastPosition(position);
const animationClass = animation ?? getToastAnimation(position);
const animationClass = animation ?? defaultAnimationByPosition[position];

useEffect(() => {
const timer = setTimeout(() => {
Expand Down
30 changes: 0 additions & 30 deletions src/internal/utils/getToastAnimation.test.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/internal/utils/getToastAnimation.ts

This file was deleted.

0 comments on commit fad0490

Please sign in to comment.