@atlaskit/navigation-system 11.2.2 → 11.3.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 +36 -0
- package/dist/cjs/components/skip-links/skip-link.js +2 -2
- package/dist/cjs/components/skip-links/skip-links-container.js +2 -2
- package/dist/cjs/ui/fhs-rollout/is-custom-is-fhs-enabled-context.js +2 -2
- package/dist/cjs/ui/fhs-rollout/is-fhs-enabled-context.js +6 -6
- package/dist/cjs/ui/fhs-rollout/is-fhs-enabled-provider.js +14 -18
- package/dist/cjs/ui/fhs-rollout/use-is-fhs-enabled.js +5 -5
- package/dist/cjs/ui/page-layout/banner.compiled.css +0 -1
- package/dist/cjs/ui/page-layout/banner.js +2 -5
- package/dist/cjs/ui/page-layout/constants.js +1 -13
- package/dist/cjs/ui/page-layout/panel-splitter/panel-splitter.compiled.css +0 -1
- package/dist/cjs/ui/page-layout/panel-splitter/panel-splitter.js +2 -5
- package/dist/cjs/ui/page-layout/panel-splitter/side-nav-panel-splitter.js +0 -68
- package/dist/cjs/ui/page-layout/ribbon.js +0 -7
- package/dist/cjs/ui/page-layout/side-nav/side-nav-content.js +1 -9
- package/dist/cjs/ui/page-layout/side-nav/side-nav.compiled.css +3 -10
- package/dist/cjs/ui/page-layout/side-nav/side-nav.js +21 -54
- package/dist/cjs/ui/page-layout/top-nav/top-nav-end.compiled.css +0 -1
- package/dist/cjs/ui/page-layout/top-nav/top-nav-end.js +4 -7
- package/dist/cjs/ui/page-layout/top-nav/top-nav-start.compiled.css +2 -12
- package/dist/cjs/ui/page-layout/top-nav/top-nav-start.js +9 -250
- package/dist/cjs/ui/page-layout/top-nav/top-nav.compiled.css +1 -15
- package/dist/cjs/ui/page-layout/top-nav/top-nav.js +5 -16
- package/dist/cjs/ui/top-nav-items/nav-logo/app-logo.compiled.css +0 -2
- package/dist/cjs/ui/top-nav-items/nav-logo/app-logo.js +13 -16
- package/dist/cjs/ui/top-nav-items/nav-logo/custom-logo.compiled.css +0 -2
- package/dist/cjs/ui/top-nav-items/nav-logo/custom-logo.js +5 -8
- package/dist/cjs/ui/top-nav-items/search.compiled.css +3 -2
- package/dist/cjs/ui/top-nav-items/search.js +9 -11
- package/dist/cjs/ui/top-nav-items/themed/themed-anchor.js +2 -2
- package/dist/cjs/ui/top-nav-items/themed/themed-pressable.js +2 -2
- package/dist/es2019/components/skip-links/skip-link.js +1 -1
- package/dist/es2019/components/skip-links/skip-links-container.js +1 -1
- package/dist/es2019/ui/fhs-rollout/is-custom-is-fhs-enabled-context.js +2 -2
- package/dist/es2019/ui/fhs-rollout/is-fhs-enabled-context.js +6 -4
- package/dist/es2019/ui/fhs-rollout/is-fhs-enabled-provider.js +12 -17
- package/dist/es2019/ui/fhs-rollout/use-is-fhs-enabled.js +5 -8
- package/dist/es2019/ui/page-layout/banner.compiled.css +0 -1
- package/dist/es2019/ui/page-layout/banner.js +2 -5
- package/dist/es2019/ui/page-layout/chat-panel.js +1 -1
- package/dist/es2019/ui/page-layout/constants.js +0 -12
- package/dist/es2019/ui/page-layout/panel-splitter/panel-splitter.compiled.css +0 -1
- package/dist/es2019/ui/page-layout/panel-splitter/panel-splitter.js +2 -5
- package/dist/es2019/ui/page-layout/panel-splitter/side-nav-panel-splitter.js +2 -61
- package/dist/es2019/ui/page-layout/ribbon.js +0 -7
- package/dist/es2019/ui/page-layout/side-nav/side-nav-content.js +2 -8
- package/dist/es2019/ui/page-layout/side-nav/side-nav.compiled.css +3 -10
- package/dist/es2019/ui/page-layout/side-nav/side-nav.js +5 -44
- package/dist/es2019/ui/page-layout/top-nav/top-nav-end.compiled.css +0 -1
- package/dist/es2019/ui/page-layout/top-nav/top-nav-end.js +3 -6
- package/dist/es2019/ui/page-layout/top-nav/top-nav-start.compiled.css +2 -12
- package/dist/es2019/ui/page-layout/top-nav/top-nav-start.js +6 -243
- package/dist/es2019/ui/page-layout/top-nav/top-nav.compiled.css +1 -15
- package/dist/es2019/ui/page-layout/top-nav/top-nav.js +5 -18
- package/dist/es2019/ui/top-nav-items/nav-logo/app-logo.compiled.css +0 -2
- package/dist/es2019/ui/top-nav-items/nav-logo/app-logo.js +9 -12
- package/dist/es2019/ui/top-nav-items/nav-logo/custom-logo.compiled.css +0 -2
- package/dist/es2019/ui/top-nav-items/nav-logo/custom-logo.js +4 -7
- package/dist/es2019/ui/top-nav-items/search.compiled.css +3 -2
- package/dist/es2019/ui/top-nav-items/search.js +6 -8
- package/dist/es2019/ui/top-nav-items/themed/themed-anchor.js +1 -1
- package/dist/es2019/ui/top-nav-items/themed/themed-pressable.js +1 -1
- package/dist/esm/components/skip-links/skip-link.js +1 -1
- package/dist/esm/components/skip-links/skip-links-container.js +1 -1
- package/dist/esm/ui/fhs-rollout/is-custom-is-fhs-enabled-context.js +2 -2
- package/dist/esm/ui/fhs-rollout/is-fhs-enabled-context.js +6 -6
- package/dist/esm/ui/fhs-rollout/is-fhs-enabled-provider.js +13 -16
- package/dist/esm/ui/fhs-rollout/use-is-fhs-enabled.js +5 -6
- package/dist/esm/ui/page-layout/banner.compiled.css +0 -1
- package/dist/esm/ui/page-layout/banner.js +2 -5
- package/dist/esm/ui/page-layout/chat-panel.js +1 -1
- package/dist/esm/ui/page-layout/constants.js +0 -12
- package/dist/esm/ui/page-layout/panel-splitter/panel-splitter.compiled.css +0 -1
- package/dist/esm/ui/page-layout/panel-splitter/panel-splitter.js +2 -5
- package/dist/esm/ui/page-layout/panel-splitter/side-nav-panel-splitter.js +2 -71
- package/dist/esm/ui/page-layout/ribbon.js +0 -7
- package/dist/esm/ui/page-layout/side-nav/side-nav-content.js +2 -10
- package/dist/esm/ui/page-layout/side-nav/side-nav.compiled.css +3 -10
- package/dist/esm/ui/page-layout/side-nav/side-nav.js +22 -55
- package/dist/esm/ui/page-layout/top-nav/top-nav-end.compiled.css +0 -1
- package/dist/esm/ui/page-layout/top-nav/top-nav-end.js +3 -6
- package/dist/esm/ui/page-layout/top-nav/top-nav-start.compiled.css +2 -12
- package/dist/esm/ui/page-layout/top-nav/top-nav-start.js +10 -250
- package/dist/esm/ui/page-layout/top-nav/top-nav.compiled.css +1 -15
- package/dist/esm/ui/page-layout/top-nav/top-nav.js +5 -16
- package/dist/esm/ui/top-nav-items/nav-logo/app-logo.compiled.css +0 -2
- package/dist/esm/ui/top-nav-items/nav-logo/app-logo.js +9 -12
- package/dist/esm/ui/top-nav-items/nav-logo/custom-logo.compiled.css +0 -2
- package/dist/esm/ui/top-nav-items/nav-logo/custom-logo.js +4 -7
- package/dist/esm/ui/top-nav-items/search.compiled.css +3 -2
- package/dist/esm/ui/top-nav-items/search.js +6 -8
- package/dist/esm/ui/top-nav-items/themed/themed-anchor.js +1 -1
- package/dist/esm/ui/top-nav-items/themed/themed-pressable.js +1 -1
- package/dist/types/ui/fhs-rollout/is-custom-is-fhs-enabled-context.d.ts +2 -2
- package/dist/types/ui/fhs-rollout/is-fhs-enabled-context.d.ts +5 -2
- package/dist/types/ui/fhs-rollout/is-fhs-enabled-provider.d.ts +9 -2
- package/dist/types/ui/fhs-rollout/use-is-fhs-enabled.d.ts +4 -1
- package/dist/types/ui/page-layout/constants.d.ts +0 -4
- package/dist/types/ui/page-layout/dangerously-hoist-css-var-to-document-root.d.ts +1 -1
- package/dist/types/ui/page-layout/panel-splitter/get-width-from-drag-location.d.ts +1 -1
- package/dist/types/ui/page-layout/panel-splitter/panel-splitter.d.ts +0 -2
- package/dist/types/ui/page-layout/side-nav/side-nav.d.ts +0 -1
- package/dist/types/ui/top-nav-items/themed/themed-anchor.d.ts +1 -1
- package/dist/types/ui/top-nav-items/themed/themed-button.d.ts +1 -1
- package/dist/types/ui/top-nav-items/themed/themed-icon-button.d.ts +1 -1
- package/dist/types/ui/top-nav-items/themed/themed-link-button.d.ts +1 -1
- package/dist/types/ui/top-nav-items/themed/themed-link-icon-button.d.ts +1 -1
- package/dist/types/ui/top-nav-items/themed/themed-pressable.d.ts +1 -1
- package/package.json +8 -10
|
@@ -1,60 +1,10 @@
|
|
|
1
|
-
import React, { useContext
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import invariant from 'tiny-invariant';
|
|
3
|
-
import {
|
|
4
|
-
import { useIsFhsEnabled } from '../../fhs-rollout/use-is-fhs-enabled';
|
|
5
|
-
import { openLayerObserverSideNavNamespace, openLayerObserverTopNavEndNamespace, openLayerObserverTopNavMiddleNamespace, openLayerObserverTopNavStartNamespace, sideNavPanelSplitterId } from '../constants';
|
|
3
|
+
import { sideNavPanelSplitterId } from '../constants';
|
|
6
4
|
import { useToggleSideNav } from '../side-nav/use-toggle-side-nav';
|
|
7
5
|
import { OnDoubleClickContext } from './on-double-click-context';
|
|
8
6
|
import { PanelSplitter } from './panel-splitter';
|
|
9
7
|
import { PanelSplitterContext } from './panel-splitter-context';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Namespaces to check for open layers that would interfere with the panel splitter.
|
|
13
|
-
*
|
|
14
|
-
* Placed outside the component for stability, as the list is used as an effect dependency.
|
|
15
|
-
*/
|
|
16
|
-
const openLayerNamespacesToCheck = [
|
|
17
|
-
// The side nav panel splitter is layered above the side nav, so needs to be disabled when there are open popups in the side nav.
|
|
18
|
-
openLayerObserverSideNavNamespace,
|
|
19
|
-
// The side nav panel splitter is layered above the top nav, so needs to be disabled when there are open popups in the top nav.
|
|
20
|
-
openLayerObserverTopNavStartNamespace, openLayerObserverTopNavMiddleNamespace, openLayerObserverTopNavEndNamespace];
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Returns whether there are any open popups in the side nav or top nav
|
|
24
|
-
*/
|
|
25
|
-
function useHasOpenPopupsInSideNavOrTopNav() {
|
|
26
|
-
const isFhsEnabled = useIsFhsEnabled();
|
|
27
|
-
const openLayerObserver = useOpenLayerObserver();
|
|
28
|
-
// Setting the initial state to false, as it is unlikely that there would be any open popups when the app starts.
|
|
29
|
-
const [hasOpenPopups, setHasOpenPopups] = useState(false);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (!openLayerObserver || !isFhsEnabled) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
function updateState() {
|
|
35
|
-
if (!openLayerObserver) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const hasAnyOpenLayers = openLayerNamespacesToCheck.some(namespace => openLayerObserver.getCount({
|
|
39
|
-
namespace,
|
|
40
|
-
type: 'popup'
|
|
41
|
-
}) > 0);
|
|
42
|
-
setHasOpenPopups(hasAnyOpenLayers);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Initial check. We do this _in case_ a popup is already open when the component mounts.
|
|
46
|
-
updateState();
|
|
47
|
-
|
|
48
|
-
// Subscribe to each namespace
|
|
49
|
-
const cleanups = openLayerNamespacesToCheck.map(namespace => openLayerObserver.onChange(updateState, {
|
|
50
|
-
namespace
|
|
51
|
-
}));
|
|
52
|
-
return function cleanupHook() {
|
|
53
|
-
cleanups.forEach(cleanup => cleanup());
|
|
54
|
-
};
|
|
55
|
-
}, [isFhsEnabled, openLayerObserver]);
|
|
56
|
-
return hasOpenPopups;
|
|
57
|
-
}
|
|
58
8
|
/**
|
|
59
9
|
* _SideNavPanelSplitter_
|
|
60
10
|
*
|
|
@@ -81,15 +31,6 @@ export const SideNavPanelSplitter = ({
|
|
|
81
31
|
const toggleSideNav = useToggleSideNav({
|
|
82
32
|
trigger: 'double-click'
|
|
83
33
|
});
|
|
84
|
-
const isFhsEnabled = useIsFhsEnabled();
|
|
85
|
-
|
|
86
|
-
// The logic and state for disabling the panel splitter when there are open popups
|
|
87
|
-
// in the side nav or top nav is being placed here, instead of in `SideNav`, to prevent
|
|
88
|
-
// re-rendering the side nav anytime the number of open popups changes.
|
|
89
|
-
const hasOpenLayersInSideNavOrTopNav = useHasOpenPopupsInSideNavOrTopNav();
|
|
90
|
-
if (hasOpenLayersInSideNavOrTopNav && isFhsEnabled) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
34
|
return /*#__PURE__*/React.createElement(OnDoubleClickContext.Provider, {
|
|
94
35
|
value: shouldCollapseOnDoubleClick ? toggleSideNav : undefined
|
|
95
36
|
}, /*#__PURE__*/React.createElement(PanelSplitter, {
|
|
@@ -10,15 +10,8 @@ import { useLayoutId } from './use-layout-id';
|
|
|
10
10
|
const localSlotLayersStatic = {
|
|
11
11
|
chatPanelOverlay: 5,
|
|
12
12
|
ribbon: 4,
|
|
13
|
-
// The side nav panel splitter is layered above the top nav when FHS is enabled.
|
|
14
|
-
// It has the same z-index value, but is rendered after the top nav in the DOM so is stacked above.
|
|
15
|
-
sideNavPanelSplitterFHS: 4,
|
|
16
13
|
topBar: 4,
|
|
17
14
|
banner: 4,
|
|
18
|
-
// When FHS is enabled, the side nav is layered below the top nav,
|
|
19
|
-
// but above the panel
|
|
20
|
-
bannerFHS: 3,
|
|
21
|
-
topNavFHS: 3,
|
|
22
15
|
sideNav: 2,
|
|
23
16
|
panelSmallViewports: 1
|
|
24
17
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/* side-nav-content.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
import "./side-nav-content.compiled.css";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
-
import React, { forwardRef
|
|
5
|
-
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
6
|
-
import { useIsFhsEnabled } from '../../fhs-rollout/use-is-fhs-enabled';
|
|
7
|
-
|
|
4
|
+
import React, { forwardRef } from 'react';
|
|
8
5
|
/**
|
|
9
6
|
* The main content of the side nav, filling up the middle section. It acts as a scroll container.
|
|
10
7
|
*
|
|
@@ -22,11 +19,8 @@ function _SideNavContent({
|
|
|
22
19
|
children,
|
|
23
20
|
testId
|
|
24
21
|
}, forwardedRef) {
|
|
25
|
-
const isFhsEnabled = useIsFhsEnabled();
|
|
26
|
-
const internalRef = useRef(null);
|
|
27
|
-
const mergedRef = useMemo(() => mergeRefs([internalRef, forwardedRef]), [forwardedRef]);
|
|
28
22
|
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
-
ref:
|
|
23
|
+
ref: forwardedRef,
|
|
30
24
|
"data-testid": testId,
|
|
31
25
|
className: ax([styles.scrollContainer])
|
|
32
26
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
._191wglyw{border-inline-start:none}
|
|
2
2
|
._t51zglyw{border-inline-end:none}._152timx3{inset-block-start:calc(var(--n_bnrM, 0px) + var(--n_tNvM, 0px))}
|
|
3
|
-
._15yekb7n{--animation-direction:1}
|
|
4
3
|
._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
5
4
|
._1bah1yb4{justify-content:space-between}
|
|
6
5
|
._1bsb1ego{width:min(90%,20pc)}
|
|
@@ -9,24 +8,18 @@
|
|
|
9
8
|
._1e0cglyw{display:none}
|
|
10
9
|
._1p2s1vfh{--exit-animation:var(--ds-sidenav-exit-left,200ms cubic-bezier(0,0.4,0,1) SlideOut100PercentLeft)}
|
|
11
10
|
._1pbycs5v{z-index:2}
|
|
12
|
-
._1pbyegat{z-index:4}
|
|
13
11
|
._2lx21bp4{flex-direction:column}
|
|
14
12
|
._4t3i1osq{height:100%}
|
|
15
13
|
._4t3ieqxy{height:calc(100vh - var(--n_bnrM, 0px) - var(--n_tNvM, 0px))}
|
|
16
14
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
17
15
|
._cjprp6j8{--enter-animation:var(--ds-sidenav-enter-left,250ms cubic-bezier(0,0.4,0,1) SlideIn100PercentLeft)}
|
|
18
16
|
._kqsw1if8{position:sticky}
|
|
19
|
-
._kqsw1n9t{position:fixed}
|
|
20
|
-
._t9ectl5p{transform:translateX(calc(var(--n_snvRsz, var(--n_snvW, 0px))))}
|
|
21
|
-
._u7coidpf{inset-block-end:0}
|
|
22
17
|
._vchhusvi{box-sizing:border-box}
|
|
23
18
|
[dir=rtl] ._1jq41dy6{--enter-animation:var(--ds-sidenav-enter-right,250ms cubic-bezier(0,0.4,0,1) SlideIn100PercentRight)}
|
|
24
19
|
[dir=rtl] ._2qe0jwwr{--exit-animation:var(--ds-sidenav-exit-right,200ms cubic-bezier(0,0.4,0,1) SlideOut100PercentRight)}
|
|
25
|
-
|
|
26
|
-
@media (prefers-reduced-motion:no-preference){._10t81t0s{transition-property:display}._1vrh1a5r{transition-behavior:allow-discrete}._xrrpi9qs{transition-duration:var(--ds-duration-medium,.2s)}._10t88iot{transition-property:transform,display}._xrrpfnf5{transition-duration:.2s}._1lh81gzg{grid-area:main}._1xq51mm8{transition-timing-function:cubic-bezier(0,.4,0,1)}._k1affm5y{animation:var(--exit-animation)}@starting-style{._1nu51p9u{transform:translateX(calc(-100%*var(--animation-direction)))}}._1xq51ku9{transition-timing-function:cubic-bezier(.6,0,0,1)}._k1af10ed{animation:var(--enter-animation)}}
|
|
20
|
+
@media (prefers-reduced-motion:no-preference){._10t81t0s{transition-property:display}._1vrh1a5r{transition-behavior:allow-discrete}._xrrpi9qs{transition-duration:var(--ds-duration-medium,.2s)}._1lh81gzg{grid-area:main}._k1affm5y{animation:var(--exit-animation)}._k1af10ed{animation:var(--enter-animation)}}
|
|
27
21
|
@media (min-width:48rem){._14b5hc79{width:var(--n_snvRsz,var(--n_sNvw))}}
|
|
28
|
-
@media (min-width:64rem){.
|
|
29
|
-
@media (prefers-reduced-motion:no-preference) and (min-width:64rem){.
|
|
30
|
-
@media (prefers-reduced-motion:no-preference) and (not (min-width:64rem)){._aadi1p9u{transform:translateX(calc(-100%*var(--animation-direction)))}}
|
|
22
|
+
@media (min-width:64rem){._cpcf1gzg._cpcf1gzg{grid-area:main}._6kttglyw._6kttglyw{border-inline-end:none}._w8v11bhr._w8v11bhr{background-color:var(--ds-surface-overlay,#fff)}._1jug130s._1jug130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}._dm2518uv{display:initial}._dm25glyw{display:none}._qiln1gzg{grid-area:main}._p5clglyw{border-inline-end:none}._4ap31bhr{background-color:var(--ds-surface-overlay,#fff)}._scbp130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}._qilnk0mc{grid-area:side-nav}._p5clia51{border-inline-end:var(--ds-border-width,1px) solid var(--ds-border,#0b120e24)}._4ap3vuon{background-color:var(--ds-surface,#fff)}._scbpglyw{box-shadow:none}}
|
|
23
|
+
@media (prefers-reduced-motion:no-preference) and (min-width:64rem){._1sg81gzg{grid-area:main}._n2infm5y{animation:var(--exit-animation)}._17ly1wzp{transition-property:grid-area,display}._hjoi1wsm{transition-duration:var(--ds-duration-instant,0ms),var(--ds-duration-medium,.2s)}._1wxo1cio{transition-delay:19ms,var(--ds-duration-instant,0ms)}@starting-style{._1xpz1gzg{grid-area:main}}._1sg8k0mc{grid-area:side-nav}._n2in10ed{animation:var(--enter-animation)}._17ly1q8v{transition-property:grid-area}._hjoi147i{transition-duration:var(--ds-duration-instant,0ms)}._1wxo4so3{transition-delay:24ms}}
|
|
31
24
|
@media not (min-width:64rem){._89fi1b6c{grid-area:main/aside/aside/aside}}
|
|
32
25
|
@supports not (-moz-appearance:none){@media (prefers-reduced-motion:no-preference){._139f8iot{transition-property:transform,display}._1tpvfnf5{transition-duration:.2s}._sylc1a5r{transition-behavior:allow-discrete}._1uwsjq3t{transform:translateX(-100%)}}@media (prefers-reduced-motion:no-preference){@starting-style{._oyeijq3t{transform:translateX(-100%)}}._139f8iot{transition-property:transform,display}._1tpvfnf5{transition-duration:.2s}._sylc1a5r{transition-behavior:allow-discrete}}@media (prefers-reduced-motion:no-preference){._4xci10ed{animation:var(--enter-animation)}._1tpv1mzy{transition-duration:var(--ds-duration-long,.25s)}._sylc1a5r{transition-behavior:allow-discrete}}@media (prefers-reduced-motion:no-preference){._4xcifm5y{animation:var(--exit-animation)}._1tpvi9qs{transition-duration:var(--ds-duration-medium,.2s)}._sylc1a5r{transition-behavior:allow-discrete}}}
|
|
@@ -16,8 +16,7 @@ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/el
|
|
|
16
16
|
|
|
17
17
|
import { useSkipLinkInternal } from '../../../context/skip-links/use-skip-link-internal';
|
|
18
18
|
import { TopNavStartElement } from '../../../context/top-nav-start/top-nav-start-element';
|
|
19
|
-
import {
|
|
20
|
-
import { UNSAFE_sideNavLayoutVar, mainMinimumWidthVar, openLayerObserverSideNavNamespace, openLayerObserverTopNavStartNamespace, sideNavLiveWidthVar, sideNavPanelSplitterId, sideNavVar } from '../constants';
|
|
19
|
+
import { UNSAFE_sideNavLayoutVar, mainMinimumWidthVar, openLayerObserverSideNavNamespace, sideNavLiveWidthVar, sideNavPanelSplitterId, sideNavVar } from '../constants';
|
|
21
20
|
import { DangerouslyHoistCssVarToDocumentRoot } from '../dangerously-hoist-css-var-to-document-root';
|
|
22
21
|
import { DangerouslyHoistSlotSizes } from '../hoist-slot-sizes-context';
|
|
23
22
|
import { convertResizeBoundToPixels } from '../panel-splitter/convert-resize-bound-to-pixels';
|
|
@@ -40,9 +39,6 @@ import { useSideNavVisibility } from './use-side-nav-visibility';
|
|
|
40
39
|
import { useSideNavVisibilityCallbacks } from './use-side-nav-visibility-callbacks';
|
|
41
40
|
import { useToggleSideNav } from './use-toggle-side-nav';
|
|
42
41
|
const panelSplitterResizingVar = '--n_snvRsz';
|
|
43
|
-
// Used to share the side nav width with the panel splitter, which is rendered outside the side nav element
|
|
44
|
-
// but positioned to stay at its right edge.
|
|
45
|
-
const sideNavClampedWidthVar = '--n_snvW';
|
|
46
42
|
const fallbackMinWidth = '240px';
|
|
47
43
|
function getPixelCustomProperty(element, propertyName, fallback) {
|
|
48
44
|
const raw = getComputedStyle(element).getPropertyValue(propertyName).trim();
|
|
@@ -56,28 +52,16 @@ function getPixelCustomProperty(element, propertyName, fallback) {
|
|
|
56
52
|
* Avoiding nesting the `@supports` at-rule inside of `@media` means Compiled can remove duplicate styles from the generated CSS.
|
|
57
53
|
*/
|
|
58
54
|
const isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
59
|
-
const panelSplitterPortalTargetStyles = {
|
|
60
|
-
root: "_kqsw1n9t _1pbyegat _u7coidpf _t9ectl5p _4t3ieqxy _165t56xv _p0az1elq"
|
|
61
|
-
};
|
|
62
55
|
const styles = {
|
|
63
56
|
root: "_191wglyw _t51zglyw _bfhk1bhr _16qs130s _vchhusvi _4t3ieqxy _152timx3 _kqsw1if8 _1bsb1ego _1pbycs5v _14b5hc79 _qilnk0mc _p5clia51 _4ap3vuon _scbpglyw _89fi1b6c",
|
|
64
57
|
chatPanelSizing: "_1bsbhc79",
|
|
65
58
|
managedOverlay: "_cpcf1gzg _6kttglyw _w8v11bhr _1jug130s",
|
|
66
59
|
flyoutOpen: "_qiln1gzg _p5clglyw _4ap31bhr _scbp130s _139f8iot _1tpvfnf5 _sylc1a5r _oyeijq3t",
|
|
67
60
|
flyoutAnimateClosed: "_1e0cglyw _qiln1gzg _139f8iot _1tpvfnf5 _sylc1a5r _1uwsjq3t",
|
|
68
|
-
animationRTLSupport: "_15yekb7n _65m41mrw",
|
|
69
|
-
flyoutBaseStylesFullHeightSidebar: "_qiln1gzg _p5clglyw _4ap31bhr _scbp130s _17ly8iot _177m1a5r",
|
|
70
|
-
flyoutOpenFullHeightSidebar: "_hjoifnf5 _vgub1ku9 _s2eg1p9u",
|
|
71
|
-
flyoutAnimateClosedFullHeightSidebar: "_dm25glyw _hjoifnf5 _vgub1mm8 _hh1u1p9u",
|
|
72
61
|
flexContainer: "_4t3i1osq _1e0c1txw _2lx21bp4 _1bah1yb4",
|
|
73
62
|
hiddenMobileAndDesktop: "_1e0cglyw",
|
|
74
63
|
hiddenMobileOnly: "_1e0cglyw _dm2518uv",
|
|
75
|
-
hiddenDesktopOnly: "_dm25glyw"
|
|
76
|
-
animationBaseStyles: "_10t88iot _1vrh1a5r _xrrpfnf5",
|
|
77
|
-
expandAnimationMobile: "_1xq51ku9 _1nu51p9u",
|
|
78
|
-
collapseAnimationMobile: "_1lh81gzg _1xq51mm8 _aadi1p9u",
|
|
79
|
-
expandAnimationDesktop: "_1sg8k0mc _vgub1ku9 _s2eg1p9u",
|
|
80
|
-
collapseAnimationDesktop: "_1sg81gzg _vgub1mm8 _hh1u1p9u"
|
|
64
|
+
hiddenDesktopOnly: "_dm25glyw"
|
|
81
65
|
};
|
|
82
66
|
|
|
83
67
|
/**
|
|
@@ -99,8 +83,6 @@ const motionUpliftStyles = {
|
|
|
99
83
|
collapseAnimationMobile: "_1lh81gzg _k1affm5y",
|
|
100
84
|
flyoutOpen: "_qiln1gzg _p5clglyw _4ap31bhr _scbp130s _4xci10ed _1tpv1mzy _sylc1a5r",
|
|
101
85
|
flyoutAnimateClosed: "_1e0cglyw _qiln1gzg _4xcifm5y _1tpvi9qs _sylc1a5r",
|
|
102
|
-
flyoutOpenFullHeightSidebar: "_n2in10ed _hjoi1mzy",
|
|
103
|
-
flyoutAnimateClosedFullHeightSidebar: "_dm25glyw _n2infm5y _hjoii9qs",
|
|
104
86
|
expandAnimationDesktop: "_1sg8k0mc _n2in10ed _1xpz1gzg _17ly1q8v _hjoi147i _1wxo4so3",
|
|
105
87
|
collapseAnimationDesktop: "_1sg81gzg _n2infm5y _17ly1wzp _hjoi1wsm _1wxo1cio"
|
|
106
88
|
};
|
|
@@ -129,7 +111,6 @@ function SideNavInternal({
|
|
|
129
111
|
}) {
|
|
130
112
|
var _managedSizing$mode, _managedSizing$width, _sideNavState$lastTri;
|
|
131
113
|
const isChatPanelLayoutEnabled = fg('platform-dst-chat-panel-layout');
|
|
132
|
-
const isFhsEnabled = useIsFhsEnabled();
|
|
133
114
|
const id = useLayoutId({
|
|
134
115
|
providedId
|
|
135
116
|
});
|
|
@@ -258,7 +239,6 @@ function SideNavInternal({
|
|
|
258
239
|
const clampedWidth = !isChatPanelLayoutEnabled ? `clamp(240px, ${inlineWidth}px, 50vw)` : managedSizing ? `${renderedWidth}px` : `clamp(${minWidth}, ${renderedWidth}px, ${configuredMaxWidth})`;
|
|
259
240
|
const dangerouslyHoistSlotSizes = useContext(DangerouslyHoistSlotSizes);
|
|
260
241
|
const navRef = useRef(null);
|
|
261
|
-
const panelSplitterPortalTargetRef = useRef(null);
|
|
262
242
|
const getResizeBounds = useCallback(() => {
|
|
263
243
|
if (!isChatPanelLayoutEnabled) {
|
|
264
244
|
return {
|
|
@@ -361,13 +341,6 @@ function SideNavInternal({
|
|
|
361
341
|
}
|
|
362
342
|
}
|
|
363
343
|
function open() {
|
|
364
|
-
// Prevent the flyout from being opened if there are any open layers in the top nav start
|
|
365
|
-
if (openLayerObserver && openLayerObserver.getCount({
|
|
366
|
-
namespace: openLayerObserverTopNavStartNamespace,
|
|
367
|
-
type: 'popup'
|
|
368
|
-
}) > 0) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
344
|
const prevFlyoutState = flyoutStateRef.current;
|
|
372
345
|
tryAbortPendingClose();
|
|
373
346
|
flyoutStateRef.current = {
|
|
@@ -866,7 +839,7 @@ function SideNavInternal({
|
|
|
866
839
|
const isMotionUpliftEnabled = fg('platform-dst-motion-uplift-sidenav');
|
|
867
840
|
|
|
868
841
|
// This is only used for the regular expand and collapse animations, not the flyout animations.
|
|
869
|
-
const shouldShowSidebarToggleAnimation =
|
|
842
|
+
const shouldShowSidebarToggleAnimation = isMotionUpliftEnabled &&
|
|
870
843
|
// We do not apply the animation styles on the initial render, as the `@starting-style` rule will cause the sidebar to
|
|
871
844
|
// slide in initially.
|
|
872
845
|
hasExpandedStateChanged &&
|
|
@@ -900,7 +873,7 @@ function SideNavInternal({
|
|
|
900
873
|
},
|
|
901
874
|
ref: mergedRef,
|
|
902
875
|
"data-testid": testId,
|
|
903
|
-
className: ax([styles.root, isChatPanelLayoutEnabled && styles.chatPanelSizing, isChatPanelLayoutEnabled && (managedSizing === null || managedSizing === void 0 ? void 0 : managedSizing.mode) === 'overlay' && styles.managedOverlay, isExpandedOnDesktop && !isExpandedOnMobile && !isFlyoutVisible && styles.hiddenMobileOnly, !isExpandedOnDesktop && isExpandedOnMobile && !isFlyoutVisible && styles.hiddenDesktopOnly, !isExpandedOnDesktop && !isExpandedOnMobile && !isFlyoutVisible && styles.hiddenMobileAndDesktop, isMotionUpliftEnabled && motionUpliftStyles.animationRTLSupport,
|
|
876
|
+
className: ax([styles.root, isChatPanelLayoutEnabled && styles.chatPanelSizing, isChatPanelLayoutEnabled && (managedSizing === null || managedSizing === void 0 ? void 0 : managedSizing.mode) === 'overlay' && styles.managedOverlay, isExpandedOnDesktop && !isExpandedOnMobile && !isFlyoutVisible && styles.hiddenMobileOnly, !isExpandedOnDesktop && isExpandedOnMobile && !isFlyoutVisible && styles.hiddenDesktopOnly, !isExpandedOnDesktop && !isExpandedOnMobile && !isFlyoutVisible && styles.hiddenMobileAndDesktop, isMotionUpliftEnabled && motionUpliftStyles.animationRTLSupport, shouldShowSidebarToggleAnimation && isMotionUpliftEnabled && motionUpliftStyles.animationBaseStyles, isExpandedOnMobile && shouldShowSidebarToggleAnimation && isMotionUpliftEnabled && motionUpliftStyles.expandAnimationMobile, !isExpandedOnMobile && shouldShowSidebarToggleAnimation && isMotionUpliftEnabled && motionUpliftStyles.collapseAnimationMobile, isExpandedOnDesktop && shouldShowSidebarToggleAnimation && isMotionUpliftEnabled && motionUpliftStyles.expandAnimationDesktop, !isExpandedOnDesktop && shouldShowSidebarToggleAnimation && isMotionUpliftEnabled && motionUpliftStyles.collapseAnimationDesktop, (sideNavState === null || sideNavState === void 0 ? void 0 : sideNavState.flyout) === 'open' && isMotionUpliftEnabled && motionUpliftStyles.flyoutOpen, (sideNavState === null || sideNavState === void 0 ? void 0 : sideNavState.flyout) === 'open' && !isMotionUpliftEnabled && styles.flyoutOpen, (sideNavState === null || sideNavState === void 0 ? void 0 : sideNavState.flyout) === 'triggered-animate-close' && isMotionUpliftEnabled && motionUpliftStyles.flyoutAnimateClosed, (sideNavState === null || sideNavState === void 0 ? void 0 : sideNavState.flyout) === 'triggered-animate-close' && !isMotionUpliftEnabled && styles.flyoutAnimateClosed])
|
|
904
877
|
}), /*#__PURE__*/React.createElement(DangerouslyHoistCssVarToDocumentRoot, {
|
|
905
878
|
variableName: sideNavLiveWidthVar,
|
|
906
879
|
value: "0px",
|
|
@@ -919,7 +892,6 @@ function SideNavInternal({
|
|
|
919
892
|
, /*#__PURE__*/React.createElement(PanelSplitterProvider, {
|
|
920
893
|
panelId: sideNavPanelSplitterId,
|
|
921
894
|
panelRef: navRef,
|
|
922
|
-
portalRef: isFhsEnabled ? panelSplitterPortalTargetRef : undefined,
|
|
923
895
|
panelWidth: renderedWidth,
|
|
924
896
|
onCompleteResize: onCompleteResize,
|
|
925
897
|
onResizeStartInternal: isChatPanelLayoutEnabled && managedSizing ? onResizeStartInternal : undefined,
|
|
@@ -932,18 +904,7 @@ function SideNavInternal({
|
|
|
932
904
|
shortcut: isShortcutEnabled ? sideNavToggleTooltipKeyboardShortcut : undefined
|
|
933
905
|
}, /*#__PURE__*/React.createElement("div", {
|
|
934
906
|
className: ax([styles.flexContainer])
|
|
935
|
-
}, children)))
|
|
936
|
-
ref: panelSplitterPortalTargetRef,
|
|
937
|
-
"data-layout-slot": true,
|
|
938
|
-
style: {
|
|
939
|
-
// We need to use an inline style here to share the side nav width to position the panel splitter.
|
|
940
|
-
// We can't use the existing --n_sNvlw variable (sideNavLiveWidthVar) because it is set to 0 when the side nav is collapsed on desktop,
|
|
941
|
-
// however the panel splitter is still visible and usable on small viewports until 48rem.
|
|
942
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
943
|
-
[sideNavClampedWidthVar]: clampedWidth
|
|
944
|
-
},
|
|
945
|
-
className: ax([panelSplitterPortalTargetStyles.root, isExpandedOnDesktop && !isExpandedOnMobile && !isFlyoutVisible && styles.hiddenMobileOnly, !isExpandedOnDesktop && isExpandedOnMobile && !isFlyoutVisible && styles.hiddenDesktopOnly, !isExpandedOnDesktop && !isExpandedOnMobile && !isFlyoutVisible && styles.hiddenMobileAndDesktop])
|
|
946
|
-
}));
|
|
907
|
+
}, children))));
|
|
947
908
|
}
|
|
948
909
|
|
|
949
910
|
/**
|
|
@@ -5,6 +5,5 @@
|
|
|
5
5
|
._1e0cglyw{display:none}
|
|
6
6
|
._1ul9zwfg{min-width:2pc}
|
|
7
7
|
._4cvr1h6o{align-items:center}
|
|
8
|
-
._y4tiutpp{padding-inline-end:var(--ds-space-150,9pt)}
|
|
9
8
|
@media (min-width:48rem){._181n1txw{display:flex}._1d2y1ris{min-width:max-content}}
|
|
10
9
|
@media (min-width:64rem){._glte1ris{width:max-content}._15rip2n4{min-width:330px}._1gs5usvi{box-sizing:border-box}._ndwch9n0{justify-self:end}}
|
|
@@ -9,16 +9,14 @@ import ShowMoreHorizontalIcon from '@atlaskit/icon/core/show-more-horizontal';
|
|
|
9
9
|
import { OpenLayerObserverNamespaceProvider } from '@atlaskit/layering/open-layer-observer-namespace-provider';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
11
11
|
import { Popup } from '@atlaskit/popup/popup';
|
|
12
|
-
import { UNSAFE_useMediaQuery as useMediaQuery } from '@atlaskit/primitives/compiled/
|
|
12
|
+
import { UNSAFE_useMediaQuery as useMediaQuery } from '@atlaskit/primitives/compiled/use-media-query';
|
|
13
13
|
import { List } from '../../../components/list';
|
|
14
|
-
import { useIsFhsEnabled } from '../../fhs-rollout/use-is-fhs-enabled';
|
|
15
14
|
import { HasCustomThemeContext } from '../../top-nav-items/themed/has-custom-theme-context';
|
|
16
15
|
import { IconButton } from '../../top-nav-items/themed/icon-button';
|
|
17
16
|
import { openLayerObserverTopNavEndNamespace } from '../constants';
|
|
18
17
|
const containerStyles = {
|
|
19
18
|
root: "_yyhy11wp _1e0c1txw _1bahh9n0 _1ul9zwfg _1d2y1ris _glte1ris _15rip2n4 _1gs5usvi _ndwch9n0",
|
|
20
|
-
withPersistentItems: "_zulp1b66 _4cvr1h6o"
|
|
21
|
-
fullHeightSidebar: "_y4tiutpp"
|
|
19
|
+
withPersistentItems: "_zulp1b66 _4cvr1h6o"
|
|
22
20
|
};
|
|
23
21
|
const listStyles = {
|
|
24
22
|
root: "_zulp1b66 _4cvr1h6o _1e0c1txw",
|
|
@@ -41,7 +39,6 @@ export function TopNavEnd({
|
|
|
41
39
|
showMoreButtonLabel = 'Show more'
|
|
42
40
|
}) {
|
|
43
41
|
const hasPersistentItems = fg('platform-dst-chat-panel-layout') && persistentItems != null;
|
|
44
|
-
const isFhsEnabled = useIsFhsEnabled();
|
|
45
42
|
const [isOpen, setIsOpen] = useState(false);
|
|
46
43
|
// Always setting to `false` for the initial render (will flip in an effect for mobile)
|
|
47
44
|
const [isMobile, setIsMobile] = useState(false);
|
|
@@ -66,7 +63,7 @@ export function TopNavEnd({
|
|
|
66
63
|
}, children);
|
|
67
64
|
const content = /*#__PURE__*/React.createElement("nav", {
|
|
68
65
|
"aria-label": label,
|
|
69
|
-
className: ax([containerStyles.root, hasPersistentItems && containerStyles.withPersistentItems
|
|
66
|
+
className: ax([containerStyles.root, hasPersistentItems && containerStyles.withPersistentItems])
|
|
70
67
|
}, isMobile ? /*#__PURE__*/React.createElement(Popup, {
|
|
71
68
|
isOpen: isOpen,
|
|
72
69
|
onClose: () => setIsOpen(false)
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
._zulp1b66{gap:var(--ds-space-050,4px)}
|
|
2
|
-
.
|
|
3
|
-
._yyhykb7n{grid-column:1}._15yekb7n{--animation-direction:1}
|
|
4
|
-
._1e0c1kw7{display:inherit}
|
|
5
|
-
._1e0c1txw{display:flex}
|
|
6
|
-
._1ul9idpf{min-width:0}
|
|
2
|
+
._yyhykb7n{grid-column:1}._1e0c1txw{display:flex}
|
|
7
3
|
._4cvr1h6o{align-items:center}
|
|
8
4
|
._4t3i1osq{height:100%}
|
|
9
|
-
.
|
|
10
|
-
._bozgutpp{padding-inline-start:var(--ds-space-150,9pt)}
|
|
11
|
-
._vchhusvi{box-sizing:border-box}
|
|
12
|
-
[dir=rtl] ._65m41mrw{--animation-direction:-1}
|
|
13
|
-
@media (prefers-reduced-motion:no-preference){._10t81e03{transition-property:transform}._10t81rjc{transition-property:transform,opacity}._1xq51ytf{transition-timing-function:ease-in-out}._1xq55ucs{transition-timing-function:ease}._mjvc1efy{transform:translateX(calc(100%*var(--animation-direction)))}._bgpzidpf{opacity:0}._mjvc1p9u{transform:translateX(calc(-100%*var(--animation-direction)))}._mjvco0k7{transform:translateX(calc((-2rem + var(--ds-space-050, 4px)*-1)*var(--animation-direction)))}._mjvcyrjp{transform:translateX(calc((2rem + var(--ds-space-050, 4px))*var(--animation-direction)))}._mjvcz12g{transform:translateX(0)}._xrrpfnf5{transition-duration:.2s}._bgpzkb7n{opacity:1}}
|
|
14
|
-
@media (min-width:64rem){._13wnh2mm{position:relative}._1l3vb3bt:after{content:""}._juxdstnw:after{position:absolute}._1vinidpf:after{inset-block-start:0}._1719idpf:after{inset-block-end:0}._e6znidpf:after{inset-inline-end:0}._1kyhe4h9:after{border-inline-end-width:var(--ds-border-width,1px)}._4cwynqa1:after{border-inline-end-style:solid}._435s1l7x:after{border-inline-end-color:var(--ds-border,#0b120e24)}._m7c3idpf:after{opacity:0}._15rin7od{min-width:unset}._glte1osq{width:100%}._4ap319ly{background-color:revert}._1m5lglyw:after{display:none}._glte1ris{width:max-content}._15rip2n4{min-width:330px}._1gs5usvi{box-sizing:border-box}._glte93mn{width:var(--n_sNvlw,100%)}._exxmutpp{padding-inline-end:var(--ds-space-150,9pt)}._4ap3vuon{background-color:var(--ds-surface,#fff)}._m7c3kb7n:after{opacity:1}}
|
|
15
|
-
@media (prefers-reduced-motion:no-preference) and (min-width:64rem){._n8qabrmi:after{transition-property:opacity}._wc72fnf5:after{transition-duration:.2s}._j3mr1v42:after{transition-timing-function:ease-in}}
|
|
5
|
+
@media (min-width:64rem){._glte1ris{width:max-content}._15rip2n4{min-width:330px}._1gs5usvi{box-sizing:border-box}}
|
|
@@ -1,149 +1,15 @@
|
|
|
1
1
|
/* top-nav-start.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
2
|
import "./top-nav-start.compiled.css";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
-
import React, {
|
|
5
|
-
import useStableRef from '@atlaskit/ds-lib/use-stable-ref';
|
|
6
|
-
import { OpenLayerObserverNamespaceProvider } from '@atlaskit/layering/open-layer-observer-namespace-provider';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
|
-
import { UNSAFE_useMediaQuery } from '@atlaskit/primitives/compiled';
|
|
4
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
9
5
|
import { TopNavStartAttachRef } from '../../../context/top-nav-start/top-nav-start-attach-ref';
|
|
10
|
-
import { useIsFhsEnabled } from '../../fhs-rollout/use-is-fhs-enabled';
|
|
11
|
-
import { useHasCustomTheme } from '../../top-nav-items/themed/has-custom-theme-context';
|
|
12
|
-
import { HasDefaultBackgroundColorContext } from '../../top-nav-items/themed/has-default-background-color-context';
|
|
13
|
-
import { openLayerObserverTopNavStartNamespace } from '../constants';
|
|
14
|
-
import { SideNavVisibilityState } from '../side-nav/side-nav-visibility-state';
|
|
15
|
-
import { useSideNavVisibility } from '../side-nav/use-side-nav-visibility';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Firefox does support these reorder animations, but only partially enabling layout animations would look odd.
|
|
19
|
-
*
|
|
20
|
-
* We are using JS to detect Firefox and disable animations, instead of using CSS, as Compiled currently does not merge duplicate
|
|
21
|
-
* CSS at-rules when at-rules are nested: https://github.com/atlassian-labs/compiled/blob/e04a325915e1d13010205089e4915de0e53bc2d4/packages/css/src/plugins/merge-duplicate-at-rules.ts#L5
|
|
22
|
-
* Avoiding nesting the `@supports` at-rule inside of `@media` means Compiled can remove duplicate styles from the generated CSS.
|
|
23
|
-
*/
|
|
24
|
-
let isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
25
|
-
|
|
26
|
-
// Placed in a variable, as the value is used in the translateX value for the children wrapper animation.
|
|
27
|
-
const flexGap = "var(--ds-space-050, 4px)";
|
|
28
6
|
|
|
29
7
|
/**
|
|
30
8
|
* Styles for the TopNavStart element.
|
|
31
|
-
*
|
|
32
|
-
* When `useIsFhsEnabled` is true this is the styling for the inner element,
|
|
33
|
-
* which re-enables pointer events.
|
|
34
9
|
*/
|
|
35
10
|
const innerStyles = {
|
|
36
|
-
root: "_zulp1b66 _yyhykb7n _4t3i1osq _4cvr1h6o _1e0c1txw _glte1ris _15rip2n4 _1gs5usvi"
|
|
37
|
-
fullHeightSidebarExpanded: "_15rin7od _glte1osq"
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Styles for the outer element, that does not have re-enabled pointer events and spans the entire
|
|
42
|
-
* width of the TopNavStart area.
|
|
43
|
-
*
|
|
44
|
-
* This wrapper element is only rendered when `useIsFhsEnabled` is true.
|
|
45
|
-
*/
|
|
46
|
-
const wrapperStyles = {
|
|
47
|
-
root: "_vchhusvi _bozgutpp _4t3i1osq _13wnh2mm _1l3vb3bt _juxdstnw _1vinidpf _1719idpf _e6znidpf _1kyhe4h9 _4cwynqa1 _435s1l7x _m7c3idpf",
|
|
48
|
-
fullHeightSidebarExpanded: "_glte93mn _exxmutpp _4ap3vuon _m7c3kb7n",
|
|
49
|
-
fullHeightSidebarBorderTransition: "_n8qabrmi _wc72fnf5 _j3mr1v42",
|
|
50
|
-
fullHeightSidebarCustomTheming: "_4ap319ly _1m5lglyw"
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* We use a fixed translateX offset for the slide animation (used when the TopNavStart children elements are reordered).
|
|
55
|
-
* This fixed offset makes the elements appear to animate smoothly from the old to the new position.
|
|
56
|
-
* This offset is calculated based on:
|
|
57
|
-
* - 32px (2rem) width of the side nav toggle button (IconButton)
|
|
58
|
-
* - 4px gap ('space.050' token) of the flex container
|
|
59
|
-
*
|
|
60
|
-
* The benefit of hardcoding this offset is that we don't need to calculate it using JS each time the sidebar is toggled.
|
|
61
|
-
* However, it could become out of sync if the width of IconButton changes.
|
|
62
|
-
*
|
|
63
|
-
* The alternative is using JS to store the previous position of the children wrapper element, and calculate the offset based on
|
|
64
|
-
* the new position, and then transforming using that offset. This would prevent the animation from going out of sync.
|
|
65
|
-
*/
|
|
66
|
-
const childrenWrapperAnimationOffset = `calc(2rem + ${flexGap})`;
|
|
67
|
-
const childrenWrapperStyles = {
|
|
68
|
-
root: "_zulp1kw7 _1e0c1kw7 _4cvr1h6o _1ul9idpf _15yekb7n _65m41mrw",
|
|
69
|
-
animationBaseStyles: "_10t81e03",
|
|
70
|
-
finalPosition: "_mjvcz12g _xrrpfnf5",
|
|
71
|
-
expandAnimationStartPosition: "_mjvcyrjp",
|
|
72
|
-
collapseAnimationStartPosition: "_mjvco0k7"
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* We use a fixed translateX offset for the toggle button slide animation (used when the TopNavStart children elements are reordered).
|
|
77
|
-
* The specific value doesn't matter too much for the toggle button animation, so we are using `100%`, which will match the toggle button width.
|
|
78
|
-
*
|
|
79
|
-
* By combining the `translateX` animation with an `opacity` fade, the feel and experience is actually quite similar to animating the
|
|
80
|
-
* element from the exact old position (offset), and it avoids the additional complexity of needing to track and calculate the exact offset.
|
|
81
|
-
*/
|
|
82
|
-
const toggleButtonWrapperStyles = {
|
|
83
|
-
root: "_15yekb7n _65m41mrw _10t81rjc",
|
|
84
|
-
finalPosition: "_mjvcz12g _xrrpfnf5 _bgpzkb7n",
|
|
85
|
-
expandAnimationStartPosition: "_mjvc1p9u _bgpzidpf",
|
|
86
|
-
collapseAnimationStartPosition: "_mjvc1efy _bgpzidpf",
|
|
87
|
-
expandAnimationTimingFunction: "_1xq51ytf",
|
|
88
|
-
collapseAnimationTimingFunction: "_1xq55ucs",
|
|
89
|
-
alignEnd: "_ahbq1wug"
|
|
11
|
+
root: "_zulp1b66 _yyhykb7n _4t3i1osq _4cvr1h6o _1e0c1txw _glte1ris _15rip2n4 _1gs5usvi"
|
|
90
12
|
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* The consistent key used for the side nav toggle button to ensure it does not get remounted
|
|
94
|
-
* when it is reordered.
|
|
95
|
-
*
|
|
96
|
-
* This ensures we get focus restoration for free.
|
|
97
|
-
*/
|
|
98
|
-
const sideNavToggleButtonKey = 'side-nav-toggle-button';
|
|
99
|
-
const TopNavStartInnerOld = /*#__PURE__*/forwardRef(function TopNavStartInner({
|
|
100
|
-
children,
|
|
101
|
-
testId
|
|
102
|
-
}, ref) {
|
|
103
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
104
|
-
ref: ref,
|
|
105
|
-
"data-testid": testId,
|
|
106
|
-
className: ax([innerStyles.root])
|
|
107
|
-
}, children);
|
|
108
|
-
});
|
|
109
|
-
const TopNavStartInnerFHS = /*#__PURE__*/forwardRef(function TopNavStartInnerFHS({
|
|
110
|
-
children,
|
|
111
|
-
testId
|
|
112
|
-
}, ref) {
|
|
113
|
-
// This needs the real `defaultCollapsed` state or will not SSR properly
|
|
114
|
-
// TODO: lift `defaultCollapsed` state to `Root` (DSP-23683)
|
|
115
|
-
// then context value will be correct in SSR / from initial render
|
|
116
|
-
const {
|
|
117
|
-
isExpandedOnDesktop
|
|
118
|
-
} = useSideNavVisibility({
|
|
119
|
-
defaultCollapsed: true
|
|
120
|
-
});
|
|
121
|
-
const sideNavState = useContext(SideNavVisibilityState);
|
|
122
|
-
const isFirstRenderRef = useRef(true);
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
// Ignore renders until the side nav state is initialized
|
|
125
|
-
// So that apps using the legacy API for setting side nav default state do not see
|
|
126
|
-
// animations when they shouldn't
|
|
127
|
-
if (sideNavState === null) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (isFirstRenderRef.current) {
|
|
131
|
-
isFirstRenderRef.current = false;
|
|
132
|
-
}
|
|
133
|
-
}, [sideNavState]);
|
|
134
|
-
const hasCustomTheme = useHasCustomTheme();
|
|
135
|
-
const hasDefaultBackgroundColor = useContext(HasDefaultBackgroundColorContext);
|
|
136
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
137
|
-
className: ax([wrapperStyles.root, isExpandedOnDesktop && wrapperStyles.fullHeightSidebarExpanded, !isFirstRenderRef.current && isExpandedOnDesktop && wrapperStyles.fullHeightSidebarBorderTransition, hasCustomTheme && !hasDefaultBackgroundColor && fg('platform_dst_nav4_custom_theming_fhs_1') && wrapperStyles.fullHeightSidebarCustomTheming])
|
|
138
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
139
|
-
ref: ref,
|
|
140
|
-
"data-testid": testId,
|
|
141
|
-
className: ax([innerStyles.root, isExpandedOnDesktop && innerStyles.fullHeightSidebarExpanded])
|
|
142
|
-
}, /*#__PURE__*/React.createElement(OpenLayerObserverNamespaceProvider, {
|
|
143
|
-
namespace: openLayerObserverTopNavStartNamespace
|
|
144
|
-
}, children)));
|
|
145
|
-
});
|
|
146
|
-
|
|
147
13
|
/**
|
|
148
14
|
* __TopNavStart__
|
|
149
15
|
*
|
|
@@ -154,7 +20,6 @@ export function TopNavStart({
|
|
|
154
20
|
testId,
|
|
155
21
|
sideNavToggleButton
|
|
156
22
|
}) {
|
|
157
|
-
const isFhsEnabled = useIsFhsEnabled();
|
|
158
23
|
const ref = useContext(TopNavStartAttachRef);
|
|
159
24
|
const elementRef = useRef(null);
|
|
160
25
|
|
|
@@ -163,111 +28,9 @@ export function TopNavStart({
|
|
|
163
28
|
useEffect(() => {
|
|
164
29
|
ref(elementRef.current);
|
|
165
30
|
}, [elementRef, ref]);
|
|
166
|
-
|
|
167
|
-
// This needs the real `defaultCollapsed` state or will not SSR properly
|
|
168
|
-
// TODO: lift `defaultCollapsed` state to `Root` (DSP-23683)
|
|
169
|
-
// then context value will be correct in SSR / from initial render
|
|
170
|
-
const {
|
|
171
|
-
isExpandedOnDesktop
|
|
172
|
-
} = useSideNavVisibility({
|
|
173
|
-
defaultCollapsed: true
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// For SSR assume desktop
|
|
177
|
-
const [isDesktop, setIsDesktop] = useState(true);
|
|
178
|
-
// Set state to real value on client
|
|
179
|
-
// This could result in some visible shift on mobile when hydrating SSR
|
|
180
|
-
// TODO: review and improve SSR behavior as necessary (DSP-23817)
|
|
181
|
-
useLayoutEffect(() => {
|
|
182
|
-
// Checking this to avoid breaking tests when `matchMedia` is not mocked
|
|
183
|
-
// Ideally we wouldn't cater to test environments, but this avoids introducing unnecessary friction
|
|
184
|
-
if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
|
|
185
|
-
setIsDesktop(window.matchMedia('(min-width: 64rem)').matches);
|
|
186
|
-
}
|
|
187
|
-
}, []);
|
|
188
|
-
UNSAFE_useMediaQuery('above.md', event => {
|
|
189
|
-
setIsDesktop(event.matches);
|
|
190
|
-
});
|
|
191
|
-
const [animationState, setAnimationState] = useState({
|
|
192
|
-
type: 'idle'
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
// Used to prevent the reorder animations from running on the initial render.
|
|
196
|
-
const isFirstRenderRef = useRef(true);
|
|
197
|
-
const sideNavState = useContext(SideNavVisibilityState);
|
|
198
|
-
useEffect(() => {
|
|
199
|
-
if (!isFhsEnabled) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Ignore renders until the side nav state is initialized
|
|
204
|
-
// So that apps using the legacy API for setting side nav default state do not see
|
|
205
|
-
// animations when they shouldn't
|
|
206
|
-
if (sideNavState === null) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (isFirstRenderRef.current) {
|
|
210
|
-
isFirstRenderRef.current = false;
|
|
211
|
-
}
|
|
212
|
-
}, [isFhsEnabled, sideNavState]);
|
|
213
|
-
|
|
214
|
-
// Using a stable ref to avoid re-running the animation layout effect when the toggle button prop value changes, which
|
|
215
|
-
// can happen a lot (e.g. if the parent re-renders)
|
|
216
|
-
const sideNavToggleButtonStableRef = useStableRef(sideNavToggleButton);
|
|
217
|
-
useLayoutEffect(() => {
|
|
218
|
-
if (!isFhsEnabled) {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* This layout effect is used to animate the TopNavStart children elements to their new position after being reordered.
|
|
224
|
-
* It is called when the sidebar's desktop expansion state changes.
|
|
225
|
-
*
|
|
226
|
-
* It works by first setting a translateX offset on the elements, used as the start position of the slide animation.
|
|
227
|
-
* - For the toggle button, it's a fixed offset. It's combined with an opacity, so the exact offset doesn't matter too much.
|
|
228
|
-
* - For the children wrapper (wrapping everything except the toggle button), an offset was chosen to make the animation
|
|
229
|
-
* start position the exact same as the element's old position. See comments for `childrenWrapperStyles` for more details.
|
|
230
|
-
*
|
|
231
|
-
* On the next frame, the translateX offset is cleared, triggering the animation to the new position.
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
if (isFirstRenderRef.current) {
|
|
235
|
-
// No animations on initial render.
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
if (!sideNavToggleButtonStableRef.current) {
|
|
239
|
-
// If there is no toggle button, there should be no re-order animations.
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// Set the translateX offsets so elements are ready to animate to their actual new position after being reordered
|
|
244
|
-
setAnimationState({
|
|
245
|
-
type: isExpandedOnDesktop ? 'expand' : 'collapse'
|
|
246
|
-
});
|
|
247
|
-
requestAnimationFrame(() => {
|
|
248
|
-
// Clear translateX offsets on next frame to trigger animation to new position in a re-render
|
|
249
|
-
setAnimationState({
|
|
250
|
-
type: 'idle'
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
// This layout effect is called when the sidebar's desktop expansion state changes.
|
|
255
|
-
}, [isExpandedOnDesktop, isFhsEnabled, sideNavToggleButtonStableRef]);
|
|
256
|
-
const TopNavStartInner = isFhsEnabled ? TopNavStartInnerFHS : TopNavStartInnerOld;
|
|
257
|
-
return /*#__PURE__*/React.createElement(TopNavStartInner, {
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
258
32
|
ref: elementRef,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
className: ax([!isFirefox && toggleButtonWrapperStyles.root, !isFirefox && animationState.type === 'idle' && toggleButtonWrapperStyles.finalPosition, !isFirefox &&
|
|
263
|
-
// Timing function is applied when the browser animates to the idle position.
|
|
264
|
-
animationState.type === 'idle' && toggleButtonWrapperStyles.collapseAnimationTimingFunction, !isFirefox && animationState.type === 'collapse' && toggleButtonWrapperStyles.collapseAnimationStartPosition])
|
|
265
|
-
}, sideNavToggleButton), isFhsEnabled ? /*#__PURE__*/React.createElement("div", {
|
|
266
|
-
className: ax([childrenWrapperStyles.root, !isFirefox && childrenWrapperStyles.animationBaseStyles, !isFirefox && animationState.type === 'idle' && childrenWrapperStyles.finalPosition, !isFirefox && animationState.type === 'expand' && childrenWrapperStyles.expandAnimationStartPosition, !isFirefox && animationState.type === 'collapse' && childrenWrapperStyles.collapseAnimationStartPosition])
|
|
267
|
-
}, children) : children, sideNavToggleButton && isDesktop && isExpandedOnDesktop && isFhsEnabled && /*#__PURE__*/React.createElement("div", {
|
|
268
|
-
key: sideNavToggleButtonKey,
|
|
269
|
-
className: ax([!isFirefox && toggleButtonWrapperStyles.root, toggleButtonWrapperStyles.alignEnd, !isFirefox && animationState.type === 'idle' && toggleButtonWrapperStyles.finalPosition, !isFirefox &&
|
|
270
|
-
// Timing function is applied when the browser animates to the idle position.
|
|
271
|
-
animationState.type === 'idle' && toggleButtonWrapperStyles.expandAnimationTimingFunction, !isFirefox && animationState.type === 'expand' && toggleButtonWrapperStyles.expandAnimationStartPosition])
|
|
272
|
-
}, sideNavToggleButton));
|
|
33
|
+
"data-testid": testId,
|
|
34
|
+
className: ax([innerStyles.root])
|
|
35
|
+
}, sideNavToggleButton, children);
|
|
273
36
|
}
|