@atlaskit/page-layout 1.1.0 → 1.2.0
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.
- package/CHANGELOG.md +14 -0
- package/README.md +3 -3
- package/__perf__/utils/perf-example.tsx +24 -17
- package/__perf__/utils/product-integration/NotificationsPopup.tsx +6 -5
- package/__perf__/utils/product-integration/SampleFooter.tsx +13 -13
- package/dist/cjs/common/hooks/index.js +23 -0
- package/dist/cjs/common/hooks/use-is-sidebar-collapsing.js +46 -0
- package/dist/cjs/common/hooks/use-is-sidebar-dragging.js +46 -0
- package/dist/cjs/components/resize-control/grab-area.js +42 -4
- package/dist/cjs/components/resize-control/index.js +22 -20
- package/dist/cjs/components/resize-control/resize-button.js +59 -4
- package/dist/cjs/components/resize-control/shadow.js +48 -0
- package/dist/cjs/components/skip-links/skip-link-components.js +49 -5
- package/dist/cjs/components/slots/banner.js +27 -11
- package/dist/cjs/components/slots/content.js +9 -2
- package/dist/cjs/components/slots/internal/left-sidebar-inner.js +65 -0
- package/dist/cjs/components/slots/internal/left-sidebar-outer.js +100 -0
- package/dist/cjs/components/slots/internal/resizable-children-wrapper.js +63 -0
- package/dist/cjs/components/slots/internal/slot-focus-ring.js +61 -0
- package/dist/cjs/components/slots/left-panel.js +26 -11
- package/dist/cjs/components/slots/left-sidebar-without-resize.js +10 -10
- package/dist/cjs/components/slots/left-sidebar.js +21 -16
- package/dist/cjs/components/slots/main.js +53 -6
- package/dist/cjs/components/slots/page-layout.js +10 -3
- package/dist/cjs/components/slots/right-panel.js +26 -11
- package/dist/cjs/components/slots/right-sidebar.js +57 -13
- package/dist/cjs/components/slots/top-navigation.js +27 -11
- package/dist/cjs/controllers/sidebar-resize-context.js +2 -1
- package/dist/cjs/controllers/sidebar-resize-controller.js +10 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/common/hooks/index.js +2 -0
- package/dist/es2019/common/hooks/use-is-sidebar-collapsing.js +29 -0
- package/dist/es2019/common/hooks/use-is-sidebar-dragging.js +29 -0
- package/dist/es2019/components/resize-control/grab-area.js +46 -4
- package/dist/es2019/components/resize-control/index.js +12 -9
- package/dist/es2019/components/resize-control/resize-button.js +61 -4
- package/dist/es2019/components/resize-control/shadow.js +43 -0
- package/dist/es2019/components/skip-links/skip-link-components.js +47 -5
- package/dist/es2019/components/slots/banner.js +21 -7
- package/dist/es2019/components/slots/content.js +8 -2
- package/dist/es2019/components/slots/internal/left-sidebar-inner.js +52 -0
- package/dist/es2019/components/slots/internal/left-sidebar-outer.js +79 -0
- package/dist/es2019/components/slots/internal/resizable-children-wrapper.js +49 -0
- package/dist/es2019/components/slots/internal/slot-focus-ring.js +50 -0
- package/dist/es2019/components/slots/left-panel.js +20 -7
- package/dist/es2019/components/slots/left-sidebar-without-resize.js +10 -11
- package/dist/es2019/components/slots/left-sidebar.js +20 -17
- package/dist/es2019/components/slots/main.js +46 -6
- package/dist/es2019/components/slots/page-layout.js +15 -3
- package/dist/es2019/components/slots/right-panel.js +20 -7
- package/dist/es2019/components/slots/right-sidebar.js +50 -8
- package/dist/es2019/components/slots/top-navigation.js +21 -7
- package/dist/es2019/controllers/sidebar-resize-context.js +2 -1
- package/dist/es2019/controllers/sidebar-resize-controller.js +10 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/common/hooks/index.js +2 -0
- package/dist/esm/common/hooks/use-is-sidebar-collapsing.js +34 -0
- package/dist/esm/common/hooks/use-is-sidebar-dragging.js +34 -0
- package/dist/esm/components/resize-control/grab-area.js +42 -4
- package/dist/esm/components/resize-control/index.js +23 -20
- package/dist/esm/components/resize-control/resize-button.js +57 -4
- package/dist/esm/components/resize-control/shadow.js +37 -0
- package/dist/esm/components/skip-links/skip-link-components.js +47 -5
- package/dist/esm/components/slots/banner.js +27 -12
- package/dist/esm/components/slots/content.js +8 -2
- package/dist/esm/components/slots/internal/left-sidebar-inner.js +53 -0
- package/dist/esm/components/slots/internal/left-sidebar-outer.js +82 -0
- package/dist/esm/components/slots/internal/resizable-children-wrapper.js +51 -0
- package/dist/esm/components/slots/internal/slot-focus-ring.js +51 -0
- package/dist/esm/components/slots/left-panel.js +26 -12
- package/dist/esm/components/slots/left-sidebar-without-resize.js +10 -10
- package/dist/esm/components/slots/left-sidebar.js +20 -16
- package/dist/esm/components/slots/main.js +49 -8
- package/dist/esm/components/slots/page-layout.js +12 -3
- package/dist/esm/components/slots/right-panel.js +26 -12
- package/dist/esm/components/slots/right-sidebar.js +57 -14
- package/dist/esm/components/slots/top-navigation.js +27 -12
- package/dist/esm/controllers/sidebar-resize-context.js +2 -1
- package/dist/esm/controllers/sidebar-resize-controller.js +10 -5
- package/dist/esm/version.json +1 -1
- package/dist/types/common/hooks/index.d.ts +2 -0
- package/dist/types/common/hooks/use-is-sidebar-collapsing.d.ts +2 -0
- package/dist/types/common/hooks/use-is-sidebar-dragging.d.ts +2 -0
- package/dist/types/components/resize-control/shadow.d.ts +6 -0
- package/dist/types/components/slots/internal/left-sidebar-inner.d.ts +9 -0
- package/dist/types/components/slots/internal/left-sidebar-outer.d.ts +13 -0
- package/dist/types/components/slots/internal/resizable-children-wrapper.d.ts +10 -0
- package/dist/types/components/slots/internal/slot-focus-ring.d.ts +19 -0
- package/dist/types/controllers/sidebar-resize-context.d.ts +1 -0
- package/package.json +8 -5
- package/dist/cjs/components/resize-control/styles.js +0 -158
- package/dist/cjs/components/skip-links/styles.js +0 -58
- package/dist/cjs/components/slots/left-sidebar-styles.js +0 -116
- package/dist/cjs/components/slots/styles.js +0 -154
- package/dist/es2019/components/resize-control/styles.js +0 -139
- package/dist/es2019/components/skip-links/styles.js +0 -41
- package/dist/es2019/components/slots/left-sidebar-styles.js +0 -96
- package/dist/es2019/components/slots/styles.js +0 -130
- package/dist/esm/components/resize-control/styles.js +0 -133
- package/dist/esm/components/skip-links/styles.js +0 -45
- package/dist/esm/components/slots/left-sidebar-styles.js +0 -94
- package/dist/esm/components/slots/styles.js +0 -117
- package/dist/types/components/resize-control/styles.d.ts +0 -41
- package/dist/types/components/skip-links/styles.d.ts +0 -2
- package/dist/types/components/slots/left-sidebar-styles.d.ts +0 -5
- package/dist/types/components/slots/styles.d.ts +0 -23
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/core';
|
|
3
|
-
import {
|
|
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
|
-
|
|
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
|
-
};
|
|
37
|
+
};
|
|
28
38
|
}, [leftPanelWidth]);
|
|
29
39
|
useSkipLink(id, skipLinkTitle);
|
|
30
|
-
return jsx(
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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 {
|
|
7
|
+
import { resolveDimension } from '../../common/utils';
|
|
9
8
|
import { publishGridState, useSkipLink } from '../../controllers';
|
|
10
|
-
import
|
|
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
|
-
};
|
|
26
|
+
};
|
|
27
27
|
}, [leftSidebarWidth]);
|
|
28
28
|
useSkipLink(id, skipLinkTitle);
|
|
29
|
-
return jsx(
|
|
29
|
+
return jsx(LeftSidebarOuter, {
|
|
30
30
|
id: id,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
31
|
+
testId: testId,
|
|
32
|
+
isFixed: isFixed
|
|
33
|
+
}, jsx(SlotDimensions, {
|
|
34
34
|
variableName: VAR_LEFT_SIDEBAR_WIDTH,
|
|
35
35
|
value: leftSidebarWidth
|
|
36
|
-
}), jsx(
|
|
37
|
-
|
|
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,
|
|
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
|
|
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(
|
|
215
|
+
jsx(LeftSidebarOuter, {
|
|
214
216
|
ref: leftSideBarRef,
|
|
215
|
-
|
|
216
|
-
"data-testid": testId,
|
|
217
|
+
testId: testId,
|
|
217
218
|
onMouseOver: onMouseOver,
|
|
218
219
|
onMouseLeave: onMouseLeave,
|
|
219
|
-
id: id
|
|
220
|
-
|
|
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(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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 {
|
|
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
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
};
|
|
37
|
+
};
|
|
28
38
|
}, [rightPanelWidth]);
|
|
29
39
|
useSkipLink(id, skipLinkTitle);
|
|
30
|
-
return jsx(
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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;
|