@brillout/docpress 0.10.2 → 0.10.4

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 CHANGED
@@ -9,7 +9,6 @@ export { blockMargin }
9
9
 
10
10
  import React from 'react'
11
11
  import { getNavItemsWithComputed, NavItem, NavItemComponent } from './NavItemComponent'
12
- import { EditPageNote } from './components/EditPageNote'
13
12
  import { parseTitle } from './parseTitle'
14
13
  import { usePageContext, usePageContext2 } from './renderer/usePageContext'
15
14
  import { NavSecondaryContent } from './NavSecondaryContent'
@@ -22,7 +21,8 @@ import { css } from './utils/css'
22
21
  import { PassThrough } from './utils/PassTrough'
23
22
  import { Style } from './utils/Style'
24
23
  import { cls } from './utils/cls'
25
- import { iconBooks } from './icons'
24
+ import { iconBooks, iconPencil } from './icons'
25
+ import { getRepoHref, RepoLink } from './components'
26
26
 
27
27
  const blockMargin = 3
28
28
  const mainViewPadding = 20
@@ -87,7 +87,7 @@ function LayoutDocsPage({ children }: { children: React.ReactNode }) {
87
87
  const hideNavLeftAlways = pageContext.navItemsDetached && pageContext.navItemsDetached.length <= 1
88
88
  return (
89
89
  <>
90
- <style>{getStyle()}</style>
90
+ <Style>{getStyle()}</Style>
91
91
  <div style={{ display: 'flex', ...whitespaceBuster2 }}>
92
92
  <NavLeft />
93
93
  <div
@@ -182,9 +182,13 @@ function PageContent({ children }: { children: React.ReactNode }) {
182
182
  }}
183
183
  >
184
184
  {globalNote}
185
- {pageTitleParsed && <h1 id={`${pageContext.urlPathname.replace('/', '')}`}>{pageTitleParsed}</h1>}
185
+ {pageTitleParsed && (
186
+ <div>
187
+ <EditPageNote />
188
+ <h1 id={`${pageContext.urlPathname.replace('/', '')}`}>{pageTitleParsed}</h1>
189
+ </div>
190
+ )}
186
191
  {children}
187
- {!isLandingPage && <EditPageNote pageContext={pageContext} />}
188
192
  </div>
189
193
  </div>
190
194
  )
@@ -349,7 +353,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
349
353
  {navSecondaryContent}
350
354
  </div>
351
355
  </div>
352
- {getStyle()}
356
+ <Style>{getStyle()}</Style>
353
357
  </div>
354
358
  )
355
359
 
@@ -395,13 +399,6 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
395
399
  .desktop-grow {
396
400
  flex-grow: 1;
397
401
  }
398
- .desktop-fade {
399
- transition: opacity 0.4s ease-in-out;
400
- }
401
- html:not(.menu-modal-show) .nav-head-top:not(:hover) .desktop-fade {
402
- transition: opacity 0.3s ease-in-out !important;
403
- opacity: 0.5;
404
- }
405
402
  }
406
403
  `
407
404
  }
@@ -429,7 +426,7 @@ html:not(.unexpand-nav).menu-modal-show .show-on-nav-hover {
429
426
  }
430
427
  `
431
428
  }
432
- return <Style>{style}</Style>
429
+ return style
433
430
  }
434
431
  }
435
432
  function unexpandNav() {
@@ -608,7 +605,7 @@ function DocsIcon() {
608
605
  src={iconBooks}
609
606
  width={21}
610
607
  style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)' }}
611
- className="decolorize-5 desktop-fade"
608
+ className="decolorize-5"
612
609
  />
613
610
  )
614
611
  }
@@ -616,7 +613,7 @@ function MenuIcon() {
616
613
  return (
617
614
  <svg
618
615
  style={{ marginRight: 'calc(var(--icon-text-padding) + 2px)', verticalAlign: 'top', width: '1.3em' }}
619
- className="decolorize-6 desktop-fade"
616
+ className="decolorize-6"
620
617
  viewBox="0 0 448 512"
621
618
  >
622
619
  <path
@@ -626,3 +623,39 @@ function MenuIcon() {
626
623
  </svg>
627
624
  )
628
625
  }
626
+
627
+ function EditPageNote() {
628
+ const pageContext = usePageContext()
629
+ const iconSize = 17
630
+ const icon = (
631
+ <img
632
+ src={iconPencil}
633
+ width={iconSize}
634
+ height={iconSize}
635
+ style={{
636
+ marginRight: 9,
637
+ position: 'relative',
638
+ top: -1,
639
+ }}
640
+ />
641
+ )
642
+ const editLink = getRepoHref('/docs/pages' + pageContext.urlPathname + '/+Page.mdx', true)
643
+ return (
644
+ <a
645
+ href={editLink}
646
+ id="edit-link"
647
+ style={{ float: 'right', marginTop: 6, padding: 10, display: 'flex', alignItems: 'center' }}
648
+ >
649
+ {icon} Edit this page
650
+ <Style>{getStyle()}</Style>
651
+ </a>
652
+ )
653
+ function getStyle() {
654
+ return css`
655
+ @container container-viewport (max-width: 800px) {
656
+ #edit-link {
657
+ display: none !important;
658
+ }
659
+ }`
660
+ }
661
+ }
@@ -12,7 +12,7 @@ import './NavigationWithColumnLayout.css'
12
12
  import { Style } from '../utils/Style'
13
13
  import { css } from '../utils/css'
14
14
 
15
- const marginBottomOnExpand = 30
15
+ const marginBottomOnExpand = 20
16
16
  function NavigationWithColumnLayout(props: { navItems: NavItem[] }) {
17
17
  const pageContext = usePageContext()
18
18
  const navItemsWithComputed = getNavItemsWithComputed(props.navItems, pageContext.urlPathname)
@@ -31,7 +31,7 @@ function NavigationWithColumnLayout(props: { navItems: NavItem[] }) {
31
31
  <div
32
32
  id={`menu-navigation-${i}`}
33
33
  className="menu-navigation-content"
34
- style={{ paddingTop: 10, transition: 'none 0.2s ease-in-out', transitionProperty: 'opacity, transform' }}
34
+ style={{ transition: 'none 0.2s ease-in-out', transitionProperty: 'opacity, transform' }}
35
35
  key={i}
36
36
  >
37
37
  {columnLayout.isFullWidthCategory ? (
@@ -119,7 +119,6 @@ function NavigationWithColumnLayout(props: { navItems: NavItem[] }) {
119
119
  .menu-toggle-${i} {
120
120
  html.menu-modal-show.menu-modal-show-${i} & {
121
121
  color: black !important;
122
- cursor: default !important;
123
122
  [class^='decolorize-'],
124
123
  [class*=' decolorize-'] {
125
124
  filter: grayscale(0) opacity(1) !important;
@@ -128,6 +127,9 @@ function NavigationWithColumnLayout(props: { navItems: NavItem[] }) {
128
127
  top: 0;
129
128
  }
130
129
  }
130
+ html.menu-modal-show & {
131
+ cursor: default !important;
132
+ }
131
133
  }
132
134
  `
133
135
  })
package/MenuModal.tsx CHANGED
@@ -44,6 +44,8 @@ function MenuModal({ isTopNav }: { isTopNav: boolean }) {
44
44
  id="menu-modal-scroll-container"
45
45
  style={{
46
46
  overflowY: 'scroll',
47
+ // Workaround for bug with Firefox 128.1.0
48
+ overflowX: 'hidden',
47
49
  // We don't set `container` to the parent #menu-modal-wrapper beacuse of a Chrome bug (showing a blank <MenuModal>). Edit: IIRC because #menu-modal-wrapper has `position: fixed`.
48
50
  container: 'container-viewport / inline-size',
49
51
  }}
@@ -28,7 +28,6 @@ function NavSecondaryContent(props: { style?: React.CSSProperties }) {
28
28
  alignItems: 'center',
29
29
  ...props.style,
30
30
  }}
31
- className="desktop-fade"
32
31
  >
33
32
  {iconI18n}
34
33
  {projectInfo.discordInvite && (
@@ -4,15 +4,21 @@ import { usePageContext } from '../renderer/usePageContext'
4
4
 
5
5
  export { RepoLink }
6
6
  export { isRepoLink }
7
+ export { getRepoHref }
7
8
 
8
9
  function isRepoLink(href: string) {
9
10
  return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/'].some((start) => href.startsWith(start))
10
11
  }
11
12
 
12
13
  function RepoLink({ path, text, editMode }: { path: string; text?: string | JSX.Element; editMode?: true }) {
14
+ text = text || path
15
+ const href = getRepoHref(path, editMode)
16
+ return <a href={href}>{text}</a>
17
+ }
18
+
19
+ function getRepoHref(path: string, editMode?: true) {
13
20
  const pageContext = usePageContext()
14
21
  assert(isRepoLink(path), { path })
15
- text = text || path
16
22
  if (!path.startsWith('/')) {
17
23
  path = '/' + path
18
24
  }
@@ -21,5 +27,5 @@ function RepoLink({ path, text, editMode }: { path: string; text?: string | JSX.
21
27
  assert(githubRepository.startsWith('https://github.com/'))
22
28
  let href = `${githubRepository}/${viewMode}/main${path}`
23
29
  if (editMode) href += '?plain=1'
24
- return <a href={href}>{text}</a>
30
+ return href
25
31
  }
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
2
  export { RepoLink };
3
3
  export { isRepoLink };
4
+ export { getRepoHref };
4
5
  declare function isRepoLink(href: string): boolean;
5
6
  declare function RepoLink({ path, text, editMode }: {
6
7
  path: string;
7
8
  text?: string | JSX.Element;
8
9
  editMode?: true;
9
10
  }): React.JSX.Element;
11
+ declare function getRepoHref(path: string, editMode?: true): string;
@@ -3,14 +3,19 @@ import { assert } from '../utils/server';
3
3
  import { usePageContext } from '../renderer/usePageContext';
4
4
  export { RepoLink };
5
5
  export { isRepoLink };
6
+ export { getRepoHref };
6
7
  function isRepoLink(href) {
7
8
  return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/'].some(function (start) { return href.startsWith(start); });
8
9
  }
9
10
  function RepoLink(_a) {
10
11
  var path = _a.path, text = _a.text, editMode = _a.editMode;
12
+ text = text || path;
13
+ var href = getRepoHref(path, editMode);
14
+ return React.createElement("a", { href: href }, text);
15
+ }
16
+ function getRepoHref(path, editMode) {
11
17
  var pageContext = usePageContext();
12
18
  assert(isRepoLink(path), { path: path });
13
- text = text || path;
14
19
  if (!path.startsWith('/')) {
15
20
  path = '/' + path;
16
21
  }
@@ -20,5 +25,5 @@ function RepoLink(_a) {
20
25
  var href = "".concat(githubRepository, "/").concat(viewMode, "/main").concat(path);
21
26
  if (editMode)
22
27
  href += '?plain=1';
23
- return React.createElement("a", { href: href }, text);
28
+ return href;
24
29
  }
@@ -34,7 +34,7 @@ function SearchIcon() {
34
34
  src={iconMagnifyingGlass}
35
35
  width={21}
36
36
  style={{ marginRight: 'var(--icon-text-padding)' }}
37
- className="decolorize-7 desktop-fade"
37
+ className="decolorize-7"
38
38
  />
39
39
  )
40
40
  }
package/icons/index.ts CHANGED
@@ -3,3 +3,4 @@ export { default as iconGear } from './gear.svg'
3
3
  export { default as iconBooks } from './books.svg'
4
4
  export { default as iconSeedling } from './seedling.svg'
5
5
  export { default as iconMagnifyingGlass } from './magnifying-glass.svg'
6
+ export { default as iconPencil } from './pencil.svg'
@@ -0,0 +1,21 @@
1
+ <svg id="Layer_1_copy" width="120.14" height="120.14" version="1.1" viewBox="0 0 120.14 120.14" xmlns="http://www.w3.org/2000/svg">
2
+ <g transform="matrix(-1 0 0 1 124.07 -3.9276)">
3
+ <path d="m123.87 118.8-6.18-16.49-4.25-11.35c-0.96-2.93-1.14-4.14-2.77-5.77l-11.82-11.82-25.46 25.46 11.83 11.83c0.97 0.97 2.83 1.8 5.76 2.76l11.35 4.25 16.49 6.18c3.11 1.01 6.06-1.94 5.05-5.05z" fill="#ffecb3"/>
4
+ <g fill="none">
5
+ <path d="m85.65 106.83-0.03-0.03z"/>
6
+ <path d="m106.8 85.6 0.21 0.21c-0.07-0.07-0.12-0.16-0.19-0.23z"/>
7
+ </g>
8
+ <path d="m118.82 123.85-13.66-5.12s5.64-0.32 9.45-4.13 4.14-9.46 4.14-9.46l5.12 13.66c1.01 3.11-1.94 6.06-5.05 5.05z" fill="#616161"/>
9
+ <path d="m43.18 17.71-5.41 19.29-20.04 6.16-11.32-11.31c-3.12-3.12-4.6-9.34 3.67-17.61l4.99-4.99c7.15-7.15 13.68-5.98 16.8-2.86z" fill="#ef5350"/>
10
+ <path d="m34.27 44.64 10.37-10.37 60.23 60.23s1.23 5.12-1.9 8.25-8.47 2.12-8.47 2.12z" fill="#ffc107"/>
11
+ <path d="m26.73 52.18 58.58 58.58c9.46 2.06 9.05-6.03 9.05-6.03l-60.09-60.09z" fill="#ffa000"/>
12
+ <path d="m44.65 34.26 60.09 60.09s10.82 0 5.87-9.21l-58.42-58.42z" fill="#fdd835"/>
13
+ <polygon points="33.66 45.43 35.07 44.02 96.07 105.02 94.5 104.86 94.27 106.04" fill="#d1762c"/>
14
+ <polygon points="40.15 31.19 41.57 29.78 106.04 94.25 104.87 94.49 105.11 96.15" fill="#f19534"/>
15
+ <path d="m52.19 26.72s-5.47 8.09-10 12.67c-8.67 8.74-15.46 12.79-15.46 12.79l1.75 1.75c2.49-0.97 8.86-3.88 15.22-10.23 6.4-6.4 9.42-12.65 10.43-15.04z" fill="#4e342e" opacity=".2"/>
16
+ <path d="m23.49 51.9c0.56 0.56 1.35 0.81 2.13 0.68 0 0 8.19-2.5 16.33-10.64s10.83-16.07 10.83-16.07c0.13-0.78-0.12-1.58-0.68-2.14l-8.58-8.58c-0.36-0.36-0.86-0.55-1.36-0.49-0.17 0.02-0.34 0.04-0.52 0.07-0.68 0.1-1.22 0.6-1.41 1.26 0 0-3.92 7.6-10.38 14.05s-14.34 10.21-14.34 10.21c-0.66 0.18-1.17 0.71-1.27 1.39v0.02c-0.08 0.54 0.1 1.08 0.48 1.46z" fill="#94d1e0"/>
17
+ <ellipse transform="matrix(.7071 -.7071 .7071 .7071 -6.2293 15.05)" cx="15.05" cy="15.04" rx="15.03" ry="4.45" fill="#ff8383"/>
18
+ <path d="m41.61 21.74c-3.29 6.3-8.7 11.47-15.14 14.46-0.42 0.19-1.01 0.33-1.26-0.05-0.19-0.3-0.02-0.68 0.17-0.98 0.84-1.3 2-2.35 3.12-3.42 2.92-2.8 5.6-5.84 8.01-9.08 1.23-1.65 2.38-3.35 3.46-5.1 0.6-0.96 1.67-2.99 3.04-1.56 1.19 1.23-0.77 4.52-1.4 5.73z" fill="#b9e4ea"/>
19
+ <path d="m37.88 33.47c-0.26 0.27-0.53 0.54-0.66 0.89s-0.08 0.8 0.22 1.02c0.25 0.19 0.59 0.17 0.9 0.12 1.73-0.27 3.26-1.25 4.61-2.35 2.95-2.39 5.45-5.71 5.69-9.5 0.03-0.45 0.02-0.92-0.18-1.32-1.27-2.51-3.96 3.1-4.49 3.89-1.77 2.63-3.88 4.99-6.09 7.25z" fill="#b9e4ea"/>
20
+ </g>
21
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
@@ -1,17 +0,0 @@
1
- import React from 'react'
2
- import { RepoLink } from './RepoLink'
3
-
4
- export { EditPageNote }
5
-
6
- function EditPageNote({ pageContext }: { pageContext: { urlPathname: string } }) {
7
- const text = (
8
- <>
9
- <span style={{ fontFamily: 'emoji' }}>✍</span> Edit this page
10
- </>
11
- )
12
- return (
13
- <div style={{ marginTop: 50 }}>
14
- <RepoLink path={'/docs/pages' + pageContext.urlPathname + '/+Page.mdx'} text={text} editMode={true} />
15
- </div>
16
- )
17
- }