@brillout/docpress 0.16.47 → 0.16.48

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.
Files changed (41) hide show
  1. package/ExternalLinks.tsx +1 -1
  2. package/Layout.tsx +30 -101
  3. package/MenuModal.tsx +3 -2
  4. package/code-blocks/components/Pre.css +1 -0
  5. package/components/index.ts +0 -3
  6. package/css/code.css +1 -0
  7. package/css/font.css +1 -1
  8. package/css/heading.css +5 -0
  9. package/css/tooltip.css +1 -1
  10. package/dist/components/index.d.ts +0 -3
  11. package/dist/components/index.js +0 -3
  12. package/dist/renderer/usePageContext.d.ts +0 -16
  13. package/dist/renderer/usePageContext.js +0 -6
  14. package/dist/resolvePageContext.d.ts +1 -0
  15. package/dist/types/Heading.d.ts +6 -0
  16. package/dist/utils/server.d.ts +0 -2
  17. package/dist/utils/server.js +0 -2
  18. package/package.json +1 -1
  19. package/renderer/usePageContext.tsx +0 -7
  20. package/types/Heading.ts +6 -0
  21. package/utils/server.ts +0 -2
  22. package/components/Comment.tsx +0 -7
  23. package/components/HorizontalLine.tsx +0 -22
  24. package/components/P.css +0 -8
  25. package/components/P.tsx +0 -8
  26. package/dist/components/Comment.d.ts +0 -3
  27. package/dist/components/Comment.js +0 -5
  28. package/dist/components/HorizontalLine.d.ts +0 -5
  29. package/dist/components/HorizontalLine.js +0 -15
  30. package/dist/components/P.d.ts +0 -4
  31. package/dist/components/P.js +0 -6
  32. package/dist/utils/cls.d.ts +0 -3
  33. package/dist/utils/cls.js +0 -5
  34. package/dist/utils/filter.d.ts +0 -2
  35. package/dist/utils/filter.js +0 -11
  36. package/dist/utils/objectAssign.d.ts +0 -2
  37. package/dist/utils/objectAssign.js +0 -5
  38. package/utils/PassTrough.tsx +0 -7
  39. package/utils/filesystemPathHandling.ts +0 -42
  40. package/utils/filter.ts +0 -12
  41. package/utils/objectAssign.ts +0 -9
package/ExternalLinks.tsx CHANGED
@@ -63,7 +63,7 @@ function ChangelogButton() {
63
63
  className="button"
64
64
  style={{
65
65
  background: '#ffffff4f',
66
- fontFamily: 'monospace',
66
+ fontFamily: 'var(--font-mono, monospace)',
67
67
  letterSpacing: -1,
68
68
  display: 'flex',
69
69
  alignItems: 'center',
package/Layout.tsx CHANGED
@@ -69,7 +69,8 @@ const whitespaceBuster2: React.CSSProperties = {
69
69
 
70
70
  function Layout({ children }: { children: React.ReactNode }) {
71
71
  const pageContext = usePageContext()
72
- const { isLandingPage } = pageContext.resolved
72
+ const { isLandingPage, pageDesign } = pageContext.resolved
73
+ const isTopNavSticky = !isLandingPage && (pageDesign?.topNavSticky ?? true)
73
74
 
74
75
  let content: React.JSX.Element
75
76
  if (isLandingPage) {
@@ -86,6 +87,8 @@ function Layout({ children }: { children: React.ReactNode }) {
86
87
  ['--block-margin']: `${blockMargin}px`,
87
88
  // ['--nav-head-height']: `${isLandingPage ? 70 : 63}px`,
88
89
  ['--nav-head-height']: `63px`,
90
+ // Offset for elements sitting below the sticky top nav
91
+ ['--nav-head-sticky-offset']: isTopNavSticky ? 'var(--nav-head-height)' : '0px',
89
92
  ['--main-view-padding']: `${mainViewPadding}px`,
90
93
  // We don't add `container` to `body` nor `html` beacuse in Firefox it breaks the `position: fixed` of <MenuModal>
91
94
  // https://stackoverflow.com/questions/74601420/css-container-inline-size-and-fixed-child
@@ -94,9 +97,12 @@ function Layout({ children }: { children: React.ReactNode }) {
94
97
  margin: 'auto',
95
98
  }}
96
99
  >
97
- <MenuModal isTopNav={isLandingPage} isNavLeftAlwaysHidden_={isNavLeftAlwaysHidden_} />
98
- <div className={isLandingPage ? '' : 'doc-page'} style={whitespaceBuster1}>
99
- <NavHead />
100
+ <div className={isLandingPage ? 'landing-page' : 'doc-page'} style={whitespaceBuster1}>
101
+ <div style={{ position: isTopNavSticky ? 'sticky' : 'relative', top: 0, zIndex: 100 }}>
102
+ <NavHead />
103
+ {/* <MenuModal> is inside here because `container-type` on the page wrapper traps `position: fixed` — https://github.com/brillout/docpress/pull/177 */}
104
+ <MenuModal isNavLeftAlwaysHidden_={isNavLeftAlwaysHidden_} />
105
+ </div>
100
106
  {content}
101
107
  </div>
102
108
  {/* Early toggling, to avoid layout jumps */}
@@ -220,10 +226,10 @@ function NavLeft() {
220
226
  <div
221
227
  style={{
222
228
  position: 'sticky',
223
- top: 0,
229
+ // Sit below the sticky top nav (or at the very top when the top nav isn't sticky)
230
+ top: 'var(--nav-head-sticky-offset)',
224
231
  }}
225
232
  >
226
- <NavHead isNavLeft={true} />
227
233
  <div
228
234
  style={{
229
235
  backgroundColor: 'var(--color-bg-gray)',
@@ -233,7 +239,7 @@ function NavLeft() {
233
239
  id="navigation-container"
234
240
  style={{
235
241
  top: 0,
236
- height: `calc(100vh - var(--nav-head-height) - var(--block-margin))`,
242
+ height: `calc(100vh - var(--nav-head-sticky-offset) - var(--block-margin))`,
237
243
  overflowY: 'auto',
238
244
  overscrollBehavior: 'contain',
239
245
  paddingBottom: 40,
@@ -296,29 +302,18 @@ const menuLinkStyle: React.CSSProperties = {
296
302
  justifyContent: 'center',
297
303
  }
298
304
 
299
- // Two <NavHead> instances are rendered:
300
- // - The left-side <NavHead> shown on documentation pages on desktop
301
- // - The top <NavHead> shown otherwise
302
- function NavHead({ isNavLeft }: { isNavLeft?: true }) {
305
+ function NavHead() {
303
306
  const pageContext = usePageContext()
304
307
  const { navMaxWidth, name, algolia } = pageContext.globalContext.config.docpress
305
308
  const hideNavHeadLogo = pageContext.resolved.isLandingPage && !navMaxWidth
306
309
 
307
310
  const navHeadSecondary = (
308
311
  <div
309
- className={cls(['nav-head-secondary', isNavLeft && 'show-on-nav-hover add-transition'])}
312
+ className="nav-head-secondary"
310
313
  style={{
311
314
  padding: 0,
312
315
  display: 'flex',
313
316
  height: '100%',
314
- ...(isNavLeft
315
- ? {
316
- position: 'absolute',
317
- left: '100%',
318
- top: 0,
319
- width: mainViewWidthMax, // guaranteed real estate
320
- }
321
- : {}),
322
317
  }}
323
318
  >
324
319
  {pageContext.globalContext.config.docpress.topNavigation}
@@ -336,26 +331,29 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
336
331
 
337
332
  return (
338
333
  <div
339
- className={cls(['nav-head link-hover-animation', isNavLeft && 'is-nav-left', !!navMaxWidth && 'has-max-width'])}
334
+ className={cls(['nav-head link-hover-animation', !!navMaxWidth && 'has-max-width'])}
340
335
  style={{
341
336
  backgroundColor: 'var(--color-bg-gray)',
342
- borderBottom: 'var(--block-margin) solid var(--color-bg-white)',
343
337
  position: 'relative',
338
+ boxShadow: `0 ${blockMargin}px 0 var(--color-bg-white)`,
344
339
  }}
345
340
  >
346
- {isNavLeft && <NavHeadLeftFullWidthBackground />}
347
341
  <div
348
342
  style={{
349
343
  // DON'T REMOVE this container: it's needed for the `cqw` values
350
344
  container: 'container-nav-head / inline-size',
351
345
  width: '100%',
346
+ // Cap the cqw context so nav-item spacing matches between landing and doc pages.
347
+ maxWidth: bodyMaxWidth,
348
+ margin: '0 auto',
352
349
  }}
353
350
  >
354
351
  <div
355
352
  className="nav-head-content"
356
353
  style={{
357
354
  width: '100%',
358
- maxWidth: navMaxWidth,
355
+ // Top nav spans the doc-page width so its logo lines up with the sidebar (same width on landing).
356
+ maxWidth: bodyMaxWidth,
359
357
  margin: 'auto',
360
358
  height: 'var(--nav-head-height)',
361
359
  fontSize: `min(14.2px, ${isProjectNameShort(name) ? '4.8cqw' : '4.5cqw'})`,
@@ -364,7 +362,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
364
362
  justifyContent: 'center',
365
363
  }}
366
364
  >
367
- {!hideNavHeadLogo && <NavHeadLogo isNavLeft={isNavLeft} />}
365
+ {!hideNavHeadLogo && <NavHeadLogo />}
368
366
  <div className="desktop-grow" style={{ display: 'none' }} />
369
367
  {algolia && <SearchLink className="always-shown" style={menuLinkStyle} />}
370
368
  <MenuToggleMain className="always-shown nav-head-menu-toggle" style={menuLinkStyle} />
@@ -380,7 +378,7 @@ function getStyleLayout() {
380
378
  // Mobile
381
379
  style += css`
382
380
  @media(max-width: ${viewMobile}px) {
383
- .nav-head:not(.is-nav-left) {
381
+ .nav-head {
384
382
  .nav-head-menu-toggle {
385
383
  justify-content: flex-end !important;
386
384
  padding-right: var(--main-view-padding) !important;
@@ -397,7 +395,7 @@ function getStyleLayout() {
397
395
  // Mobile + tablet
398
396
  style += css`
399
397
  @media(max-width: ${viewTablet}px) {
400
- .nav-head:not(.is-nav-left) {
398
+ .nav-head {
401
399
  .nav-head-secondary {
402
400
  display: none !important;
403
401
  }
@@ -407,7 +405,7 @@ function getStyleLayout() {
407
405
  // Tablet
408
406
  style += css`
409
407
  @media(max-width: ${viewTablet}px) and (min-width: ${viewMobile + 1}px) {
410
- .nav-head:not(.is-nav-left) {
408
+ .nav-head {
411
409
  .nav-head-content {
412
410
  --icon-text-padding: 8px;
413
411
  --padding-side: 20px;
@@ -418,7 +416,7 @@ function getStyleLayout() {
418
416
  // Desktop small + desktop
419
417
  style += css`
420
418
  @media(min-width: ${viewTablet + 1}px) {
421
- .nav-head:not(.is-nav-left) {
419
+ .nav-head {
422
420
  .nav-head-content {
423
421
  --icon-text-padding: min(8px, 0.5cqw);
424
422
  --padding-side: min(20px, 1.2cqw);
@@ -442,39 +440,6 @@ function getStyleLayout() {
442
440
  // Desktop
443
441
  if (!isNavLeftAlwaysHidden()) {
444
442
  style += css`
445
- @container container-viewport (min-width: ${viewDesktop}px) {
446
- .nav-head:not(.is-nav-left) {
447
- display: none !important;
448
- }
449
- .nav-head.is-nav-left {
450
- .nav-head-content {
451
- --icon-text-padding: min(8px, 7 * (1cqw - 2.5px));
452
- & > :not(.always-shown) {
453
- --padding-side: min(24px, 27 * (1cqw - 2.5px));
454
- }
455
- & > * {
456
- flex-grow: 0.5;
457
- }
458
- & > .nav-head-menu-toggle {
459
- flex-grow: 1;
460
- }
461
- }
462
- }
463
- .show-on-nav-hover {
464
- opacity: 0;
465
- transition-property: opacity;
466
- pointer-events: none;
467
- }
468
- html:not(.unexpand-nav) {
469
- & .nav-head.is-nav-left:hover .show-on-nav-hover,
470
- &:has(.nav-head:hover) #menu-modal-wrapper.show-on-nav-hover,
471
- &.menu-modal-show .nav-head.is-nav-left .show-on-nav-hover,
472
- &.menu-modal-show #menu-modal-wrapper.show-on-nav-hover {
473
- opacity: 1;
474
- pointer-events: all;
475
- }
476
- }
477
- }
478
443
  @container container-viewport (max-width: ${viewDesktop - 1}px) {
479
444
  #nav-left, #nav-left-margin {
480
445
  display: none;
@@ -514,37 +479,7 @@ function unexpandNav() {
514
479
  }, 1000)
515
480
  }
516
481
 
517
- function NavHeadLeftFullWidthBackground() {
518
- return (
519
- <>
520
- <div
521
- className="nav-head-bg show-on-nav-hover add-transition"
522
- style={{
523
- height: '100%',
524
- zIndex: -1,
525
- background: 'var(--color-bg-gray)',
526
- position: 'absolute',
527
- left: 0,
528
- top: 0,
529
- boxSizing: 'content-box',
530
- borderBottom: 'var(--block-margin) solid var(--color-bg-white)',
531
- }}
532
- />
533
- <Style>{
534
- // (min-width: 0px) => trick to always apply => @container seems to always require a condition
535
- css`
536
- @container container-viewport (min-width: 0px) {
537
- .nav-head-bg {
538
- width: 100cqw;
539
- }
540
- }
541
- `
542
- }</Style>
543
- </>
544
- )
545
- }
546
-
547
- function NavHeadLogo({ isNavLeft }: { isNavLeft?: true }) {
482
+ function NavHeadLogo() {
548
483
  const pageContext = usePageContext()
549
484
 
550
485
  const { navLogo } = pageContext.globalContext.config.docpress
@@ -584,14 +519,8 @@ function NavHeadLogo({ isNavLeft }: { isNavLeft?: true }) {
584
519
  alignItems: 'center',
585
520
  height: '100%',
586
521
  color: 'inherit',
587
- ...(!isNavLeft
588
- ? {
589
- paddingLeft: 'var(--main-view-padding)',
590
- paddingRight: 'var(--padding-side)',
591
- }
592
- : {
593
- paddingLeft: 15,
594
- }),
522
+ paddingLeft: 'var(--main-view-padding)',
523
+ paddingRight: 'var(--padding-side)',
595
524
  }}
596
525
  href="/"
597
526
  onContextMenu={!navLogo ? undefined : onContextMenu}
package/MenuModal.tsx CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  } from './MenuModal/toggleMenuModal.js'
15
15
  import { EditLink } from './EditLink.js'
16
16
 
17
- function MenuModal({ isTopNav, isNavLeftAlwaysHidden_ }: { isTopNav: boolean; isNavLeftAlwaysHidden_: boolean }) {
17
+ function MenuModal({ isNavLeftAlwaysHidden_ }: { isNavLeftAlwaysHidden_: boolean }) {
18
18
  return (
19
19
  <>
20
20
  <Style>{getStyle()}</Style>
@@ -22,7 +22,8 @@ function MenuModal({ isTopNav, isNavLeftAlwaysHidden_ }: { isTopNav: boolean; is
22
22
  id="menu-modal-wrapper"
23
23
  className="link-hover-animation add-transition show-on-nav-hover"
24
24
  style={{
25
- position: isTopNav ? 'absolute' : 'fixed',
25
+ // Absolute inside the sticky header so the dropdown tracks the nav on scroll
26
+ position: 'absolute',
26
27
  width: '100%',
27
28
  top: 'var(--nav-head-height)',
28
29
  zIndex: 199, // maximum value, because docsearch's modal has `z-index: 200`
@@ -5,6 +5,7 @@ pre > code {
5
5
  */
6
6
  background: rgba(0, 0, 0, 0.043137255);
7
7
  font-size: 1em;
8
+ font-family: var(--font-mono, monospace);
8
9
  }
9
10
 
10
11
  /* Copy button */
@@ -1,11 +1,8 @@
1
1
  export * from '../utils/Emoji/index.js'
2
2
  export * from './Link.js'
3
3
  export * from './RepoLink.js'
4
- export * from './P.js'
5
4
  export * from './Note.js'
6
5
  export * from './ImportMeta.js'
7
- export * from './HorizontalLine.js'
8
6
  export * from './CodeBlockTransformer.js'
9
- export * from './Comment.js'
10
7
  export * from './FileRemoved.js'
11
8
  export * from '../code-blocks/components/Tabs.js'
package/css/code.css CHANGED
@@ -10,4 +10,5 @@ code {
10
10
  border-radius: 4px;
11
11
  background: rgba(0, 0, 0, 0.063137255);
12
12
  font-size: 1.1em;
13
+ font-family: var(--font-mono, monospace);
13
14
  }
package/css/font.css CHANGED
@@ -1,7 +1,7 @@
1
1
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
2
2
 
3
3
  body {
4
- font-family: 'Inter', sans-serif;
4
+ font-family: var(--font-sans, 'Inter', sans-serif);
5
5
  }
6
6
  button {
7
7
  font-family: inherit;
package/css/heading.css CHANGED
@@ -13,6 +13,11 @@ h3 {
13
13
  margin-bottom: 20px;
14
14
  }
15
15
 
16
+ /* Offset headings below the sticky top nav (no offset if top nav isn't sticky). */
17
+ .doc-page :is(h1, h2, h3, h4, h5, h6) {
18
+ scroll-margin-top: calc(var(--nav-head-sticky-offset) + 16px);
19
+ }
20
+
16
21
  .doc-page h2,
17
22
  .doc-page h3 {
18
23
  margin-bottom: 16px;
package/css/tooltip.css CHANGED
@@ -13,7 +13,7 @@
13
13
  opacity: 0;
14
14
  transition: opacity 0.3s ease-in-out;
15
15
  pointer-events: none;
16
- font-family: monospace;
16
+ font-family: var(--font-mono, monospace);
17
17
  font-size: 12px;
18
18
  content: attr(aria-label);
19
19
  position: absolute;
@@ -1,11 +1,8 @@
1
1
  export * from '../utils/Emoji/index.js';
2
2
  export * from './Link.js';
3
3
  export * from './RepoLink.js';
4
- export * from './P.js';
5
4
  export * from './Note.js';
6
5
  export * from './ImportMeta.js';
7
- export * from './HorizontalLine.js';
8
6
  export * from './CodeBlockTransformer.js';
9
- export * from './Comment.js';
10
7
  export * from './FileRemoved.js';
11
8
  export * from '../code-blocks/components/Tabs.js';
@@ -1,11 +1,8 @@
1
1
  export * from '../utils/Emoji/index.js';
2
2
  export * from './Link.js';
3
3
  export * from './RepoLink.js';
4
- export * from './P.js';
5
4
  export * from './Note.js';
6
5
  export * from './ImportMeta.js';
7
- export * from './HorizontalLine.js';
8
6
  export * from './CodeBlockTransformer.js';
9
- export * from './Comment.js';
10
7
  export * from './FileRemoved.js';
11
8
  export * from '../code-blocks/components/Tabs.js';
@@ -1,23 +1,7 @@
1
1
  export { PageContextProvider };
2
2
  export { usePageContext };
3
- export { usePageContextLegacy };
4
3
  import React from 'react';
5
4
  import type { PageContext } from 'vike/types';
6
- declare function usePageContextLegacy(): {
7
- navItemsAll: import("../NavItemComponent.js").NavItem[];
8
- navItemsDetached: import("../NavItemComponent.js").NavItem[] | undefined;
9
- pageDesign: {
10
- hideTitle?: true;
11
- hideMenuLeft?: true;
12
- contentMaxWidth?: number;
13
- } | undefined;
14
- linksAll: import("../components/Link.js").LinkData[];
15
- isLandingPage: boolean;
16
- pageTitle: string | null;
17
- documentTitle: string;
18
- activeCategoryName: string;
19
- choices: import("../code-blocks/utils/resolveChoices.js").ResolvedChoices | undefined;
20
- };
21
5
  declare function usePageContext(): PageContext;
22
6
  declare function PageContextProvider({ pageContext, children, }: {
23
7
  pageContext: PageContext;
@@ -1,16 +1,10 @@
1
1
  export { PageContextProvider };
2
2
  export { usePageContext };
3
- export { usePageContextLegacy };
4
3
  import React, { useContext } from 'react';
5
4
  import { getGlobalObject } from '../utils/getGlobalObject.js';
6
5
  const globalObject = getGlobalObject('usePageContext.ts', {
7
6
  Ctx: React.createContext(undefined),
8
7
  });
9
- function usePageContextLegacy() {
10
- const { Ctx } = globalObject;
11
- const pageContext = useContext(Ctx);
12
- return pageContext.resolved;
13
- }
14
8
  function usePageContext() {
15
9
  const pageContext = useContext(globalObject.Ctx);
16
10
  return pageContext;
@@ -10,6 +10,7 @@ declare function resolvePageContext(pageContext: PageContextServer): {
10
10
  hideTitle?: true;
11
11
  hideMenuLeft?: true;
12
12
  contentMaxWidth?: number;
13
+ topNavSticky?: boolean;
13
14
  } | undefined;
14
15
  linksAll: LinkData[];
15
16
  isLandingPage: boolean;
@@ -24,6 +24,12 @@ type PageDesign = {
24
24
  hideTitle?: true;
25
25
  hideMenuLeft?: true;
26
26
  contentMaxWidth?: number;
27
+ /**
28
+ * Whether the top navigation sticks to the top of the viewport while scrolling.
29
+ *
30
+ * @default true
31
+ */
32
+ topNavSticky?: boolean;
27
33
  };
28
34
  type HeadingDetachedResolved = Omit<HeadingResolved, 'level' | 'linkBreadcrumb'> & {
29
35
  level: 2;
@@ -1,7 +1,5 @@
1
1
  export * from './client.js';
2
2
  export * from './isBrowser.js';
3
- export * from './filter.js';
4
3
  export * from './determineSectionUrlHash.js';
5
4
  export * from './jsxToTextContent.js';
6
- export * from './objectAssign.js';
7
5
  export * from './Emoji/index.js';
@@ -1,7 +1,5 @@
1
1
  export * from './client.js';
2
2
  export * from './isBrowser.js';
3
- export * from './filter.js';
4
3
  export * from './determineSectionUrlHash.js';
5
4
  export * from './jsxToTextContent.js';
6
- export * from './objectAssign.js';
7
5
  export * from './Emoji/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.16.47",
3
+ "version": "0.16.48",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
@@ -1,6 +1,5 @@
1
1
  export { PageContextProvider }
2
2
  export { usePageContext }
3
- export { usePageContextLegacy }
4
3
 
5
4
  import React, { useContext } from 'react'
6
5
  import type { PageContext } from 'vike/types'
@@ -10,12 +9,6 @@ const globalObject = getGlobalObject('usePageContext.ts', {
10
9
  Ctx: React.createContext<PageContext>(undefined as any),
11
10
  })
12
11
 
13
- function usePageContextLegacy() {
14
- const { Ctx } = globalObject
15
- const pageContext = useContext(Ctx)
16
- return pageContext.resolved
17
- }
18
-
19
12
  function usePageContext(): PageContext {
20
13
  const pageContext = useContext(globalObject.Ctx)
21
14
  return pageContext
package/types/Heading.ts CHANGED
@@ -28,6 +28,12 @@ type PageDesign = {
28
28
  hideTitle?: true
29
29
  hideMenuLeft?: true
30
30
  contentMaxWidth?: number
31
+ /**
32
+ * Whether the top navigation sticks to the top of the viewport while scrolling.
33
+ *
34
+ * @default true
35
+ */
36
+ topNavSticky?: boolean
31
37
  }
32
38
 
33
39
  type HeadingDetachedResolved = Omit<HeadingResolved, 'level' | 'linkBreadcrumb'> & {
package/utils/server.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  export * from './client.js'
2
2
  export * from './isBrowser.js'
3
- export * from './filter.js'
4
3
  export * from './determineSectionUrlHash.js'
5
4
  export * from './jsxToTextContent.js'
6
- export * from './objectAssign.js'
7
5
  export * from './Emoji/index.js'
@@ -1,7 +0,0 @@
1
- export { Comment }
2
-
3
- import React from 'react'
4
-
5
- function Comment() {
6
- return <></>
7
- }
@@ -1,22 +0,0 @@
1
- export { HorizontalLine }
2
-
3
- import React from 'react'
4
- import { cls } from '../utils/cls.js'
5
-
6
- function HorizontalLine({ primary }: { primary?: true }) {
7
- return (
8
- <div className={cls(primary && 'primary')} style={{ textAlign: 'center' }}>
9
- <hr
10
- style={{
11
- display: 'inline-block',
12
- margin: 0,
13
- border: 0,
14
- // Same as `.doc-page h2::after`
15
- borderTop: '1px solid var(--color-border, rgba(0, 0, 0, 0.1))',
16
- maxWidth: 500,
17
- width: '80%',
18
- }}
19
- />
20
- </div>
21
- )
22
- }
package/components/P.css DELETED
@@ -1,8 +0,0 @@
1
- /* Copied from Chrome's user agent stylesheet */
2
- div.paragraph {
3
- display: block;
4
- margin-block-start: 1em;
5
- margin-block-end: 1em;
6
- margin-inline-start: 0px;
7
- margin-inline-end: 0px;
8
- }
package/components/P.tsx DELETED
@@ -1,8 +0,0 @@
1
- import React from 'react'
2
- import './P.css'
3
-
4
- export { P }
5
-
6
- function P(props: React.HTMLProps<HTMLDivElement>) {
7
- return <div {...props} className={'paragraph'} />
8
- }
@@ -1,3 +0,0 @@
1
- export { Comment };
2
- import React from 'react';
3
- declare function Comment(): React.JSX.Element;
@@ -1,5 +0,0 @@
1
- export { Comment };
2
- import React from 'react';
3
- function Comment() {
4
- return React.createElement(React.Fragment, null);
5
- }
@@ -1,5 +0,0 @@
1
- export { HorizontalLine };
2
- import React from 'react';
3
- declare function HorizontalLine({ primary }: {
4
- primary?: true;
5
- }): React.JSX.Element;
@@ -1,15 +0,0 @@
1
- export { HorizontalLine };
2
- import React from 'react';
3
- import { cls } from '../utils/cls.js';
4
- function HorizontalLine({ primary }) {
5
- return (React.createElement("div", { className: cls(primary && 'primary'), style: { textAlign: 'center' } },
6
- React.createElement("hr", { style: {
7
- display: 'inline-block',
8
- margin: 0,
9
- border: 0,
10
- // Same as `.doc-page h2::after`
11
- borderTop: '1px solid var(--color-border, rgba(0, 0, 0, 0.1))',
12
- maxWidth: 500,
13
- width: '80%',
14
- } })));
15
- }
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import './P.css';
3
- export { P };
4
- declare function P(props: React.HTMLProps<HTMLDivElement>): React.JSX.Element;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import './P.css';
3
- export { P };
4
- function P(props) {
5
- return React.createElement("div", { ...props, className: 'paragraph' });
6
- }
@@ -1,3 +0,0 @@
1
- export { cls };
2
- type Class = string | boolean | undefined;
3
- declare function cls(className: Class | Class[]): string;
package/dist/utils/cls.js DELETED
@@ -1,5 +0,0 @@
1
- export { cls };
2
- function cls(className) {
3
- const classNames = Array.isArray(className) ? className : [className];
4
- return classNames.filter(Boolean).join(' ');
5
- }
@@ -1,2 +0,0 @@
1
- export { filter };
2
- declare function filter<T extends object>(obj: T, predicate: <K extends keyof T>(value: T[K], key: K) => boolean): T;
@@ -1,11 +0,0 @@
1
- export { filter };
2
- // https://stackoverflow.com/questions/66341757/typescript-how-to-filter-the-object
3
- function filter(obj, predicate) {
4
- const result = {};
5
- Object.keys(obj).forEach((name) => {
6
- if (predicate(obj[name], name)) {
7
- result[name] = obj[name];
8
- }
9
- });
10
- return result;
11
- }
@@ -1,2 +0,0 @@
1
- export { objectAssign };
2
- declare function objectAssign<Obj extends Object, ObjAddendum>(obj: Obj, objAddendum: ObjAddendum): asserts obj is Obj & ObjAddendum;
@@ -1,5 +0,0 @@
1
- export { objectAssign };
2
- // Same as `Object.assign()` but with type inference
3
- function objectAssign(obj, objAddendum) {
4
- Object.assign(obj, objAddendum);
5
- }
@@ -1,7 +0,0 @@
1
- export { PassThrough }
2
-
3
- import React from 'react'
4
-
5
- function PassThrough({ children }: any) {
6
- return <>{children}</>
7
- }
@@ -1,42 +0,0 @@
1
- export { toPosixPath }
2
- export { assertPosixPath }
3
- export { toSystemPath }
4
-
5
- import assert from 'assert'
6
-
7
- const sepPosix = '/'
8
- const sepWin32 = '\\'
9
-
10
- function toPosixPath(path: string) {
11
- if (isPosix()) {
12
- assertPosixPath(path)
13
- return path
14
- }
15
- if (isWin32()) {
16
- const pathPosix = path.split(sepWin32).join(sepPosix)
17
- assertPosixPath(pathPosix)
18
- return pathPosix
19
- }
20
- assert(false)
21
- }
22
-
23
- function assertPosixPath(path: string) {
24
- assert(path && !path.includes(sepWin32), `Wrongly formatted path: ${path}`)
25
- }
26
-
27
- function toSystemPath(path: string) {
28
- if (isPosix()) {
29
- return toPosixPath(path)
30
- }
31
- if (isWin32()) {
32
- return path.split(sepPosix).join(sepWin32)
33
- }
34
- assert(false)
35
- }
36
-
37
- function isWin32() {
38
- return process.platform === 'win32'
39
- }
40
- function isPosix() {
41
- return !isWin32()
42
- }
package/utils/filter.ts DELETED
@@ -1,12 +0,0 @@
1
- export { filter }
2
-
3
- // https://stackoverflow.com/questions/66341757/typescript-how-to-filter-the-object
4
- function filter<T extends object>(obj: T, predicate: <K extends keyof T>(value: T[K], key: K) => boolean): T {
5
- const result: { [K in keyof T]?: T[K] } = {}
6
- ;(Object.keys(obj) as Array<keyof T>).forEach((name) => {
7
- if (predicate(obj[name], name)) {
8
- result[name] = obj[name]
9
- }
10
- })
11
- return result as T
12
- }
@@ -1,9 +0,0 @@
1
- export { objectAssign }
2
-
3
- // Same as `Object.assign()` but with type inference
4
- function objectAssign<Obj extends Object, ObjAddendum>(
5
- obj: Obj,
6
- objAddendum: ObjAddendum,
7
- ): asserts obj is Obj & ObjAddendum {
8
- Object.assign(obj, objAddendum)
9
- }