@react-md/app-bar
Version:
This small package implments the AppBar spec in material design.
74 lines • 4.01 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppBar = void 0;
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var classnames_1 = __importDefault(require("classnames"));
var utils_1 = require("@react-md/utils");
var useInheritContext_1 = require("./useInheritContext");
var block = (0, utils_1.bem)("rmd-app-bar");
/**
* This component is used to create a top-level app bar in your application that
* can be used to contain a navigation menu toggle button, the app's logo and/or
* title, as well as any top-level actions that will be reused throughout your
* app. When using this component with the `fixed` prop, it is recommended to
* also use one of the "offset class names" so that your content will not be
* converted by the app bar. You can also use any of the exposed mixins to add
* these offsets as well.
*/
exports.AppBar = (0, react_1.forwardRef)(function AppBar(_a, ref) {
var _b;
var className = _a.className, children = _a.children, _c = _a.theme, propTheme = _c === void 0 ? "primary" : _c, _d = _a.component, propComponent = _d === void 0 ? "header" : _d, _e = _a.height, height = _e === void 0 ? "normal" : _e, _f = _a.fixed, fixed = _f === void 0 ? false : _f, _g = _a.fixedPosition, fixedPosition = _g === void 0 ? "top" : _g, _h = _a.fixedElevation, fixedElevation = _h === void 0 ? true : _h, inheritColor = _a.inheritColor, _j = _a.flexWrap, flexWrap = _j === void 0 ? height === "none" ||
height === "prominent" ||
height === "prominent-dense" : _j, remaining = __rest(_a, ["className", "children", "theme", "component", "height", "fixed", "fixedPosition", "fixedElevation", "inheritColor", "flexWrap"]);
var parentContext = (0, useInheritContext_1.useParentContext)();
var inheritContext = (0, useInheritContext_1.useInheritContext)(undefined);
var inherit;
var theme = propTheme;
var Component = propComponent;
if (typeof inheritColor === "boolean") {
inherit = inheritColor;
}
else if (parentContext) {
inherit = inheritContext;
theme = "clear";
Component = "div";
}
else {
inherit = theme !== "clear" && theme !== "default";
}
return ((0, jsx_runtime_1.jsx)(useInheritContext_1.ParentContext.Provider, __assign({ value: true }, { children: (0, jsx_runtime_1.jsx)(useInheritContext_1.InheritContext.Provider, __assign({ value: inherit }, { children: (0, jsx_runtime_1.jsx)(Component, __assign({}, remaining, { className: (0, classnames_1.default)(block((_b = {},
_b[theme] = theme !== "clear",
_b[height] = height !== "none",
_b.wrap = flexWrap,
_b.fixed = fixed,
_b[fixedPosition] = fixed,
_b["fixed-elevation"] = fixed && fixedElevation,
_b)), className), ref: ref }, { children: children })) })) })));
});
//# sourceMappingURL=AppBar.js.map