@brillout/docpress 0.15.1 → 0.15.2
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/Layout.tsx +39 -25
- package/dist/types/Config.d.ts +3 -2
- package/package.json +1 -1
- package/types/Config.ts +5 -2
package/Layout.tsx
CHANGED
|
@@ -482,8 +482,36 @@ function NavHeaderLeftFullWidthBackground() {
|
|
|
482
482
|
|
|
483
483
|
function NavLogo({ className }: { className: string }) {
|
|
484
484
|
const pageContext = usePageContext()
|
|
485
|
-
|
|
486
|
-
const {
|
|
485
|
+
|
|
486
|
+
const { navLogo } = pageContext.globalContext.config.docpress
|
|
487
|
+
let navLogoResolved = navLogo
|
|
488
|
+
if (!navLogoResolved) {
|
|
489
|
+
const iconSize = pageContext.globalContext.config.docpress.navLogoSize ?? 39
|
|
490
|
+
const { name, logo, navLogoStyle, navLogoTextStyle } = pageContext.globalContext.config.docpress
|
|
491
|
+
navLogoResolved = (
|
|
492
|
+
<>
|
|
493
|
+
<img
|
|
494
|
+
src={logo}
|
|
495
|
+
style={{
|
|
496
|
+
height: iconSize,
|
|
497
|
+
width: iconSize,
|
|
498
|
+
...navLogoStyle,
|
|
499
|
+
}}
|
|
500
|
+
onContextMenu={onContextMenu}
|
|
501
|
+
/>
|
|
502
|
+
<span
|
|
503
|
+
style={{
|
|
504
|
+
marginLeft: `calc(var(--icon-text-padding) + 2px)`,
|
|
505
|
+
fontSize: isProjectNameShort(name) ? '1.65em' : '1.3em',
|
|
506
|
+
...navLogoTextStyle,
|
|
507
|
+
}}
|
|
508
|
+
>
|
|
509
|
+
{name}
|
|
510
|
+
</span>
|
|
511
|
+
</>
|
|
512
|
+
)
|
|
513
|
+
}
|
|
514
|
+
|
|
487
515
|
return (
|
|
488
516
|
<a
|
|
489
517
|
className={cls(['nav-logo', className])}
|
|
@@ -494,32 +522,18 @@ function NavLogo({ className }: { className: string }) {
|
|
|
494
522
|
color: 'inherit',
|
|
495
523
|
}}
|
|
496
524
|
href="/"
|
|
525
|
+
onContextMenu={!navLogo ? undefined : onContextMenu}
|
|
497
526
|
>
|
|
498
|
-
|
|
499
|
-
src={pageContext.globalContext.config.docpress.logo}
|
|
500
|
-
style={{
|
|
501
|
-
height: iconSize,
|
|
502
|
-
width: iconSize,
|
|
503
|
-
...pageContext.globalContext.config.docpress.navLogoStyle,
|
|
504
|
-
}}
|
|
505
|
-
onContextMenu={(ev) => {
|
|
506
|
-
if (!pageContext.globalContext.config.docpress.pressKit) return // no /press page
|
|
507
|
-
if (window.location.pathname === '/press') return
|
|
508
|
-
ev.preventDefault()
|
|
509
|
-
navigate('/press#logo')
|
|
510
|
-
}}
|
|
511
|
-
/>
|
|
512
|
-
<span
|
|
513
|
-
style={{
|
|
514
|
-
marginLeft: `calc(var(--icon-text-padding) + 2px)`,
|
|
515
|
-
fontSize: isProjectNameShort(name) ? '1.65em' : '1.3em',
|
|
516
|
-
...pageContext.globalContext.config.docpress.navLogoTextStyle,
|
|
517
|
-
}}
|
|
518
|
-
>
|
|
519
|
-
{name}
|
|
520
|
-
</span>
|
|
527
|
+
{navLogoResolved}
|
|
521
528
|
</a>
|
|
522
529
|
)
|
|
530
|
+
|
|
531
|
+
function onContextMenu(ev: React.MouseEvent<unknown, MouseEvent>) {
|
|
532
|
+
if (!pageContext.globalContext.config.docpress.pressKit) return // no /press page
|
|
533
|
+
if (window.location.pathname === '/press') return
|
|
534
|
+
ev.preventDefault()
|
|
535
|
+
navigate('/press#logo')
|
|
536
|
+
}
|
|
523
537
|
}
|
|
524
538
|
function isProjectNameShort(name: string) {
|
|
525
539
|
return name.length <= 4
|
package/dist/types/Config.d.ts
CHANGED
|
@@ -24,12 +24,13 @@ type Config = {
|
|
|
24
24
|
i18n?: true;
|
|
25
25
|
pressKit?: true;
|
|
26
26
|
docsDir?: string;
|
|
27
|
-
topNavigation?: React.ReactNode;
|
|
28
|
-
globalNote?: React.ReactNode;
|
|
29
27
|
navMaxWidth?: number;
|
|
28
|
+
topNavigation?: React.ReactNode;
|
|
29
|
+
navLogo?: React.ReactNode;
|
|
30
30
|
navLogoSize?: number;
|
|
31
31
|
navLogoStyle?: React.CSSProperties;
|
|
32
32
|
navLogoTextStyle?: React.CSSProperties;
|
|
33
|
+
globalNote?: React.ReactNode;
|
|
33
34
|
};
|
|
34
35
|
/** Order in Algolia search results */
|
|
35
36
|
type Category = string | {
|
package/package.json
CHANGED
package/types/Config.ts
CHANGED
|
@@ -30,13 +30,16 @@ type Config = {
|
|
|
30
30
|
i18n?: true
|
|
31
31
|
pressKit?: true
|
|
32
32
|
docsDir?: string
|
|
33
|
+
navMaxWidth?: number
|
|
33
34
|
|
|
34
35
|
topNavigation?: React.ReactNode
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
navLogo?: React.ReactNode
|
|
37
38
|
navLogoSize?: number
|
|
38
39
|
navLogoStyle?: React.CSSProperties
|
|
39
40
|
navLogoTextStyle?: React.CSSProperties
|
|
41
|
+
|
|
42
|
+
globalNote?: React.ReactNode
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
/** Order in Algolia search results */
|