@atlaskit/page-layout 1.0.7 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +3 -3
  3. package/__perf__/utils/perf-example.tsx +27 -18
  4. package/__perf__/utils/product-integration/Create.tsx +5 -1
  5. package/__perf__/utils/product-integration/NotificationsPopup.tsx +6 -5
  6. package/__perf__/utils/product-integration/SampleFooter.tsx +14 -13
  7. package/dist/cjs/common/hooks/index.js +23 -0
  8. package/dist/cjs/common/hooks/use-is-sidebar-collapsing.js +46 -0
  9. package/dist/cjs/common/hooks/use-is-sidebar-dragging.js +46 -0
  10. package/dist/cjs/components/resize-control/grab-area.js +42 -4
  11. package/dist/cjs/components/resize-control/index.js +22 -20
  12. package/dist/cjs/components/resize-control/resize-button.js +59 -4
  13. package/dist/cjs/components/resize-control/shadow.js +48 -0
  14. package/dist/cjs/components/skip-links/skip-link-components.js +49 -5
  15. package/dist/cjs/components/slots/banner.js +27 -11
  16. package/dist/cjs/components/slots/content.js +9 -2
  17. package/dist/cjs/components/slots/internal/left-sidebar-inner.js +65 -0
  18. package/dist/cjs/components/slots/internal/left-sidebar-outer.js +100 -0
  19. package/dist/cjs/components/slots/internal/resizable-children-wrapper.js +63 -0
  20. package/dist/cjs/components/slots/internal/slot-focus-ring.js +61 -0
  21. package/dist/cjs/components/slots/left-panel.js +26 -11
  22. package/dist/cjs/components/slots/left-sidebar-without-resize.js +10 -10
  23. package/dist/cjs/components/slots/left-sidebar.js +21 -16
  24. package/dist/cjs/components/slots/main.js +53 -6
  25. package/dist/cjs/components/slots/page-layout.js +10 -3
  26. package/dist/cjs/components/slots/right-panel.js +26 -11
  27. package/dist/cjs/components/slots/right-sidebar.js +57 -13
  28. package/dist/cjs/components/slots/top-navigation.js +27 -11
  29. package/dist/cjs/controllers/sidebar-resize-context.js +2 -1
  30. package/dist/cjs/controllers/sidebar-resize-controller.js +10 -5
  31. package/dist/cjs/version.json +1 -1
  32. package/dist/es2019/common/hooks/index.js +2 -0
  33. package/dist/es2019/common/hooks/use-is-sidebar-collapsing.js +29 -0
  34. package/dist/es2019/common/hooks/use-is-sidebar-dragging.js +29 -0
  35. package/dist/es2019/components/resize-control/grab-area.js +46 -4
  36. package/dist/es2019/components/resize-control/index.js +12 -9
  37. package/dist/es2019/components/resize-control/resize-button.js +61 -4
  38. package/dist/es2019/components/resize-control/shadow.js +43 -0
  39. package/dist/es2019/components/skip-links/skip-link-components.js +47 -5
  40. package/dist/es2019/components/slots/banner.js +21 -7
  41. package/dist/es2019/components/slots/content.js +8 -2
  42. package/dist/es2019/components/slots/internal/left-sidebar-inner.js +52 -0
  43. package/dist/es2019/components/slots/internal/left-sidebar-outer.js +79 -0
  44. package/dist/es2019/components/slots/internal/resizable-children-wrapper.js +49 -0
  45. package/dist/es2019/components/slots/internal/slot-focus-ring.js +50 -0
  46. package/dist/es2019/components/slots/left-panel.js +20 -7
  47. package/dist/es2019/components/slots/left-sidebar-without-resize.js +10 -11
  48. package/dist/es2019/components/slots/left-sidebar.js +20 -17
  49. package/dist/es2019/components/slots/main.js +46 -6
  50. package/dist/es2019/components/slots/page-layout.js +15 -3
  51. package/dist/es2019/components/slots/right-panel.js +20 -7
  52. package/dist/es2019/components/slots/right-sidebar.js +50 -8
  53. package/dist/es2019/components/slots/top-navigation.js +21 -7
  54. package/dist/es2019/controllers/sidebar-resize-context.js +2 -1
  55. package/dist/es2019/controllers/sidebar-resize-controller.js +10 -5
  56. package/dist/es2019/version.json +1 -1
  57. package/dist/esm/common/hooks/index.js +2 -0
  58. package/dist/esm/common/hooks/use-is-sidebar-collapsing.js +34 -0
  59. package/dist/esm/common/hooks/use-is-sidebar-dragging.js +34 -0
  60. package/dist/esm/components/resize-control/grab-area.js +42 -4
  61. package/dist/esm/components/resize-control/index.js +23 -20
  62. package/dist/esm/components/resize-control/resize-button.js +57 -4
  63. package/dist/esm/components/resize-control/shadow.js +37 -0
  64. package/dist/esm/components/skip-links/skip-link-components.js +47 -5
  65. package/dist/esm/components/slots/banner.js +27 -12
  66. package/dist/esm/components/slots/content.js +8 -2
  67. package/dist/esm/components/slots/internal/left-sidebar-inner.js +53 -0
  68. package/dist/esm/components/slots/internal/left-sidebar-outer.js +82 -0
  69. package/dist/esm/components/slots/internal/resizable-children-wrapper.js +51 -0
  70. package/dist/esm/components/slots/internal/slot-focus-ring.js +51 -0
  71. package/dist/esm/components/slots/left-panel.js +26 -12
  72. package/dist/esm/components/slots/left-sidebar-without-resize.js +10 -10
  73. package/dist/esm/components/slots/left-sidebar.js +20 -16
  74. package/dist/esm/components/slots/main.js +49 -8
  75. package/dist/esm/components/slots/page-layout.js +12 -3
  76. package/dist/esm/components/slots/right-panel.js +26 -12
  77. package/dist/esm/components/slots/right-sidebar.js +57 -14
  78. package/dist/esm/components/slots/top-navigation.js +27 -12
  79. package/dist/esm/controllers/sidebar-resize-context.js +2 -1
  80. package/dist/esm/controllers/sidebar-resize-controller.js +10 -5
  81. package/dist/esm/version.json +1 -1
  82. package/dist/types/common/hooks/index.d.ts +2 -0
  83. package/dist/types/common/hooks/use-is-sidebar-collapsing.d.ts +2 -0
  84. package/dist/types/common/hooks/use-is-sidebar-dragging.d.ts +2 -0
  85. package/dist/types/components/resize-control/shadow.d.ts +6 -0
  86. package/dist/types/components/slots/internal/left-sidebar-inner.d.ts +9 -0
  87. package/dist/types/components/slots/internal/left-sidebar-outer.d.ts +13 -0
  88. package/dist/types/components/slots/internal/resizable-children-wrapper.d.ts +10 -0
  89. package/dist/types/components/slots/internal/slot-focus-ring.d.ts +19 -0
  90. package/dist/types/controllers/sidebar-resize-context.d.ts +1 -0
  91. package/package.json +14 -9
  92. package/dist/cjs/components/resize-control/styles.js +0 -156
  93. package/dist/cjs/components/skip-links/styles.js +0 -58
  94. package/dist/cjs/components/slots/left-sidebar-styles.js +0 -116
  95. package/dist/cjs/components/slots/styles.js +0 -154
  96. package/dist/es2019/components/resize-control/styles.js +0 -136
  97. package/dist/es2019/components/skip-links/styles.js +0 -41
  98. package/dist/es2019/components/slots/left-sidebar-styles.js +0 -96
  99. package/dist/es2019/components/slots/styles.js +0 -130
  100. package/dist/esm/components/resize-control/styles.js +0 -131
  101. package/dist/esm/components/skip-links/styles.js +0 -45
  102. package/dist/esm/components/slots/left-sidebar-styles.js +0 -94
  103. package/dist/esm/components/slots/styles.js +0 -117
  104. package/dist/types/components/resize-control/styles.d.ts +0 -41
  105. package/dist/types/components/skip-links/styles.d.ts +0 -2
  106. package/dist/types/components/slots/left-sidebar-styles.d.ts +0 -5
  107. package/dist/types/components/slots/styles.d.ts +0 -23
@@ -3,12 +3,23 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
 
4
4
  /** @jsx jsx */
5
5
  import { useEffect } from 'react';
6
- import { jsx } from '@emotion/core';
7
- import { DEFAULT_BANNER_HEIGHT, VAR_BANNER_HEIGHT } from '../../common/constants';
6
+ import { css, jsx } from '@emotion/core';
7
+ import { BANNER, BANNER_HEIGHT, DEFAULT_BANNER_HEIGHT, LEFT_PANEL_WIDTH, RIGHT_PANEL_WIDTH, VAR_BANNER_HEIGHT } from '../../common/constants';
8
8
  import { getPageLayoutSlotSelector, resolveDimension } from '../../common/utils';
9
9
  import { publishGridState, useSkipLink } from '../../controllers';
10
+ import SlotFocusRing from './internal/slot-focus-ring';
10
11
  import SlotDimensions from './slot-dimensions';
11
- import { bannerStyles } from './styles';
12
+ var bannerStyles = css({
13
+ height: BANNER_HEIGHT,
14
+ gridArea: BANNER
15
+ });
16
+ var bannerFixedStyles = css({
17
+ position: 'fixed',
18
+ zIndex: 2,
19
+ top: 0,
20
+ right: RIGHT_PANEL_WIDTH,
21
+ left: LEFT_PANEL_WIDTH
22
+ });
12
23
 
13
24
  var Banner = function Banner(props) {
14
25
  var children = props.children,
@@ -25,17 +36,21 @@ var Banner = function Banner(props) {
25
36
  publishGridState(_defineProperty({}, VAR_BANNER_HEIGHT, bannerHeight));
26
37
  return function () {
27
38
  publishGridState(_defineProperty({}, VAR_BANNER_HEIGHT, 0));
28
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
39
+ };
29
40
  }, [bannerHeight]);
30
41
  useSkipLink(id, skipLinkTitle);
31
- return jsx("div", _extends({
32
- css: bannerStyles(isFixed),
33
- "data-testid": testId,
34
- id: id
35
- }, getPageLayoutSlotSelector('banner')), jsx(SlotDimensions, {
36
- variableName: VAR_BANNER_HEIGHT,
37
- value: bannerHeight
38
- }), children);
42
+ return jsx(SlotFocusRing, null, function (_ref) {
43
+ var className = _ref.className;
44
+ return jsx("div", _extends({
45
+ css: [bannerStyles, isFixed && bannerFixedStyles],
46
+ className: className,
47
+ "data-testid": testId,
48
+ id: id
49
+ }, getPageLayoutSlotSelector('banner')), jsx(SlotDimensions, {
50
+ variableName: VAR_BANNER_HEIGHT,
51
+ value: bannerHeight
52
+ }), children);
53
+ });
39
54
  };
40
55
 
41
56
  export default Banner;
@@ -1,6 +1,12 @@
1
1
  /** @jsx jsx */
2
- import { jsx } from '@emotion/core';
3
- import { contentStyles } from './styles';
2
+ import { css, jsx } from '@emotion/core';
3
+ import { CONTENT } from '../../common/constants';
4
+ var contentStyles = css({
5
+ display: 'flex',
6
+ height: '100%',
7
+ position: 'relative',
8
+ gridArea: CONTENT
9
+ });
4
10
 
5
11
  var Content = function Content(props) {
6
12
  var children = props.children,
@@ -0,0 +1,53 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/core';
3
+ import { easeOut, prefersReducedMotion } from '@atlaskit/motion';
4
+ import { BANNER_HEIGHT, LEFT_PANEL_WIDTH, LEFT_SIDEBAR_FLYOUT_WIDTH, LEFT_SIDEBAR_WIDTH, TOP_NAVIGATION_HEIGHT, TRANSITION_DURATION } from '../../../common/constants';
5
+ import { useIsSidebarDragging } from '../../../common/hooks';
6
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
7
+ var prefersReducedMotionStyles = css(prefersReducedMotion());
8
+ /**
9
+ * This inner wrapper is required to allow the sidebar to be `position: fixed`.
10
+ *
11
+ * If we were to apply `position: fixed` to the outer wrapper, it will be popped
12
+ * out of its flex container and Main would stretch to occupy all the space.
13
+ */
14
+
15
+ var fixedInnerStyles = css({
16
+ width: "".concat(LEFT_SIDEBAR_WIDTH),
17
+ position: 'fixed',
18
+ top: "calc(".concat(BANNER_HEIGHT, " + ").concat(TOP_NAVIGATION_HEIGHT, ")"),
19
+ bottom: 0,
20
+ left: "".concat(LEFT_PANEL_WIDTH),
21
+ transition: "width ".concat(TRANSITION_DURATION, "ms ").concat(easeOut, " 0s")
22
+ });
23
+ var fixedInnerFlyoutStyles = css({
24
+ width: LEFT_SIDEBAR_FLYOUT_WIDTH
25
+ });
26
+ /**
27
+ * Static in the sense of `position: static`.
28
+ *
29
+ * It will expand the page height to fit its content.
30
+ */
31
+
32
+ var staticInnerStyles = css({
33
+ height: '100%'
34
+ });
35
+ var draggingStyles = css({
36
+ cursor: 'ew-resize',
37
+ // Make sure drag to resize does not animate as the user drags
38
+ transition: 'none'
39
+ });
40
+
41
+ var LeftSidebarInner = function LeftSidebarInner(_ref) {
42
+ var children = _ref.children,
43
+ _ref$isFixed = _ref.isFixed,
44
+ isFixed = _ref$isFixed === void 0 ? false : _ref$isFixed,
45
+ _ref$isFlyoutOpen = _ref.isFlyoutOpen,
46
+ isFlyoutOpen = _ref$isFlyoutOpen === void 0 ? false : _ref$isFlyoutOpen;
47
+ var isDragging = useIsSidebarDragging();
48
+ return jsx("div", {
49
+ css: [!isFixed && staticInnerStyles, isFixed && fixedInnerStyles, isFixed && isFlyoutOpen && fixedInnerFlyoutStyles, isDragging && draggingStyles, prefersReducedMotionStyles]
50
+ }, children);
51
+ };
52
+
53
+ export default LeftSidebarInner;
@@ -0,0 +1,82 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+
3
+ /** @jsx jsx */
4
+ import { forwardRef } from 'react';
5
+ import { css, jsx } from '@emotion/core';
6
+ import { easeOut, prefersReducedMotion } from '@atlaskit/motion';
7
+ import { COLLAPSED_LEFT_SIDEBAR_WIDTH, LEFT_SIDEBAR_FLYOUT_WIDTH, LEFT_SIDEBAR_WIDTH, TRANSITION_DURATION } from '../../../common/constants';
8
+ import { useIsSidebarDragging } from '../../../common/hooks';
9
+ import { getPageLayoutSlotSelector } from '../../../common/utils';
10
+ import SlotFocusRing from './slot-focus-ring';
11
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
12
+ var prefersReducedMotionStyles = css(prefersReducedMotion());
13
+ var outerStyles = css({
14
+ width: LEFT_SIDEBAR_WIDTH,
15
+ marginLeft: 0,
16
+ position: 'relative',
17
+ zIndex: 1,
18
+ transition: "width ".concat(TRANSITION_DURATION, "ms ").concat(easeOut, " 0s"),
19
+ ':hover': {
20
+ '--ds--resize-button--opacity': 1
21
+ }
22
+ });
23
+ var draggingStyles = css({
24
+ cursor: 'ew-resize',
25
+ // Make sure drag to resize does not animate as the user drags
26
+ transition: 'none'
27
+ });
28
+ /**
29
+ * In fixed mode this element's child is taken out of the document flow.
30
+ * It doesn't take up the width as expected,
31
+ * so the pseudo element forces it to take up the necessary width.
32
+ */
33
+
34
+ var fixedStyles = css({
35
+ '::after': {
36
+ display: 'inline-block',
37
+ width: "".concat(LEFT_SIDEBAR_WIDTH),
38
+ content: "''"
39
+ }
40
+ });
41
+ var flyoutStyles = css({
42
+ width: LEFT_SIDEBAR_FLYOUT_WIDTH
43
+ });
44
+ var flyoutFixedStyles = css({
45
+ width: COLLAPSED_LEFT_SIDEBAR_WIDTH
46
+ });
47
+ var selector = getPageLayoutSlotSelector('left-sidebar');
48
+
49
+ var LeftSidebarOuter = function LeftSidebarOuter(_ref, ref) {
50
+ var children = _ref.children,
51
+ _ref$isFixed = _ref.isFixed,
52
+ isFixed = _ref$isFixed === void 0 ? false : _ref$isFixed,
53
+ _ref$isFlyoutOpen = _ref.isFlyoutOpen,
54
+ isFlyoutOpen = _ref$isFlyoutOpen === void 0 ? false : _ref$isFlyoutOpen,
55
+ testId = _ref.testId,
56
+ onMouseLeave = _ref.onMouseLeave,
57
+ onMouseOver = _ref.onMouseOver,
58
+ id = _ref.id;
59
+ var isDragging = useIsSidebarDragging();
60
+ return jsx(SlotFocusRing, {
61
+ isSidebar: true
62
+ }, function (_ref2) {
63
+ var className = _ref2.className;
64
+ return (
65
+ /**
66
+ * The mouse handlers control flyout behavior, a mouse-only experience.
67
+ */
68
+ // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
69
+ jsx("div", _extends({
70
+ css: [outerStyles, isFixed && fixedStyles, isFlyoutOpen && flyoutStyles, isFlyoutOpen && isFixed && flyoutFixedStyles, isDragging && draggingStyles, prefersReducedMotionStyles],
71
+ className: className,
72
+ "data-testid": testId,
73
+ id: id,
74
+ onMouseOver: onMouseOver,
75
+ onMouseLeave: onMouseLeave,
76
+ ref: ref
77
+ }, selector), children)
78
+ );
79
+ });
80
+ };
81
+
82
+ export default /*#__PURE__*/forwardRef(LeftSidebarOuter);
@@ -0,0 +1,51 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/core';
3
+ import { prefersReducedMotion } from '@atlaskit/motion';
4
+ import { TRANSITION_DURATION } from '../../../common/constants';
5
+ import { useIsSidebarCollapsing } from '../../../common/hooks';
6
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
7
+ var prefersReducedMotionStyles = css(prefersReducedMotion());
8
+ /**
9
+ * The transition duration is intentionally set to 0ms.
10
+ *
11
+ * A transition is being used here to delay the setting of
12
+ * opacity and visibility so that it syncs collapsing sidebar.
13
+ */
14
+
15
+ var hideLeftSidebarContentsStyles = css({
16
+ opacity: 0,
17
+ transition: "opacity 0ms linear, visibility 0ms linear",
18
+ transitionDelay: "".concat(TRANSITION_DURATION - 100, "ms"),
19
+ visibility: 'hidden'
20
+ });
21
+ var resizableChildrenWrapperStyles = css({
22
+ height: '100%',
23
+ opacity: 1,
24
+ overflow: 'hidden auto',
25
+ transition: 'none',
26
+ visibility: 'visible'
27
+ });
28
+ var fixedChildrenWrapperStyles = css({
29
+ minWidth: 240,
30
+ height: '100%'
31
+ });
32
+
33
+ var ResizableChildrenWrapper = function ResizableChildrenWrapper(_ref) {
34
+ var children = _ref.children,
35
+ _ref$isLeftSidebarCol = _ref.isLeftSidebarCollapsed,
36
+ isLeftSidebarCollapsed = _ref$isLeftSidebarCol === void 0 ? false : _ref$isLeftSidebarCol,
37
+ _ref$hasCollapsedStat = _ref.hasCollapsedState,
38
+ hasCollapsedState = _ref$hasCollapsedStat === void 0 ? false : _ref$hasCollapsedStat,
39
+ _ref$isFlyoutOpen = _ref.isFlyoutOpen,
40
+ isFlyoutOpen = _ref$isFlyoutOpen === void 0 ? false : _ref$isFlyoutOpen;
41
+ var isCollapsing = useIsSidebarCollapsing();
42
+ var isCollapsed = isLeftSidebarCollapsed || hasCollapsedState;
43
+ var isHidden = isCollapsing || isCollapsed && !isFlyoutOpen;
44
+ return jsx("div", {
45
+ css: [resizableChildrenWrapperStyles, isHidden && hideLeftSidebarContentsStyles, prefersReducedMotionStyles]
46
+ }, jsx("div", {
47
+ css: fixedChildrenWrapperStyles
48
+ }, children));
49
+ };
50
+
51
+ export default ResizableChildrenWrapper;
@@ -0,0 +1,51 @@
1
+ /** @jsx jsx */
2
+ import { ClassNames, css, jsx } from '@emotion/core';
3
+ import { B100 } from '@atlaskit/theme/colors';
4
+ var focusStyles = css({
5
+ ':focus': {
6
+ outline: 'none',
7
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
8
+ '> div': {
9
+ boxShadow: "0px 0px 0px 2px inset ".concat("var(--ds-border-focused, ".concat(B100, ")")),
10
+ outline: 'none'
11
+ }
12
+ }
13
+ });
14
+ /**
15
+ * Sidebars have an outer and inner component,
16
+ * so the nested selector needs to target an extra level deeper.
17
+ */
18
+
19
+ var sidebarFocusStyles = css({
20
+ ':focus': {
21
+ outline: 'none',
22
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
23
+ '> div > div': {
24
+ boxShadow: "0px 0px 0px 2px inset ".concat("var(--ds-border-focused, ".concat(B100, ")")),
25
+ outline: 'none'
26
+ }
27
+ }
28
+ });
29
+ /**
30
+ * We don't use `@atlaskit/focus-ring` here,
31
+ * because we need inset focus styles and:
32
+ *
33
+ * 1. If we set them directly to the layout element,
34
+ * then any child element's background will cover the shadow.
35
+ * 2. We cannot wrap `children` in `FocusRing`,
36
+ * because there's no guarantee the passed child takes `className`.
37
+ */
38
+
39
+ var SlotFocusRing = function SlotFocusRing(_ref) {
40
+ var children = _ref.children,
41
+ _ref$isSidebar = _ref.isSidebar,
42
+ isSidebar = _ref$isSidebar === void 0 ? false : _ref$isSidebar;
43
+ return jsx(ClassNames, null, function (_ref2) {
44
+ var css = _ref2.css;
45
+ return children({
46
+ className: isSidebar ? css(sidebarFocusStyles) : css(focusStyles)
47
+ });
48
+ });
49
+ };
50
+
51
+ export default SlotFocusRing;
@@ -3,12 +3,22 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
 
4
4
  /** @jsx jsx */
5
5
  import { useEffect } from 'react';
6
- import { jsx } from '@emotion/core';
7
- import { DEFAULT_LEFT_PANEL_WIDTH, VAR_LEFT_PANEL_WIDTH } from '../../common/constants';
6
+ import { css, jsx } from '@emotion/core';
7
+ import { DEFAULT_LEFT_PANEL_WIDTH, LEFT_PANEL, LEFT_PANEL_WIDTH, VAR_LEFT_PANEL_WIDTH } from '../../common/constants';
8
8
  import { getPageLayoutSlotSelector, resolveDimension } from '../../common/utils';
9
9
  import { publishGridState, useSkipLink } from '../../controllers';
10
+ import SlotFocusRing from './internal/slot-focus-ring';
10
11
  import SlotDimensions from './slot-dimensions';
11
- import { leftPanelStyles } from './styles';
12
+ var leftPanelStyles = css({
13
+ gridArea: LEFT_PANEL
14
+ });
15
+ var leftPanelFixedStyles = css({
16
+ width: LEFT_PANEL_WIDTH,
17
+ position: 'fixed',
18
+ top: 0,
19
+ bottom: 0,
20
+ left: 0
21
+ });
12
22
 
13
23
  var LeftPanel = function LeftPanel(props) {
14
24
  var children = props.children,
@@ -24,17 +34,21 @@ var LeftPanel = function LeftPanel(props) {
24
34
  publishGridState(_defineProperty({}, VAR_LEFT_PANEL_WIDTH, leftPanelWidth));
25
35
  return function () {
26
36
  publishGridState(_defineProperty({}, VAR_LEFT_PANEL_WIDTH, 0));
27
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ };
28
38
  }, [leftPanelWidth]);
29
39
  useSkipLink(id, skipLinkTitle);
30
- return jsx("div", _extends({
31
- css: leftPanelStyles(isFixed),
32
- "data-testid": testId,
33
- id: id
34
- }, getPageLayoutSlotSelector('left-panel')), jsx(SlotDimensions, {
35
- variableName: VAR_LEFT_PANEL_WIDTH,
36
- value: leftPanelWidth
37
- }), children);
40
+ return jsx(SlotFocusRing, null, function (_ref) {
41
+ var className = _ref.className;
42
+ return jsx("div", _extends({
43
+ css: [leftPanelStyles, isFixed && leftPanelFixedStyles],
44
+ className: className,
45
+ "data-testid": testId,
46
+ id: id
47
+ }, getPageLayoutSlotSelector('left-panel')), jsx(SlotDimensions, {
48
+ variableName: VAR_LEFT_PANEL_WIDTH,
49
+ value: leftPanelWidth
50
+ }), children);
51
+ });
38
52
  };
39
53
 
40
54
  export default LeftPanel;
@@ -1,13 +1,13 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
 
4
3
  /** @jsx jsx */
5
4
  import { useEffect } from 'react';
6
5
  import { jsx } from '@emotion/core';
7
6
  import { VAR_LEFT_SIDEBAR_WIDTH } from '../../common/constants';
8
- import { getPageLayoutSlotSelector, resolveDimension } from '../../common/utils';
7
+ import { resolveDimension } from '../../common/utils';
9
8
  import { publishGridState, useSkipLink } from '../../controllers';
10
- import { fixedLeftSidebarInnerStyles, leftSidebarStyles } from './left-sidebar-styles';
9
+ import LeftSidebarInner from './internal/left-sidebar-inner';
10
+ import LeftSidebarOuter from './internal/left-sidebar-outer';
11
11
  import SlotDimensions from './slot-dimensions';
12
12
 
13
13
  var LeftSidebarWithoutResize = function LeftSidebarWithoutResize(props) {
@@ -23,18 +23,18 @@ var LeftSidebarWithoutResize = function LeftSidebarWithoutResize(props) {
23
23
  publishGridState(_defineProperty({}, VAR_LEFT_SIDEBAR_WIDTH, leftSidebarWidth));
24
24
  return function () {
25
25
  publishGridState(_defineProperty({}, VAR_LEFT_SIDEBAR_WIDTH, 0));
26
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
26
+ };
27
27
  }, [leftSidebarWidth]);
28
28
  useSkipLink(id, skipLinkTitle);
29
- return jsx("div", _extends({
29
+ return jsx(LeftSidebarOuter, {
30
30
  id: id,
31
- "data-testid": testId,
32
- css: leftSidebarStyles(isFixed)
33
- }, getPageLayoutSlotSelector('left-sidebar')), jsx(SlotDimensions, {
31
+ testId: testId,
32
+ isFixed: isFixed
33
+ }, jsx(SlotDimensions, {
34
34
  variableName: VAR_LEFT_SIDEBAR_WIDTH,
35
35
  value: leftSidebarWidth
36
- }), jsx("div", {
37
- css: fixedLeftSidebarInnerStyles(isFixed)
36
+ }), jsx(LeftSidebarInner, {
37
+ isFixed: isFixed
38
38
  }, children));
39
39
  };
40
40
 
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
 
4
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -9,10 +8,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
9
8
  import { useContext, useEffect, useRef } from 'react';
10
9
  import { jsx } from '@emotion/core';
11
10
  import { COLLAPSED_LEFT_SIDEBAR_WIDTH, DEFAULT_LEFT_SIDEBAR_WIDTH, FLYOUT_DELAY, RESIZE_BUTTON_SELECTOR, VAR_LEFT_SIDEBAR_FLYOUT, VAR_LEFT_SIDEBAR_WIDTH } from '../../common/constants';
12
- import { getGridStateFromStorage, getPageLayoutSlotSelector, mergeGridStateIntoStorage, resolveDimension } from '../../common/utils';
11
+ import { getGridStateFromStorage, mergeGridStateIntoStorage, resolveDimension } from '../../common/utils';
13
12
  import { publishGridState, SidebarResizeContext, useSkipLink } from '../../controllers';
14
13
  import ResizeControl from '../resize-control';
15
- import { fixedChildrenWrapperStyle, fixedLeftSidebarInnerStyles, leftSidebarStyles, resizeableChildrenWrapperStyle } from './left-sidebar-styles';
14
+ import LeftSidebarInner from './internal/left-sidebar-inner';
15
+ import LeftSidebarOuter from './internal/left-sidebar-outer';
16
+ import ResizableChildrenWrapper from './internal/resizable-children-wrapper';
16
17
  import SlotDimensions from './slot-dimensions';
17
18
 
18
19
  var LeftSidebar = function LeftSidebar(props) {
@@ -115,7 +116,8 @@ var LeftSidebar = function LeftSidebar(props) {
115
116
  isLeftSidebarCollapsed: cachedCollapsedState,
116
117
  leftSidebarWidth: leftSidebarWidth,
117
118
  lastLeftSidebarWidth: lastLeftSidebarWidth,
118
- flyoutLockCount: 0
119
+ flyoutLockCount: 0,
120
+ isFixed: isFixed
119
121
  }); // eslint-disable-next-line react-hooks/exhaustive-deps
120
122
  }, []); // Every time other than mount,
121
123
  // update the local storage and css variables.
@@ -210,23 +212,25 @@ var LeftSidebar = function LeftSidebar(props) {
210
212
  };
211
213
 
212
214
  return (// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
213
- jsx("div", _extends({
215
+ jsx(LeftSidebarOuter, {
214
216
  ref: leftSideBarRef,
215
- css: leftSidebarStyles(isFixed, isFlyoutOpen),
216
- "data-testid": testId,
217
+ testId: testId,
217
218
  onMouseOver: onMouseOver,
218
219
  onMouseLeave: onMouseLeave,
219
- id: id
220
- }, getPageLayoutSlotSelector('left-sidebar')), jsx(SlotDimensions, {
220
+ id: id,
221
+ isFixed: isFixed,
222
+ isFlyoutOpen: isFlyoutOpen
223
+ }, jsx(SlotDimensions, {
221
224
  variableName: VAR_LEFT_SIDEBAR_WIDTH,
222
225
  value: notFirstRun.current ? leftSidebarWidth : leftSidebarWidthOnMount
223
- }), jsx("div", {
224
- css: fixedLeftSidebarInnerStyles(isFixed, isFlyoutOpen)
225
- }, jsx("div", {
226
- css: resizeableChildrenWrapperStyle(isFlyoutOpen, isLeftSidebarCollapsed, !notFirstRun.current && collapsedState === 'collapsed')
227
- }, jsx("div", {
228
- css: fixedChildrenWrapperStyle
229
- }, children)), jsx(ResizeControl, {
226
+ }), jsx(LeftSidebarInner, {
227
+ isFixed: isFixed,
228
+ isFlyoutOpen: isFlyoutOpen
229
+ }, jsx(ResizableChildrenWrapper, {
230
+ isFlyoutOpen: isFlyoutOpen,
231
+ isLeftSidebarCollapsed: isLeftSidebarCollapsed,
232
+ hasCollapsedState: !notFirstRun.current && collapsedState === 'collapsed'
233
+ }, children), jsx(ResizeControl, {
230
234
  testId: testId,
231
235
  resizeGrabAreaLabel: resizeGrabAreaLabel,
232
236
  resizeButtonLabel: resizeButtonLabel,
@@ -1,10 +1,40 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
- import { jsx } from '@emotion/core';
4
+ import { useContext } from 'react';
5
+ import { css, jsx } from '@emotion/core';
6
+ import { prefersReducedMotion } from '@atlaskit/motion/accessibility';
7
+ import { easeOut } from '@atlaskit/motion/curves';
8
+ import { COLLAPSED_LEFT_SIDEBAR_WIDTH, DEFAULT_LEFT_SIDEBAR_FLYOUT_WIDTH, TRANSITION_DURATION, VAR_LEFT_SIDEBAR_FLYOUT } from '../../common/constants';
9
+ import { useIsSidebarDragging } from '../../common/hooks';
5
10
  import { getPageLayoutSlotSelector } from '../../common/utils';
6
- import { useSkipLink } from '../../controllers';
7
- import { mainStyles } from './styles';
11
+ import { SidebarResizeContext, useSkipLink } from '../../controllers';
12
+ import SlotFocusRing from './internal/slot-focus-ring'; // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
13
+
14
+ var prefersReducedMotionStyles = css(prefersReducedMotion());
15
+ var mainStyles = css({
16
+ minWidth: 0,
17
+ marginLeft: 0,
18
+ // Prevent flex container from blowing up when there's super wide content.
19
+ flexGrow: 1,
20
+ // Transition negative margin on main in sync with the increase in width of leftSidebar.
21
+ transition: "margin-left ".concat(TRANSITION_DURATION, "ms ").concat(easeOut, " 0s")
22
+ });
23
+ var draggingStyles = css({
24
+ cursor: 'ew-resize',
25
+ // Make sure drag to resize remains snappy.
26
+ transition: 'none'
27
+ });
28
+ /**
29
+ * Adds a negative left margin to main,
30
+ * which transitions at the same speed as the left sidebar's width increase.
31
+ * This give an illusion that the flyout is appearing on top of the main content,
32
+ * while main remains in place.
33
+ */
34
+
35
+ var flyoutStyles = css({
36
+ marginLeft: "calc(-1 * var(--".concat(VAR_LEFT_SIDEBAR_FLYOUT, ", ").concat(DEFAULT_LEFT_SIDEBAR_FLYOUT_WIDTH, "px) + ").concat(COLLAPSED_LEFT_SIDEBAR_WIDTH, "px)")
37
+ });
8
38
 
9
39
  var Main = function Main(props) {
10
40
  var children = props.children,
@@ -12,11 +42,22 @@ var Main = function Main(props) {
12
42
  id = props.id,
13
43
  skipLinkTitle = props.skipLinkTitle;
14
44
  useSkipLink(id, skipLinkTitle);
15
- return jsx("div", _extends({
16
- "data-testid": testId,
17
- css: mainStyles,
18
- id: id
19
- }, getPageLayoutSlotSelector('main')), children);
45
+ var isDragging = useIsSidebarDragging();
46
+
47
+ var _useContext = useContext(SidebarResizeContext),
48
+ _useContext$leftSideb = _useContext.leftSidebarState,
49
+ isFlyoutOpen = _useContext$leftSideb.isFlyoutOpen,
50
+ isFixed = _useContext$leftSideb.isFixed;
51
+
52
+ return jsx(SlotFocusRing, null, function (_ref) {
53
+ var className = _ref.className;
54
+ return jsx("div", _extends({
55
+ "data-testid": testId,
56
+ css: [mainStyles, isDragging && draggingStyles, isFlyoutOpen && !isFixed && flyoutStyles, prefersReducedMotionStyles],
57
+ className: className,
58
+ id: id
59
+ }, getPageLayoutSlotSelector('main')), children);
60
+ });
20
61
  };
21
62
 
22
63
  export default Main;
@@ -3,14 +3,23 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
 
4
4
  /** @jsx jsx */
5
5
  import { Fragment } from 'react';
6
- import { jsx } from '@emotion/core';
7
- import { DEFAULT_I18N_PROPS_SKIP_LINKS, PAGE_LAYOUT_CONTAINER_SELECTOR } from '../../common/constants';
6
+ import { css, jsx } from '@emotion/core';
7
+ import { BANNER, BANNER_HEIGHT, CONTENT, DEFAULT_I18N_PROPS_SKIP_LINKS, LEFT_PANEL, LEFT_PANEL_WIDTH, PAGE_LAYOUT_CONTAINER_SELECTOR, RIGHT_PANEL, RIGHT_PANEL_WIDTH, TOP_NAVIGATION, TOP_NAVIGATION_HEIGHT } from '../../common/constants';
8
8
  import { SidebarResizeController, SkipLinksController } from '../../controllers';
9
9
  import { SkipLinkWrapper } from '../skip-links';
10
- import { gridStyles } from './styles';
11
10
 
12
11
  var pageLayoutSelector = _defineProperty({}, PAGE_LAYOUT_CONTAINER_SELECTOR, true);
13
12
 
13
+ var gridTemplateAreas = "\n \"".concat(LEFT_PANEL, " ").concat(BANNER, " ").concat(RIGHT_PANEL, "\"\n \"").concat(LEFT_PANEL, " ").concat(TOP_NAVIGATION, " ").concat(RIGHT_PANEL, "\"\n \"").concat(LEFT_PANEL, " ").concat(CONTENT, " ").concat(RIGHT_PANEL, "\"\n ");
14
+ var gridStyles = css({
15
+ display: 'grid',
16
+ height: '100%',
17
+ gridTemplateAreas: gridTemplateAreas,
18
+ gridTemplateColumns: "".concat(LEFT_PANEL_WIDTH, " minmax(0, 1fr) ").concat(RIGHT_PANEL_WIDTH),
19
+ gridTemplateRows: "".concat(BANNER_HEIGHT, " ").concat(TOP_NAVIGATION_HEIGHT, " auto"),
20
+ outline: 'none'
21
+ });
22
+
14
23
  var PageLayout = function PageLayout(_ref) {
15
24
  var _ref$skipLinksLabel = _ref.skipLinksLabel,
16
25
  skipLinksLabel = _ref$skipLinksLabel === void 0 ? DEFAULT_I18N_PROPS_SKIP_LINKS : _ref$skipLinksLabel,
@@ -3,12 +3,22 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
 
4
4
  /** @jsx jsx */
5
5
  import { useEffect } from 'react';
6
- import { jsx } from '@emotion/core';
7
- import { DEFAULT_RIGHT_PANEL_WIDTH, VAR_RIGHT_PANEL_WIDTH } from '../../common/constants';
6
+ import { css, jsx } from '@emotion/core';
7
+ import { DEFAULT_RIGHT_PANEL_WIDTH, RIGHT_PANEL, RIGHT_PANEL_WIDTH, VAR_RIGHT_PANEL_WIDTH } from '../../common/constants';
8
8
  import { getPageLayoutSlotSelector, resolveDimension } from '../../common/utils';
9
9
  import { publishGridState, useSkipLink } from '../../controllers';
10
+ import SlotFocusRing from './internal/slot-focus-ring';
10
11
  import SlotDimensions from './slot-dimensions';
11
- import { rightPanelStyles } from './styles';
12
+ var baseStyles = css({
13
+ gridArea: RIGHT_PANEL
14
+ });
15
+ var fixedStyles = css({
16
+ width: RIGHT_PANEL_WIDTH,
17
+ position: 'fixed',
18
+ top: 0,
19
+ right: 0,
20
+ bottom: 0
21
+ });
12
22
 
13
23
  var RightPanel = function RightPanel(props) {
14
24
  var children = props.children,
@@ -24,17 +34,21 @@ var RightPanel = function RightPanel(props) {
24
34
  publishGridState(_defineProperty({}, VAR_RIGHT_PANEL_WIDTH, rightPanelWidth));
25
35
  return function () {
26
36
  publishGridState(_defineProperty({}, VAR_RIGHT_PANEL_WIDTH, 0));
27
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ };
28
38
  }, [rightPanelWidth]);
29
39
  useSkipLink(id, skipLinkTitle);
30
- return jsx("div", _extends({
31
- css: rightPanelStyles(isFixed),
32
- "data-testid": testId,
33
- id: id
34
- }, getPageLayoutSlotSelector('right-panel')), jsx(SlotDimensions, {
35
- variableName: VAR_RIGHT_PANEL_WIDTH,
36
- value: rightPanelWidth
37
- }), children);
40
+ return jsx(SlotFocusRing, null, function (_ref) {
41
+ var className = _ref.className;
42
+ return jsx("div", _extends({
43
+ css: [baseStyles, isFixed && fixedStyles],
44
+ className: className,
45
+ "data-testid": testId,
46
+ id: id
47
+ }, getPageLayoutSlotSelector('right-panel')), jsx(SlotDimensions, {
48
+ variableName: VAR_RIGHT_PANEL_WIDTH,
49
+ value: rightPanelWidth
50
+ }), children);
51
+ });
38
52
  };
39
53
 
40
54
  export default RightPanel;