UNPKG

@atlaskit/navigation-system

Version:

Page layout and navigation components for Atlassian apps.

89 lines (87 loc) • 6.52 kB
/* panel-layout-shell.tsx generated by @compiled/babel-plugin v3.0.4 */ import _defineProperty from "@babel/runtime/helpers/defineProperty"; import "./panel-layout-shell.compiled.css"; import * as React from 'react'; import { ax, ix } from "@compiled/react/runtime"; import { useContext, useId } from 'react'; import { fg } from '@atlaskit/platform-feature-flags/fg'; import { MainMinWidthContext } from './main-min-width-context'; // The grid uses runtime CSS variables and container sizing outside @atlaskit/css's bounded values. var localPanelTrackWidthVar = '--p_lclPnlTrackW'; var localPanelResizingVar = '--p_lclPnlRsz'; var localPanelMinWidthVar = '--p_lclPnlMinW'; // One CSS animation holds both the grid and its surface placement until the layout snap. // Identical keyframes keep the layout static; normal styles take over at 60ms. var holdPanelTrack = null; var styles = { container: "_1f38177r _7cca15wb _4t3i1osq _1bsb1osq", layout: "_1reo1wug _18m91wug _1e0c11p5 _1lmc1m6a _yv0ei47z _2z05hkll _4t3i1osq _1bsb1osq", mainContent: "_nd5l1gzg _1reo1wug _18m91wug _1e0c1txw _4t3i1osq _19121cl4", panelUplift: "_1reo15vq _18m915vq _bfhkvuon", unmeasured: "_evra4a59 _1lmcc53r _yv0eggl6", unmeasuredWidths: "_129o1uuk _cw8k1fc5 _peezi77x _1tg31owj _1qxn1ykh _13bt1t8m", managedInline: "_1uwq15vq _82e815vq _f8374a59 _1l7c1wug _vleg1orf", managedOverlay: "_1uwq15vq _82e815vq _f8371m6a _vlegi47z _1l7chkll", entering: "_1cro60m4 _wqfno73m", chatMotion: "_1uwq15vq _82e815vq _h62jewfl _1duvewfl", panelClosed: "_f8371m6a _vlegi47z _1l7chkll" }; /** * Grid and scrolling for Main and its local panel. Use inside navigation's Root and Main. */ export function PanelLayoutShell(_ref) { var children = _ref.children, panel = _ref.panel, isPanelOpen = _ref.isPanelOpen, panelWidth = _ref.panelWidth, compactPanelWidth = _ref.compactPanelWidth, xlPanelWidth = _ref.xlPanelWidth, xlDefaultPanelWidth = _ref.xlDefaultPanelWidth, defaultPanelWidth = _ref.defaultPanelWidth, compactDefaultPanelWidth = _ref.compactDefaultPanelWidth, _ref$panelMinWidth = _ref.panelMinWidth, panelMinWidth = _ref$panelMinWidth === void 0 ? 320 : _ref$panelMinWidth, mode = _ref.mode, layoutRef = _ref.layoutRef, _ref$isMotionEnabled = _ref.isMotionEnabled, isMotionEnabled = _ref$isMotionEnabled === void 0 ? false : _ref$isMotionEnabled, testId = _ref.testId; var mainMinWidth = useContext(MainMinWidthContext); var id = "local-panel-".concat(useId().replace(/[^a-zA-Z0-9_-]/g, '_')); // CSS query conditions cannot read custom properties. Only the numeric minimums and // instance selector are generated here; this rule is removed after the first measurement, // so live resizing never rewrites stylesheet text. The named container is local to this shell. // Scope each query to its own following grid. Hydration can retain the server's ID // while subsequent renders use a different client ID. Include both minimums so // layouts with different query conditions cannot apply their rules to each other. // Encode punctuation to keep the CSS attribute selector unquoted (React 18 escapes // quotes in server-rendered style text). var queryKey = "m".concat(mainMinWidth, "p").concat(panelMinWidth).replace(/[^a-zA-Z0-9_-]/g, function (character) { return "_".concat(character.charCodeAt(0), "_"); }); var useSiblingSelector = fg('platform-dst-chat-panel-layout'); var inlineSelector = useSiblingSelector ? "style[data-panel-layout-query=".concat(queryKey, "] + div") : "#".concat(id); var inlineQuery = "@container local-panel-layout (min-width: ".concat(mainMinWidth + panelMinWidth, "px)"); return /*#__PURE__*/React.createElement("div", { className: ax([styles.container]) }, mode === undefined && isMotionEnabled && fg('platform-dst-chat-panel-layout') && /*#__PURE__*/ // Keep the inline motion cap available during exit, after the open-only track rule is removed. // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles -- Instance-scoped query matches the SSR inline allocation, including caller-defined minimums. React.createElement("style", { "data-panel-layout-motion-query": queryKey }, "".concat(inlineQuery, " {\n\t\t\t\t\tstyle[data-panel-layout-motion-query=").concat(queryKey, "] ~ div { --p_lclPnlMotionMaxW: calc(100cqw - ").concat(mainMinWidth, "px); }\n\t\t\t\t}")), mode === undefined && isPanelOpen && /*#__PURE__*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles -- Instance-scoped SSR query supports caller-defined minimums; CSS variables are not allowed in query conditions. React.createElement("style", { "data-panel-layout-query": useSiblingSelector ? queryKey : undefined }, "".concat(inlineQuery, " {\n\t\t\t\t\t").concat(inlineSelector, " {\n\t\t\t\t\t\t--p_lclPnlSsrAreas: var(--p_lclPnlSsrInlineAreas);\n\t\t\t\t\t\t--p_lclPnlSsrColumns: minmax(0, 1fr) min(var(--p_lclPnlSsrPreferredW), calc(100% - ").concat(mainMinWidth, "px));\n\t\t\t\t\t\t--p_lclPnlSsrArea: panel;\n\t\t\t\t\t\t--p_lclPnlSsrWidth: 100%;\n\t\t\t\t\t\t--p_lclPnlSsrBackground: ", "var(--ds-surface, #FFFFFF)", ";\n\t\t\t\t\t\t--p_lclPnlSsrShadow: none;\n\t\t\t\t\t\t--p_lclPnlSsrBorder: ", "var(--ds-border-width, 1px)", " solid ", "var(--ds-border, #0B120E24)", ";\n\t\t\t\t\t}\n\t\t\t\t}")), /*#__PURE__*/React.createElement("div", { id: id, "data-testid": testId, ref: layoutRef, style: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, localPanelTrackWidthVar, "".concat(panelWidth, "px")), localPanelMinWidthVar, "".concat(panelMinWidth, "px")), '--p_lclPnlCompactW', "".concat(compactPanelWidth, "px")), '--p_lclPnlXlW', "".concat(xlPanelWidth, "px")), '--p_lclPnlXlDefaultW', "".concat(xlDefaultPanelWidth, "px")), '--p_lclPnlDefaultW', "".concat(defaultPanelWidth, "px")), '--p_lclPnlCompactDefaultW', "".concat(compactDefaultPanelWidth, "px")), className: ax([styles.layout, mode === undefined && styles.unmeasuredWidths, mode === undefined && isPanelOpen && styles.unmeasured, isMotionEnabled && styles.panelUplift, mode === 'inline' && styles.managedInline, mode === 'overlay' && styles.managedOverlay, !isPanelOpen && styles.panelClosed, isPanelOpen && isMotionEnabled && styles.entering, isMotionEnabled && styles.chatMotion]) }, /*#__PURE__*/React.createElement("div", { className: ax([styles.mainContent]) }, children), panel)); }