@hitachivantara/uikit-react-core
Version:
UI Kit Core React components.
55 lines (54 loc) • 1.9 kB
JavaScript
import { useClasses } from "./Banner.styles.js";
import { HvBannerContent } from "./BannerContent/BannerContent.js";
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
import { forwardRef, useCallback } from "react";
import { jsx } from "react/jsx-runtime";
import Slide from "@mui/material/Slide";
import Snackbar from "@mui/material/Snackbar";
//#region src/Banner/Banner.tsx
/**
* A **Banner** shows an important message with optional actions. It appears below the top app bar and requires user dismissal.
*/
var HvBanner = forwardRef(function HvBanner(props, ref) {
const { classes: classesProp, className, title, open, onClose, anchorOrigin = "top", variant, transitionDuration = 300, transitionDirection = "down", container, showIcon, customIcon, actions, onAction, actionsPosition, label, offset = 60, bannerContentProps, size, ...others } = useDefaultProps("HvBanner", props);
const { classes, cx } = useClasses(classesProp);
const anchorOriginBanner = {
horizontal: "center",
vertical: anchorOrigin
};
const SlideTransition = useCallback((properties) => /* @__PURE__ */ jsx(Slide, {
...properties,
container,
direction: transitionDirection
}), [container, transitionDirection]);
return /* @__PURE__ */ jsx(Snackbar, {
ref,
open,
className,
classes: {
root: cx(classes.root, { [classes.rootClosed]: !open }),
anchorOriginTopCenter: classes.anchorOriginTopCenter,
anchorOriginBottomCenter: classes.anchorOriginBottomCenter
},
style: { [anchorOrigin]: offset },
anchorOrigin: anchorOriginBanner,
TransitionComponent: SlideTransition,
transitionDuration,
...others,
children: /* @__PURE__ */ jsx(HvBannerContent, {
title,
variant,
customIcon,
showIcon,
actions,
onAction,
actionsPosition,
onClose,
size,
...bannerContentProps,
children: label
})
});
});
//#endregion
export { HvBanner };