UNPKG

@react-md/app-bar

Version:

This small package implments the AppBar spec in material design.

123 lines 5.76 kB
"use strict"; 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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; 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 react_1 = __importStar(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 (react_1.default.createElement(useInheritContext_1.ParentContext.Provider, { value: true }, react_1.default.createElement(useInheritContext_1.InheritContext.Provider, { value: inherit }, react_1.default.createElement(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)))); }); /* istanbul ignore next */ if (process.env.NODE_ENV !== "production") { try { var PropTypes = require("prop-types"); exports.AppBar.propTypes = { className: PropTypes.string, component: PropTypes.oneOfType([ PropTypes.string, PropTypes.func, PropTypes.object, ]), height: PropTypes.oneOf([ "none", "normal", "dense", "prominent", "prominent-dense", ]), flexWrap: PropTypes.bool, children: PropTypes.node, fixed: PropTypes.bool, fixedPosition: PropTypes.oneOf(["top", "bottom"]), fixedElevation: PropTypes.bool, inheritColor: PropTypes.bool, theme: PropTypes.oneOf(["primary", "secondary", "default", "clear"]), }; } catch (e) { } } //# sourceMappingURL=AppBar.js.map