UNPKG

@atlaskit/page-layout

Version:

A collection of components which let you compose an application's page layout.

69 lines (67 loc) 2.74 kB
import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; /** * @jsxRuntime classic * @jsx jsx */ import { useEffect } from 'react'; // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766 import { css, jsx } from '@emotion/react'; import { DEFAULT_RIGHT_PANEL_WIDTH, RIGHT_PANEL, RIGHT_PANEL_WIDTH, VAR_RIGHT_PANEL_WIDTH } from '../../common/constants'; import { getPageLayoutSlotSelector, resolveDimension } from '../../common/utils'; import { publishGridState, useSkipLink } from '../../controllers'; import SlotFocusRing from './internal/slot-focus-ring'; import SlotDimensions from './slot-dimensions'; var baseStyles = 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: RIGHT_PANEL }); var fixedStyles = 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: 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 ? DEFAULT_RIGHT_PANEL_WIDTH : _props$width, shouldPersistWidth = props.shouldPersistWidth, testId = props.testId, id = props.id, skipLinkTitle = props.skipLinkTitle; var rightPanelWidth = resolveDimension(VAR_RIGHT_PANEL_WIDTH, width, shouldPersistWidth); useEffect(function () { publishGridState(_defineProperty({}, VAR_RIGHT_PANEL_WIDTH, rightPanelWidth)); return function () { publishGridState(_defineProperty({}, VAR_RIGHT_PANEL_WIDTH, 0)); }; }, [rightPanelWidth]); useSkipLink(id, skipLinkTitle); return jsx(SlotFocusRing, null, function (_ref) { var className = _ref.className; return jsx("div", _extends({ 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 }, getPageLayoutSlotSelector('right-panel')), jsx(SlotDimensions, { variableName: VAR_RIGHT_PANEL_WIDTH, value: rightPanelWidth }), children); }); }; export default RightPanel;