Skip to content

Commit

Permalink
feat(alert): created and exported the default timeout and classnames
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Aug 20, 2020
1 parent 0bacc6e commit 32bacc9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
14 changes: 3 additions & 11 deletions packages/alert/src/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import CSSTransition from "react-transition-group/CSSTransition";
import { OverridableCSSTransitionProps } from "@react-md/transition";
import { bem } from "@react-md/utils";

import { DEFAULT_TOAST_CLASSNAMES, DEFAULT_TOAST_TIMEOUT } from "./constants";

export interface ToastProps
extends HTMLAttributes<HTMLDivElement>,
Omit<OverridableCSSTransitionProps, "mountOnEnter" | "unmountOnExit"> {
Expand Down Expand Up @@ -33,16 +35,6 @@ export interface ToastProps
}

const block = bem("rmd-toast");
const DEFAULT_TOAST_CLASSNAMES = {
appear: "rmd-toast--enter",
appearActive: "rmd-toast--enter-active",
enter: "rmd-toast--enter",
enterActive: "rmd-toast--enter-active",
enterDone: "",
exit: "rmd-toast--exit",
exitActive: "rmd-toast--exit-active",
exitDone: "",
};

/**
* This is a very low-level component that can be used to animate a new toast in
Expand All @@ -62,7 +54,7 @@ const Toast = forwardRef<HTMLDivElement, ToastProps>(function Toast(
onExit,
onExiting,
onExited,
timeout = 150,
timeout = DEFAULT_TOAST_TIMEOUT,
classNames = DEFAULT_TOAST_CLASSNAMES,
action = null,
stacked = false,
Expand Down
12 changes: 12 additions & 0 deletions packages/alert/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { CSSTransitionClassNames } from "react-transition-group/CSSTransition";
import { TransitionTimeout } from "@react-md/transition";

export const DEFAULT_TOAST_TIMEOUT: TransitionTimeout = 150;
export const DEFAULT_TOAST_CLASSNAMES: CSSTransitionClassNames = {
appear: "rmd-toast--enter",
appearActive: "rmd-toast--enter-active",
enter: "rmd-toast--enter",
enterActive: "rmd-toast--enter-active",
exit: "rmd-toast--exit",
exitActive: "rmd-toast--exit-active",
};
1 change: 1 addition & 0 deletions packages/alert/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export { default as MessageQueue } from "./MessageQueue";
export * from "./MessageQueue";

export * from "./MessageQueueContext";
export * from "./constants";

0 comments on commit 32bacc9

Please sign in to comment.