Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] V10 #968

Merged
merged 74 commits into from
Jan 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
94a36ff
9.1.3
fkhadra May 14, 2023
01aec2d
move playground to vite
fkhadra May 28, 2023
c05b833
setup component testing
fkhadra May 28, 2023
4baf4d4
import stylesheet in test
fkhadra May 28, 2023
3bbd87b
WIP rewrite tests
fkhadra May 29, 2023
4c7eb9b
ignore cypress video
fkhadra Jun 1, 2023
916d60d
Add toast tests
fkhadra Jun 1, 2023
f938ee8
rewrite toast tests
fkhadra Jun 4, 2023
b6c7c5b
remove default props
fkhadra Jun 10, 2023
dfe2250
export default props
fkhadra Jun 11, 2023
6c6a968
[WIP] rewrite toast tests
fkhadra Jun 11, 2023
b42e1a4
drop synthetic event to start timer
fkhadra Jun 12, 2023
a068110
formatting
fkhadra Jun 12, 2023
e9b09c4
remove unused import
fkhadra Jun 12, 2023
0a597a6
WIP
fkhadra Jun 16, 2023
b5e46f6
core fully tested
fkhadra Jun 17, 2023
c79df9c
playground: add some containers with limit
fkhadra Jun 17, 2023
932ce37
feat: initial implementation without event manager
fkhadra Jun 17, 2023
cb9dbb2
update workflow
fkhadra Jun 17, 2023
ec376f4
drop displayed toast count
fkhadra Jun 17, 2023
56861bf
skip addons for now
fkhadra Jun 17, 2023
423b70e
add build config to ease work with addons
fkhadra Jun 17, 2023
76d30a3
chore: run tests wit chrome
fkhadra Jun 18, 2023
ef396b5
migrate notification center
fkhadra Jun 18, 2023
3a3ff4a
remove jest and reenable addons
fkhadra Jun 18, 2023
517d5d7
exclude types from coverage
fkhadra Jun 18, 2023
207578e
drop unused style
fkhadra Jun 19, 2023
3a049cb
drop position and type constant
fkhadra Jun 19, 2023
cb6d988
tweak shadow and animation duration
fkhadra Jun 19, 2023
841bbf0
update playground
fkhadra Jun 19, 2023
66a968f
fix newestOnTop
fkhadra Jun 20, 2023
b6f081f
remove container id var
fkhadra Jun 23, 2023
bcd94e7
rewrite store
fkhadra Jun 23, 2023
68b81a1
refactor container observer
fkhadra Jun 23, 2023
eb17a31
[WIP] feat: play pause toast
fkhadra Jun 23, 2023
62b486f
export decorate func #979
fkhadra Jul 1, 2023
4665865
fix typos
fkhadra Jul 2, 2023
c386141
review draggable logic
fkhadra Jul 9, 2023
628347b
update defaults
fkhadra Jul 9, 2023
fa7e6b1
remove closeOnClick from default props
fkhadra Jul 9, 2023
8085770
add stacked notifications
fkhadra Aug 1, 2023
70fcee0
support drag for stacked container
fkhadra Aug 3, 2023
d14c523
clean effect
fkhadra Aug 4, 2023
147e6ac
handle progress for stacked notification
fkhadra Aug 4, 2023
ad4ba7b
fix progress
fkhadra Aug 4, 2023
1ce1119
skip hidden folders
fkhadra Aug 4, 2023
ad5c93a
fix tests
fkhadra Aug 5, 2023
a42e9f3
fix overflow
fkhadra Sep 3, 2023
c1ecc4e
fix issue #1011
fkhadra Oct 31, 2023
fb8744b
use sync external store shim
fkhadra Oct 31, 2023
a2e1942
export map #1002
fkhadra Nov 1, 2023
6e74a0c
add stacked container tests
fkhadra Nov 3, 2023
8b8644f
improve typescript support
fkhadra Nov 3, 2023
21dd642
reenable test
fkhadra Nov 3, 2023
054a6a9
cleanup playground
fkhadra Nov 3, 2023
a9d3256
update usages
fkhadra Nov 3, 2023
53f8a73
add isLoading to icon #1003
fkhadra Nov 3, 2023
e428326
update props instead of overriding
fkhadra Nov 25, 2023
50f76d0
upload artifact for test
fkhadra Nov 26, 2023
673990c
hack test
fkhadra Nov 26, 2023
14ff114
try hard
fkhadra Nov 26, 2023
deb09a8
progress bar background
kifrud Dec 4, 2023
89390ec
tweak progress bar
fkhadra Dec 6, 2023
4c5397c
drop react 17 support
fkhadra Dec 6, 2023
f060d34
bump deps
fkhadra Dec 7, 2023
7633800
update workflow
fkhadra Dec 7, 2023
18df567
fix path
fkhadra Dec 7, 2023
de26fee
bump action
fkhadra Dec 7, 2023
de177a2
update progress bar opacity
fkhadra Dec 7, 2023
568fa60
handle both object and primitive
fkhadra Dec 17, 2023
0edcf87
refactor expression
fkhadra Dec 17, 2023
172bcc5
update readme
fkhadra Dec 20, 2023
bcde4ab
update readme
fkhadra Jan 8, 2024
cbc7109
bump dependencies
fkhadra Jan 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update usages
fkhadra committed Nov 3, 2023
commit a9d3256320ee66b48df4843fe8bccc117a3d7857
128 changes: 124 additions & 4 deletions src/core/toast.ts
Original file line number Diff line number Diff line change
@@ -30,8 +30,7 @@ function getToastId<TData>(options?: ToastOptions<TData>) {
}

/**
* If the container is not mounted, the toast is enqueued and
* the container lazy mounted
* If the container is not mounted, the toast is enqueued
*/
function dispatchToast<TData>(
content: ToastContent<TData>,
@@ -232,6 +231,26 @@ function dismiss(params?: Id | RemoveParams) {

/**
* Remove toast programmatically
*
* - Remove all toasts:
* ```
* toast.dismiss()
* ```
*
* - Remove all toasts that belongs to a given container
* ```
* toast.dismiss({ container: "123" })
* ```
*
* - Remove toast that has a given id regardless the container
* ```
* toast.dismiss({ id: "123" })
* ```
*
* - Remove toast that has a given id for a specific container
* ```
* toast.dismiss({ id: "123", containerId: "12" })
* ```
*/
toast.dismiss = dismiss;

@@ -241,10 +260,49 @@ toast.dismiss = dismiss;
toast.clearWaitingQueue = clearWaitingQueue;

/**
* return true if one container is displaying the toast
* Check if a toast is active
*
* - Check regardless the container
* ```
* toast.isActive("123")
* ```
*
* - Check in a specific container
* ```
* toast.isActive("123", "containerId")
* ```
*/
toast.isActive = isToastActive;

/**
* Update a toast, see https://fkhadra.github.io/react-toastify/update-toast/ for more
*
* Example:
* ```
* // With a string
* toast.update(toastId, {
* render: "New content",
* type: "info",
* });
*
* // Or with a component
* toast.update(toastId, {
* render: MyComponent
* });
*
* // Or a function
* toast.update(toastId, {
* render: () => <div>New content</div>
* });
*
* // Apply a transition
* toast.update(toastId, {
* render: "New Content",
* type: toast.TYPE.INFO,
* transition: Rotate
* })
* ```
*/
toast.update = <TData = unknown>(
toastId: Id,
options: UpdateOptions<TData> = {}
@@ -272,7 +330,18 @@ toast.update = <TData = unknown>(
};

/**
* Used for controlled progress bar.
* Used for controlled progress bar. It will automatically close the notification.
*
* If you don't want your notification to be clsoed when the timer is done you should use `toast.update` instead as follow instead:
*
* ```
* toast.update(id, {
* progress: null, // remove controlled progress bar
* render: "ok",
* type: "success",
* autoClose: 5000 // set autoClose to the desired value
* });
* ```
*/
toast.done = (id: Id) => {
toast.update(id, {
@@ -302,7 +371,58 @@ toast.done = (id: Id) => {
*/
toast.onChange = onChange;

/**
* Play a toast(s) timer progammatically
*
* Usage:
*
* - Play all toasts
* ```
* toast.play()
* ```
*
* - Play all toasts for a given container
* ```
* toast.play({ containerId: "123" })
* ```
*
* - Play toast that has a given id regardless the container
* ```
* toast.play({ id: "123" })
* ```
*
* - Play toast that has a given id for a specific container
* ```
* toast.play({ id: "123", containerId: "12" })
* ```
*/
toast.play = (opts?: IdOpts) => toggleToast(true, opts);

/**
* Pause a toast(s) timer progammatically
*
* Usage:
*
* - Pause all toasts
* ```
* toast.pause()
* ```
*
* - Pause all toasts for a given container
* ```
* toast.pause({ containerId: "123" })
* ```
*
* - Pause toast that has a given id regardless the container
* ```
* toast.pause({ id: "123" })
* ```
*
* - Pause toast that has a given id for a specific container
* ```
* toast.pause({ id: "123", containerId: "12" })
* ```
*/
toast.pause = (opts?: IdOpts) => toggleToast(false, opts);

export { toast };
1 change: 0 additions & 1 deletion src/hooks/useToastContainer.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ export function useToastContainer(props: ToastContainerProps) {
);
const snapshot = useSyncExternalStore(subscribe, getSnapshot);

// TODO: extract when idea are clear
function getToastToRender<T>(
cb: (position: ToastPosition, toastList: Toast[]) => T
) {
7 changes: 5 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -128,13 +128,13 @@ interface CommonOptions {
hideProgressBar?: boolean;

/**
* Pass a custom transition built with react-transition-group.
* Pass a custom transition see https://fkhadra.github.io/react-toastify/custom-animation/
*/
transition?: ToastTransition;

/**
* Allow toast to be draggable
* `Default: true`
* `Default: 'touch'`
*/
draggable?: boolean | 'mouse' | 'touch';

@@ -257,6 +257,9 @@ export interface ToastContainerProps extends CommonOptions {
*/
className?: ToastClassName;

/**
* Will stack the toast with the newest on the top.
*/
stacked?: boolean;

/**