adwaita-web
Version:
A GTK inspired toolkit designed to build awesome web apps
48 lines (47 loc) • 1.12 kB
JavaScript
import cx from "clsx";
import React, { useState } from "react";
import { WindowClose } from "../icons";
import { Box } from "./Box";
import { Button } from "./Button";
function InfoBar({
className,
children,
closable,
activatable: activatableValue,
info,
success,
warning,
danger,
close: closeValue,
onClose,
...rest
}) {
const [closeState, setClose] = useState(false);
const close = closeValue ?? closeState;
const activatable = activatableValue ?? Boolean(rest.onClick);
return /* @__PURE__ */ React.createElement("div", {
className: cx("InfoBar", className, {
activatable,
info,
success,
warning,
danger,
close
}),
role: activatable ? "button" : void 0,
onTransitionEnd: onClose,
...rest
}, /* @__PURE__ */ React.createElement(Box, {
horizontal: true,
align: true,
fill: true
}, /* @__PURE__ */ React.createElement("span", {
className: "Box__fill"
}, children), closable && /* @__PURE__ */ React.createElement(Button, {
icon: WindowClose,
onClick: () => setClose(true)
})));
}
export {
InfoBar
};