@atlaskit/page-layout
Version:
A collection of components which let you compose an application's page layout.
77 lines (73 loc) • 3.23 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = require("react");
var _react2 = require("@emotion/react");
var _constants = require("../../common/constants");
var _utils = require("../../common/utils");
var _controllers = require("../../controllers");
var _slotFocusRing = _interopRequireDefault(require("./internal/slot-focus-ring"));
var _slotDimensions = _interopRequireDefault(require("./slot-dimensions"));
/**
* @jsxRuntime classic
* @jsx jsx
*/
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
var baseStyles = (0, _react2.css)({
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
gridArea: _constants.RIGHT_PANEL
});
var fixedStyles = (0, _react2.css)({
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
width: _constants.RIGHT_PANEL_WIDTH,
position: 'fixed',
insetBlockEnd: 0,
insetBlockStart: 0,
insetInlineEnd: 0
});
/**
* __Right panel__
*
* Provides a slot for a right panel within the PageLayout.
*
* - [Examples](https://atlassian.design/components/page-layout/examples)
* - [Code](https://atlassian.design/components/page-layout/code)
*/
var RightPanel = function RightPanel(props) {
var children = props.children,
isFixed = props.isFixed,
_props$width = props.width,
width = _props$width === void 0 ? _constants.DEFAULT_RIGHT_PANEL_WIDTH : _props$width,
shouldPersistWidth = props.shouldPersistWidth,
testId = props.testId,
id = props.id,
skipLinkTitle = props.skipLinkTitle;
var rightPanelWidth = (0, _utils.resolveDimension)(_constants.VAR_RIGHT_PANEL_WIDTH, width, shouldPersistWidth);
(0, _react.useEffect)(function () {
(0, _controllers.publishGridState)((0, _defineProperty2.default)({}, _constants.VAR_RIGHT_PANEL_WIDTH, rightPanelWidth));
return function () {
(0, _controllers.publishGridState)((0, _defineProperty2.default)({}, _constants.VAR_RIGHT_PANEL_WIDTH, 0));
};
}, [rightPanelWidth]);
(0, _controllers.useSkipLink)(id, skipLinkTitle);
return (0, _react2.jsx)(_slotFocusRing.default, null, function (_ref) {
var className = _ref.className;
return (0, _react2.jsx)("div", (0, _extends2.default)({
css: [baseStyles, isFixed && fixedStyles]
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
,
className: className,
"data-testid": testId,
id: id
}, (0, _utils.getPageLayoutSlotSelector)('right-panel')), (0, _react2.jsx)(_slotDimensions.default, {
variableName: _constants.VAR_RIGHT_PANEL_WIDTH,
value: rightPanelWidth
}), children);
});
};
var _default = exports.default = RightPanel;