Skip to content

Commit 48cd9d5

Browse files
committed
feat(overlay): created and exported the default timeout and classnames
1 parent 32bacc9 commit 48cd9d5

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

packages/overlay/src/Overlay.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
22
import React, { forwardRef, HTMLAttributes } from "react";
33
import cn from "classnames";
4-
import CSSTransition, {
5-
CSSTransitionClassNames,
6-
} from "react-transition-group/CSSTransition";
4+
import CSSTransition from "react-transition-group/CSSTransition";
75
import {
86
ConditionalPortal,
97
RenderConditionalPortalProps,
108
} from "@react-md/portal";
119
import { OverridableCSSTransitionProps } from "@react-md/transition";
1210
import { bem } from "@react-md/utils";
1311

12+
import {
13+
DEFAULT_OVERLAY_TIMEOUT,
14+
DEFAULT_OVERLAY_CLASSNAMES,
15+
} from "./constants";
16+
1417
export interface OverlayProps
1518
extends OverridableCSSTransitionProps,
1619
RenderConditionalPortalProps,
@@ -46,12 +49,6 @@ export interface OverlayProps
4649

4750
const block = bem("rmd-overlay");
4851

49-
const DEFAULT_OVERLAY_CLASSNAMES: CSSTransitionClassNames = {
50-
appearActive: "rmd-overlay--active",
51-
enterActive: "rmd-overlay--active",
52-
enterDone: "rmd-overlay--active",
53-
};
54-
5552
/**
5653
* The `Overlay` component is a simple component used to render a full page
5754
* overlay in the page with an enter and exit animation. If there are overflow
@@ -64,7 +61,8 @@ const Overlay = forwardRef<HTMLDivElement, OverlayProps>(function Overlay(
6461
visible,
6562
hidden = false,
6663
clickable = true,
67-
timeout = 150,
64+
timeout = DEFAULT_OVERLAY_TIMEOUT,
65+
classNames = DEFAULT_OVERLAY_CLASSNAMES,
6866
children,
6967
mountOnEnter = true,
7068
unmountOnExit = true,
@@ -78,7 +76,6 @@ const Overlay = forwardRef<HTMLDivElement, OverlayProps>(function Overlay(
7876
portal,
7977
portalInto,
8078
portalIntoId,
81-
classNames = DEFAULT_OVERLAY_CLASSNAMES,
8279
tabIndex = -1,
8380
...props
8481
},

packages/overlay/src/constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { CSSTransitionClassNames } from "react-transition-group/CSSTransition";
2+
import { TransitionTimeout } from "@react-md/transition";
3+
4+
export const DEFAULT_OVERLAY_TIMEOUT: TransitionTimeout = 150;
5+
export const DEFAULT_OVERLAY_CLASSNAMES: CSSTransitionClassNames = {
6+
appearActive: "rmd-overlay--active",
7+
enterActive: "rmd-overlay--active",
8+
enterDone: "rmd-overlay--active",
9+
};

packages/overlay/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export { default as Overlay } from "./Overlay";
22
export * from "./Overlay";
3+
4+
export * from "./constants";

0 commit comments

Comments
 (0)