@brillout/docpress 0.15.13-commit-253f5e5 → 0.15.13-commit-1d03f73
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/ExternalLinks.tsx +1 -0
- package/Layout.tsx +4 -3
- package/MenuModal/NavigationWithColumnLayout.tsx +5 -4
- package/MenuModal.tsx +2 -2
- package/package.json +1 -1
package/ExternalLinks.tsx
CHANGED
package/Layout.tsx
CHANGED
|
@@ -70,6 +70,7 @@ function Layout({ children }: { children: React.ReactNode }) {
|
|
|
70
70
|
content = <LayoutDocsPage>{children}</LayoutDocsPage>
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
const isNavLeftHidden = isNavLeftAlwaysHidden()
|
|
73
74
|
return (
|
|
74
75
|
<div
|
|
75
76
|
style={{
|
|
@@ -81,11 +82,11 @@ function Layout({ children }: { children: React.ReactNode }) {
|
|
|
81
82
|
// We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
|
|
82
83
|
// https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
|
|
83
84
|
container: 'container-viewport / inline-size',
|
|
84
|
-
maxWidth: bodyMaxWidth,
|
|
85
|
+
maxWidth: isNavLeftHidden ? undefined : bodyMaxWidth,
|
|
85
86
|
margin: 'auto',
|
|
86
87
|
}}
|
|
87
88
|
>
|
|
88
|
-
<MenuModal isTopNav={isLandingPage} />
|
|
89
|
+
<MenuModal isTopNav={isLandingPage} isNavLeftHidden={isNavLeftHidden} />
|
|
89
90
|
<div className={isLandingPage ? '' : 'doc-page'} style={whitespaceBuster1}>
|
|
90
91
|
<NavHead />
|
|
91
92
|
{content}
|
|
@@ -270,7 +271,7 @@ function NavigationContent(props: {
|
|
|
270
271
|
function isNavLeftAlwaysHidden() {
|
|
271
272
|
const pageContext = usePageContext()
|
|
272
273
|
const { isLandingPage, navItemsDetached, pageDesign } = pageContext.resolved
|
|
273
|
-
return isLandingPage || pageDesign?.hideMenuLeft || (navItemsDetached && navItemsDetached.length <= 1)
|
|
274
|
+
return isLandingPage || !!pageDesign?.hideMenuLeft || !!(navItemsDetached && navItemsDetached.length <= 1)
|
|
274
275
|
}
|
|
275
276
|
|
|
276
277
|
const menuLinkStyle: React.CSSProperties = {
|
|
@@ -3,7 +3,7 @@ export { NavigationWithColumnLayout }
|
|
|
3
3
|
import React, { useEffect, useState } from 'react'
|
|
4
4
|
import { assert } from '../utils/server'
|
|
5
5
|
import { getViewportWidth } from '../utils/getViewportWidth'
|
|
6
|
-
import { viewTablet, navLeftWidthMax, navLeftWidthMin } from '../Layout'
|
|
6
|
+
import { viewTablet, navLeftWidthMax, navLeftWidthMin, bodyMaxWidth } from '../Layout'
|
|
7
7
|
import { throttle } from '../utils/throttle'
|
|
8
8
|
import { Collapsible } from './Collapsible'
|
|
9
9
|
import { ColumnMap, getNavItemsWithComputed, NavItem, NavItemComponent, NavItemComputed } from '../NavItemComponent'
|
|
@@ -22,7 +22,8 @@ function NavigationWithColumnLayout(props: { navItems: NavItem[] }) {
|
|
|
22
22
|
updateviewportwidth()
|
|
23
23
|
window.addEventListener('resize', throttle(updateviewportwidth, 300), { passive: true })
|
|
24
24
|
})
|
|
25
|
-
const
|
|
25
|
+
const availableWidth = viewportWidth && Math.min(viewportWidth, bodyMaxWidth)
|
|
26
|
+
const navItemsByColumnLayouts = getNavItemsByColumnLayouts(navItemsWithComputed, availableWidth)
|
|
26
27
|
const columnWidthBase = navLeftWidthMax + 20
|
|
27
28
|
const maxColumns = Math.max(...navItemsByColumnLayouts.map((layout) => layout.columns.length), 1)
|
|
28
29
|
const widthMax = maxColumns * columnWidthBase
|
|
@@ -222,9 +223,9 @@ type NavItemsByColumnLayout =
|
|
|
222
223
|
columns: { navItems: NavItemComputed[] }[]
|
|
223
224
|
isFullWidthCategory: true
|
|
224
225
|
}
|
|
225
|
-
function getNavItemsByColumnLayouts(navItems: NavItemComputed[],
|
|
226
|
+
function getNavItemsByColumnLayouts(navItems: NavItemComputed[], availableWidth: number = 0): NavItemsByColumnLayout[] {
|
|
226
227
|
const navItemsByColumnEntries = getNavItemsByColumnEntries(navItems)
|
|
227
|
-
const numberOfColumnsMax = Math.floor(
|
|
228
|
+
const numberOfColumnsMax = Math.floor(availableWidth / navLeftWidthMin) || 1
|
|
228
229
|
const navItemsByColumnLayouts: NavItemsByColumnLayout[] = navItemsByColumnEntries.map(
|
|
229
230
|
({ columnEntries, isFullWidthCategory }) => {
|
|
230
231
|
const numberOfColumns = Math.min(numberOfColumnsMax, columnEntries.length)
|
package/MenuModal.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import { NavigationWithColumnLayout } from './MenuModal/NavigationWithColumnLayo
|
|
|
10
10
|
import { closeMenuModal, closeMenuModalOnMouseLeave, keepMenuModalOpenOnMouseOver } from './MenuModal/toggleMenuModal'
|
|
11
11
|
import { EditLink } from './EditLink'
|
|
12
12
|
|
|
13
|
-
function MenuModal({ isTopNav }: { isTopNav: boolean }) {
|
|
13
|
+
function MenuModal({ isTopNav, isNavLeftHidden }: { isTopNav: boolean; isNavLeftHidden: boolean }) {
|
|
14
14
|
return (
|
|
15
15
|
<>
|
|
16
16
|
<Style>{getStyle()}</Style>
|
|
@@ -25,7 +25,7 @@ function MenuModal({ isTopNav }: { isTopNav: boolean }) {
|
|
|
25
25
|
background: '#ededef',
|
|
26
26
|
transitionProperty: 'opacity',
|
|
27
27
|
transitionTimingFunction: 'ease',
|
|
28
|
-
maxWidth: bodyMaxWidth,
|
|
28
|
+
maxWidth: isNavLeftHidden ? undefined : bodyMaxWidth,
|
|
29
29
|
// Horizontal align
|
|
30
30
|
// https://stackoverflow.com/questions/3157372/css-horizontal-centering-of-a-fixed-div/32694476#32694476
|
|
31
31
|
left: '50%',
|