-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dashboard): suggestions from the pr #6718
- Loading branch information
Showing
11 changed files
with
863 additions
and
707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
apps/dashboard/src/components/primitives/sonner-helpers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ReactNode } from 'react'; | ||
import { ExternalToast, toast } from 'sonner'; | ||
import { SmallToast } from './sonner'; | ||
|
||
export const smallToast = ({ children, options }: { children: ReactNode; options: ExternalToast }) => { | ||
return toast(<SmallToast>{children}</SmallToast>, { | ||
duration: 5000, | ||
unstyled: true, | ||
...options, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useRef } from 'react'; | ||
|
||
export const useDataRef = <T>(data: T) => { | ||
const ref = useRef<T>(data); | ||
ref.current = data; | ||
|
||
return ref; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useCallback, useEffect } from 'react'; | ||
import debounce from 'lodash.debounce'; | ||
import { useDataRef } from './use-data-ref'; | ||
|
||
export const useDebounce = <Arguments = unknown | unknown[]>(callback: (args?: Arguments) => void, ms = 0) => { | ||
const callbackRef = useDataRef(callback); | ||
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
const debouncedCallback = useCallback(debounce(callbackRef.current, ms), [callbackRef, ms]); | ||
|
||
useEffect(() => debouncedCallback.cancel, [debouncedCallback.cancel]); | ||
|
||
return debouncedCallback; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.