From 0656fb193bc77b6dc0c8e03740833b3794ca1347 Mon Sep 17 00:00:00 2001 From: Gunnar Torfi Date: Thu, 5 Sep 2024 16:27:18 +0000 Subject: [PATCH] chore: refactor enums to types --- docs/docs/Toaster.md | 12 ++++++------ example/src/App.tsx | 10 +++------- example/src/ToastDemo.tsx | 17 ++++++++--------- src/animations.ts | 11 +++++------ src/constants.ts | 15 ++++++++++----- src/gestures.tsx | 13 +++++-------- src/index.tsx | 1 - src/toast-fns.ts | 10 +++++----- src/toast.tsx | 14 ++++++-------- src/toaster.tsx | 11 +++-------- src/types.ts | 16 +++------------- 11 files changed, 54 insertions(+), 76 deletions(-) diff --git a/docs/docs/Toaster.md b/docs/docs/Toaster.md index fede5fd..743b327 100644 --- a/docs/docs/Toaster.md +++ b/docs/docs/Toaster.md @@ -28,12 +28,12 @@ export default function App() { ## Props -| Prop | Type | Default | Description | -| ------------------------ | --------------------- | -------------------------- | ----------------------------------------------------------- | -| `duration` | `number` | `3000` (ms) | Duration each toast is visible before auto-dismissal. | -| `position` | `ToastPosition` | `ToastPosition.TOP_CENTER` | The position of the toasts (`top-center`, `bottom-center`). | -| `maxToasts` | `number` | `3` | Maximum number of toasts to show at once. | -| `swipToDismissDirection` | `ToastSwipeDirection` | `ToastSwipeDirection.UP | Swipe direction to dismiss (`left`, `up`). | +| Prop | Type | Default | Description | +| ------------------------ | --------------------- | ------------ | ----------------------------------------------------------- | +| `duration` | `number` | `3000` (ms) | Duration each toast is visible before auto-dismissal. | +| `position` | `ToastPosition` | `top-center` | The position of the toasts (`top-center`, `bottom-center`). | +| `maxToasts` | `number` | `3` | Maximum number of toasts to show at once. | +| `swipToDismissDirection` | `ToastSwipeDirection` | `up` | Swipe direction to dismiss (`left`, `up`). | ### Style related props diff --git a/example/src/App.tsx b/example/src/App.tsx index 7de235f..c51e670 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -4,11 +4,7 @@ import { ToastDemoModal } from 'example/src/ToastDemoModal'; import { ToastDemoScreen } from 'example/src/ToastDemoScreen'; import * as React from 'react'; import { GestureHandlerRootView } from 'react-native-gesture-handler'; -import { - Toaster, - ToastPosition, - ToastSwipeDirection, -} from 'react-native-reanimated-toasts'; +import { Toaster } from 'react-native-reanimated-toasts'; import { SafeAreaProvider } from 'react-native-safe-area-context'; import '../global.css'; @@ -31,9 +27,9 @@ const App: React.FC = () => { diff --git a/example/src/ToastDemo.tsx b/example/src/ToastDemo.tsx index b51ce94..fbcba35 100644 --- a/example/src/ToastDemo.tsx +++ b/example/src/ToastDemo.tsx @@ -1,22 +1,21 @@ import { Button, Pressable, Text, View } from 'react-native'; import * as React from 'react'; -import { toast, ToastVariant } from 'react-native-reanimated-toasts'; +import { toast } from 'react-native-reanimated-toasts'; import { SafeAreaView } from 'react-native-safe-area-context'; export const ToastDemo: React.FC = () => { - const [variant, setVariant] = React.useState(ToastVariant.INFO); + const [variant, setVariant] = React.useState<'success' | 'error' | 'info'>( + 'info' + ); const [toastId, setToastId] = React.useState(null); return ( Selected variant: {variant} -