UNPKG

zent

Version:

一套前端设计语言和基于React的实现

21 lines (20 loc) 1.14 kB
import { __assign, __rest } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import { useMemo } from 'react'; import cx from 'classnames'; import { Alert } from '../alert'; var BannerCloseIconColorMap = { grey: '#999', white: '#fff', }; export var Banner = function (_a) { var backgroundImage = _a.backgroundImage, closeIconColor = _a.closeIconColor, _b = _a.style, style = _b === void 0 ? {} : _b, className = _a.className, _c = _a.closable, closable = _c === void 0 ? true : _c, resetProps = __rest(_a, ["backgroundImage", "closeIconColor", "style", "className", "closable"]); var bannerStyle = useMemo(function () { if (!backgroundImage) return style; return __assign(__assign({}, style), { backgroundImage: "url(" + backgroundImage + ")" }); }, [style, backgroundImage]); var bannerClassName = cx('zent-banner', className); return (_jsx(Alert, __assign({}, resetProps, { closable: closable, icon: null, style: bannerStyle, className: bannerClassName, closeIconColor: BannerCloseIconColorMap[closeIconColor] || closeIconColor }), void 0)); }; export default Banner;