Skip to content

Commit 32bacc9

Browse files
committed
feat(alert): created and exported the default timeout and classnames
1 parent 0bacc6e commit 32bacc9

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

packages/alert/src/Toast.tsx

+3-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import CSSTransition from "react-transition-group/CSSTransition";
44
import { OverridableCSSTransitionProps } from "@react-md/transition";
55
import { bem } from "@react-md/utils";
66

7+
import { DEFAULT_TOAST_CLASSNAMES, DEFAULT_TOAST_TIMEOUT } from "./constants";
8+
79
export interface ToastProps
810
extends HTMLAttributes<HTMLDivElement>,
911
Omit<OverridableCSSTransitionProps, "mountOnEnter" | "unmountOnExit"> {
@@ -33,16 +35,6 @@ export interface ToastProps
3335
}
3436

3537
const block = bem("rmd-toast");
36-
const DEFAULT_TOAST_CLASSNAMES = {
37-
appear: "rmd-toast--enter",
38-
appearActive: "rmd-toast--enter-active",
39-
enter: "rmd-toast--enter",
40-
enterActive: "rmd-toast--enter-active",
41-
enterDone: "",
42-
exit: "rmd-toast--exit",
43-
exitActive: "rmd-toast--exit-active",
44-
exitDone: "",
45-
};
4638

4739
/**
4840
* This is a very low-level component that can be used to animate a new toast in
@@ -62,7 +54,7 @@ const Toast = forwardRef<HTMLDivElement, ToastProps>(function Toast(
6254
onExit,
6355
onExiting,
6456
onExited,
65-
timeout = 150,
57+
timeout = DEFAULT_TOAST_TIMEOUT,
6658
classNames = DEFAULT_TOAST_CLASSNAMES,
6759
action = null,
6860
stacked = false,

packages/alert/src/constants.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { CSSTransitionClassNames } from "react-transition-group/CSSTransition";
2+
import { TransitionTimeout } from "@react-md/transition";
3+
4+
export const DEFAULT_TOAST_TIMEOUT: TransitionTimeout = 150;
5+
export const DEFAULT_TOAST_CLASSNAMES: CSSTransitionClassNames = {
6+
appear: "rmd-toast--enter",
7+
appearActive: "rmd-toast--enter-active",
8+
enter: "rmd-toast--enter",
9+
enterActive: "rmd-toast--enter-active",
10+
exit: "rmd-toast--exit",
11+
exitActive: "rmd-toast--exit-active",
12+
};

packages/alert/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export { default as MessageQueue } from "./MessageQueue";
88
export * from "./MessageQueue";
99

1010
export * from "./MessageQueueContext";
11+
export * from "./constants";

0 commit comments

Comments
 (0)