Skip to content

Commit

Permalink
Merge pull request #125 from cristidumitrescutotalsoft/feature/autoCl…
Browse files Browse the repository at this point in the history
…ose-default-on-useToast

Add tooltip documentation for default false, on autoClose param, of useToast
  • Loading branch information
DCosti committed Sep 5, 2024
2 parents f18f506 + edb0b20 commit f1909fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/feedback/Toast/ToastContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ToastContainerProps } from './types'

const ToastContainer: React.FC<ToastContainerProps> = ({
position = toast.POSITION.TOP_CENTER,
autoClose = 3000,
autoClose = false,
newestOnTop = true,
transitionType = 'Slide',
limit = 5,
Expand All @@ -37,7 +37,7 @@ ToastContainer.propTypes = {
/**
* Set the delay in ms to close the toast automatically.
* Use `false` to prevent the toast from closing.
* @default 3000
* @default false
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down
6 changes: 6 additions & 0 deletions src/components/feedback/Toast/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ export interface ToastContainerProps extends Omit<ReactToastifyProps, 'transitio
* @default Slide
*/
transitionType?: 'Slide' | 'Bounce' | 'Zoom' | 'Flip'
/**
* Set the delay in ms to close the toast automatically.
* Use `false` to prevent the toast from closing.
* `Default: false`
*/
autoClose?: number | false
}
4 changes: 1 addition & 3 deletions src/components/feedback/Toast/useToast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ const useToast = () => {
* @param {('success'|'info'|'warning'|'error')} variant The type of the toast
* @param {ToastOptions} options Additional options passed to the toast
*/
(message: ToastContent, variant?: ToastifyTypeOptions, { transitionType, autoClose, ...restOptions } = {} as ToastOptions) => {

(message: ToastContent, variant?: ToastifyTypeOptions, { transitionType, ...restOptions } = {} as ToastOptions) => {
const toastClasses = cx({
[classes[variant]]: variant,
[classes['default']]: true
Expand All @@ -41,7 +40,6 @@ const useToast = () => {

const options: ToastifyToastOptions = {
...restOptions,
autoClose: autoClose || false,
transition: getTransitionType(transitionType),
className: toastClasses
}
Expand Down

0 comments on commit f1909fc

Please sign in to comment.