@redocly/theme 0.7.5 → 0.8.1

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 (52) hide show
  1. package/lib/Markdown/Admonition.d.ts +3 -1
  2. package/lib/Markdown/Admonition.js +2 -2
  3. package/lib/Markdown/CodeSample/CodeSample.d.ts +3 -1
  4. package/lib/Markdown/CodeSample/CodeSample.js +2 -2
  5. package/lib/Markdown/Heading.d.ts +3 -1
  6. package/lib/Markdown/Heading.js +6 -4
  7. package/lib/Markdown/Mermaid.d.ts +3 -1
  8. package/lib/Markdown/Mermaid.js +2 -2
  9. package/lib/Sidebar/MenuGroup.js +2 -2
  10. package/lib/Sidebar/Sidebar.d.ts +1 -0
  11. package/lib/Sidebar/Sidebar.js +5 -2
  12. package/lib/Sidebar/SidebarLayout.d.ts +2 -1
  13. package/lib/Sidebar/SidebarLayout.js +2 -2
  14. package/lib/TableOfContent/TableOfContent.js +1 -1
  15. package/lib/config.d.ts +123 -37
  16. package/lib/config.js +32 -32
  17. package/lib/globalStyle.js +3 -2
  18. package/lib/hooks/useActiveHeading.js +2 -7
  19. package/lib/hooks/useActiveSectionId.js +1 -1
  20. package/lib/hooks/useMobileMenu.js +1 -1
  21. package/lib/icons/AnchorIcon/AnchorIcon.d.ts +7 -0
  22. package/lib/icons/AnchorIcon/AnchorIcon.js +23 -0
  23. package/lib/icons/AnchorIcon/index.d.ts +2 -0
  24. package/lib/icons/AnchorIcon/index.js +6 -0
  25. package/lib/icons/ArrowIcon/ArrowIcon.d.ts +1 -0
  26. package/lib/icons/ArrowIcon/ArrowIcon.js +1 -0
  27. package/lib/icons/index.d.ts +1 -0
  28. package/lib/icons/index.js +1 -0
  29. package/lib/index.d.ts +1 -0
  30. package/lib/index.js +1 -0
  31. package/lib/ui/Jumbotron.js +2 -2
  32. package/package.json +3 -7
  33. package/src/Markdown/Admonition.tsx +10 -1
  34. package/src/Markdown/CodeSample/CodeSample.tsx +15 -2
  35. package/src/Markdown/Heading.tsx +12 -18
  36. package/src/Markdown/Mermaid.tsx +9 -1
  37. package/src/Sidebar/MenuGroup.tsx +5 -2
  38. package/src/Sidebar/Sidebar.tsx +6 -2
  39. package/src/Sidebar/SidebarLayout.tsx +3 -1
  40. package/src/TableOfContent/TableOfContent.tsx +1 -1
  41. package/src/config.ts +35 -32
  42. package/src/globalStyle.ts +3 -2
  43. package/src/hooks/useActiveHeading.ts +3 -12
  44. package/src/hooks/useActiveSectionId.ts +1 -1
  45. package/src/hooks/useMobileMenu.ts +2 -2
  46. package/src/icons/AnchorIcon/AnchorIcon.tsx +36 -0
  47. package/src/icons/AnchorIcon/index.ts +2 -0
  48. package/src/icons/ArrowIcon/ArrowIcon.tsx +2 -0
  49. package/src/icons/index.ts +1 -0
  50. package/src/index.ts +1 -0
  51. package/src/types/portal/src/shared/types/nav.d.ts +1 -1
  52. package/src/ui/Jumbotron.tsx +2 -2
@@ -4,6 +4,8 @@ interface AdmonitionTypeProps {
4
4
  }
5
5
  export interface AdmonitionProps extends Partial<AdmonitionTypeProps> {
6
6
  name?: string;
7
+ 'data-source'?: string;
8
+ 'data-hash'?: string;
7
9
  }
8
- export declare function Admonition({ type, name, children, }: React.PropsWithChildren<AdmonitionProps>): JSX.Element;
10
+ export declare function Admonition({ type, name, children, 'data-source': dataSource, 'data-hash': dataHash, }: React.PropsWithChildren<AdmonitionProps>): JSX.Element;
9
11
  export {};
@@ -7,8 +7,8 @@ exports.Admonition = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
9
  const AlertIcon_1 = require("../icons/AlertIcon/AlertIcon");
10
- function Admonition({ type = 'info', name, children, }) {
11
- return (react_1.default.createElement(Wrapper, { type: type, "data-component-name": "Markdown/Admonition" },
10
+ function Admonition({ type = 'info', name, children, 'data-source': dataSource, 'data-hash': dataHash, }) {
11
+ return (react_1.default.createElement(Wrapper, { type: type, "data-component-name": "Markdown/Admonition", "data-source": dataSource, "data-hash": dataHash },
12
12
  react_1.default.createElement(AlertIcon_1.AlertIcon, { type: type }),
13
13
  name ? react_1.default.createElement(Heading, { type: type }, name) : null,
14
14
  react_1.default.createElement(Content, null, children)));
@@ -3,5 +3,7 @@ export type CodeSampleProps = {
3
3
  language: string;
4
4
  highlighted: string;
5
5
  rawContent: string;
6
+ 'data-source'?: string;
7
+ 'data-hash'?: string;
6
8
  };
7
- export declare function CodeSample({ rawContent, highlighted, language }: CodeSampleProps): JSX.Element;
9
+ export declare function CodeSample({ rawContent, highlighted, language, 'data-source': dataSource, 'data-hash': dataHash, }: CodeSampleProps): JSX.Element;
@@ -29,7 +29,7 @@ const styled_components_1 = __importStar(require("styled-components"));
29
29
  const ClipboardService_1 = require("../../utils/ClipboardService");
30
30
  const useThemeConfig_1 = require("../../hooks/useThemeConfig");
31
31
  const Feedback_1 = require("../../Feedback");
32
- function CodeSample({ rawContent, highlighted, language }) {
32
+ function CodeSample({ rawContent, highlighted, language, 'data-source': dataSource, 'data-hash': dataHash, }) {
33
33
  const langClassName = language ? `language-${language}` : '';
34
34
  const { codeSnippet: { copy = {}, report = {} } = {} } = (0, useThemeConfig_1.useThemeConfig)();
35
35
  const [isCopied, setIsCopied] = (0, react_1.useState)(false);
@@ -39,7 +39,7 @@ function CodeSample({ rawContent, highlighted, language }) {
39
39
  setIsCopied(true);
40
40
  setTimeout(() => setIsCopied(false), copy.toasterDuration || 1500);
41
41
  };
42
- return (react_1.default.createElement(Wrapper, { className: "code-sample", "data-component-name": "Markdown/CodeSample/CodeSample" },
42
+ return (react_1.default.createElement(Wrapper, { className: "code-sample", "data-component-name": "Markdown/CodeSample/CodeSample", "data-source": dataSource, "data-hash": dataHash },
43
43
  react_1.default.createElement(CodeSampleButtonContainer, null,
44
44
  !copy.hide && (react_1.default.createElement(react_1.default.Fragment, null,
45
45
  !isCopied && (react_1.default.createElement(Button, { onClick: () => copyCode(rawContent), title: copy.tooltipText || 'Copy to clipboard' }, copy.buttonText || 'Copy')),
@@ -1,5 +1,7 @@
1
1
  import type { PropsWithChildren } from 'react';
2
- export declare function Heading({ level, id, children, }: PropsWithChildren<{
2
+ export declare function Heading({ level, id, children, 'data-source': dataSource, 'data-hash': dataHash, }: PropsWithChildren<{
3
3
  level: number;
4
4
  id: string;
5
+ 'data-source'?: string;
6
+ 'data-hash'?: string;
5
7
  }>): JSX.Element;
@@ -26,18 +26,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Heading = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
28
  const utils_1 = require("../utils");
29
+ const icons_1 = require("../icons");
29
30
  /**
30
31
  * Class name for all MD tags
31
32
  */
32
33
  const mdClassName = 'md';
33
- const SvgIcon = (react_1.default.createElement("svg", { "aria-hidden": "true", focusable: "false", height: "16", version: "1.1", viewBox: "0 0 16 16", width: "16" },
34
- react_1.default.createElement("path", { fillRule: "evenodd", d: "M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" })));
35
- function Heading({ level, id, children, }) {
36
- const linkEl = (react_1.default.createElement("a", { href: `#${id}`, className: (0, utils_1.concatClassNames)('anchor', 'before') }, SvgIcon));
34
+ function Heading({ level, id, children, 'data-source': dataSource, 'data-hash': dataHash, }) {
35
+ const linkEl = (react_1.default.createElement("a", { href: `#${id}`, className: (0, utils_1.concatClassNames)('anchor', 'before') },
36
+ react_1.default.createElement(icons_1.AnchorIcon, null)));
37
37
  return (0, react_1.createElement)(`h${level}`, {
38
38
  id,
39
39
  className: (0, utils_1.concatClassNames)('heading-anchor', mdClassName),
40
40
  'data-component-name': 'Markdown/Heading',
41
+ 'data-source': dataSource,
42
+ 'data-hash': dataHash,
41
43
  }, react_1.default.createElement(react_1.default.Fragment, null,
42
44
  linkEl,
43
45
  children));
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  type MermaidProps = {
3
3
  diagramHtml: string;
4
+ 'data-source'?: string;
5
+ 'data-hash'?: string;
4
6
  };
5
- export declare function Mermaid({ diagramHtml }: MermaidProps): JSX.Element;
7
+ export declare function Mermaid({ diagramHtml, 'data-source': dataSource, 'data-hash': dataHash, }: MermaidProps): JSX.Element;
6
8
  export {};
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Mermaid = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
- function Mermaid({ diagramHtml }) {
10
- return (react_1.default.createElement(Wrapper, { className: "mermaid-wrapper", dangerouslySetInnerHTML: { __html: diagramHtml }, "data-component-name": "Markdown/Mermaid" }));
9
+ function Mermaid({ diagramHtml, 'data-source': dataSource, 'data-hash': dataHash, }) {
10
+ return (react_1.default.createElement(Wrapper, { className: "mermaid-wrapper", dangerouslySetInnerHTML: { __html: diagramHtml }, "data-component-name": "Markdown/Mermaid", "data-source": dataSource, "data-hash": dataHash }));
11
11
  }
12
12
  exports.Mermaid = Mermaid;
13
13
  const Wrapper = styled_components_1.default.div `
@@ -53,7 +53,7 @@ function MenuGroup({ item, isExpanded, toggleExpanded, children, }) {
53
53
  return (react_1.default.createElement(Wrapper, { "data-component-name": "Sidebar/MenuGroup" },
54
54
  react_1.default.createElement(MenuLinkItem_1.MenuLinkItem, { item: item },
55
55
  react_1.default.createElement(MenuGroupLabel, { onClick: toggleExpanded, isAlwaysExpanded: item.expanded === 'always', active: item.active },
56
- react_1.default.createElement(MenuGroupArrow, { direction: isExpanded ? 'down' : 'right' }),
56
+ react_1.default.createElement(MenuGroupArrow, { visibility: item.items.length ? 'visible' : 'hidden', direction: isExpanded ? 'down' : 'right' }),
57
57
  item.label)),
58
58
  react_1.default.createElement(MenuWrapper, { isExpanded: isExpanded }, showChildren ? children : null),
59
59
  item.separatorLine ? react_1.default.createElement(SeparatorLine_1.SeparatorLine, null) : null));
@@ -64,7 +64,7 @@ const MenuWrapper = styled_components_1.default.div `
64
64
  padding-left: var(--sidebar-item-nested-offset);
65
65
  overflow: hidden;
66
66
  ${(props) => props.isExpanded
67
- ? `max-height: 9999px;
67
+ ? `max-height: 99999px;
68
68
  transition: max-height .8s cubic-bezier(0.5, 0, 1, 0) 0s;`
69
69
  : `max-height: 0px;
70
70
  transition: max-height .8s cubic-bezier(0, 1, 0, 1) -.1s;`};
@@ -1,4 +1,5 @@
1
1
  interface SidebarProps {
2
+ isNavbar: boolean;
2
3
  opened?: boolean;
3
4
  animate?: boolean;
4
5
  }
@@ -18,13 +18,16 @@ exports.Sidebar = styled_components_1.default.aside.attrs(() => ({
18
18
  font-size: var(--sidebar-item-font-size);
19
19
  font-family: var(--sidebar-item-font-family);
20
20
  color: var(--sidebar-item-text-color);
21
- top: var(--navbar-height);
22
- height: calc(100vh - var(--navbar-height));
23
21
  display: flex;
24
22
  flex-direction: column;
25
23
  width: 100%;
26
24
  -webkit-font-smoothing: antialiased;
27
25
 
26
+ ${({ isNavbar }) => `
27
+ top: ${isNavbar ? 'var(--navbar-height)' : '0'};
28
+ height: calc(100vh ${isNavbar ? '- var(--navbar-height)' : ''});
29
+ `};
30
+
28
31
  ${({ opened, animate }) => `
29
32
  opacity: ${opened ? '1' : '0'};
30
33
  pointer-events: ${opened ? 'auto' : 'none'};
@@ -6,6 +6,7 @@ interface SidebarLayoutProps {
6
6
  label: string;
7
7
  slug: string;
8
8
  };
9
+ isNavbar: boolean;
9
10
  }
10
- export declare function SidebarLayout({ versions, menu, backLink, }: SidebarLayoutProps): JSX.Element | null;
11
+ export declare function SidebarLayout({ versions, menu, backLink, isNavbar, }: SidebarLayoutProps): JSX.Element | null;
11
12
  export {};
@@ -14,7 +14,7 @@ const SidebarSearch_1 = require("../Search/SidebarSearch");
14
14
  const useThemeConfig_1 = require("../hooks/useThemeConfig");
15
15
  const ArrowBack_1 = require("../Sidebar/ArrowBack");
16
16
  const Link_1 = require("../mocks/Link");
17
- function SidebarLayout({ versions, menu, backLink, }) {
17
+ function SidebarLayout({ versions, menu, backLink, isNavbar, }) {
18
18
  const [isOpen, setIsOpen] = (0, useMobileMenu_1.useMobileMenu)();
19
19
  const toggleMenu = () => setIsOpen(!isOpen);
20
20
  const { search, sidebar } = (0, useThemeConfig_1.useThemeConfig)();
@@ -24,7 +24,7 @@ function SidebarLayout({ versions, menu, backLink, }) {
24
24
  return (react_1.default.createElement(Wrapper, { "data-component-name": "Sidebar/SidebarLayout" },
25
25
  react_1.default.createElement(MobileSidebarButton_1.MobileSidebarButton, { opened: isOpen, onClick: toggleMenu }),
26
26
  !(search === null || search === void 0 ? void 0 : search.hide) && (search === null || search === void 0 ? void 0 : search.placement) === 'sidebar' ? react_1.default.createElement(SidebarSearch_1.SidebarSearch, null) : null,
27
- react_1.default.createElement(Sidebar_1.Sidebar, { animate: true, opened: isOpen },
27
+ react_1.default.createElement(Sidebar_1.Sidebar, { animate: true, opened: isOpen, isNavbar: isNavbar },
28
28
  (backLink && (react_1.default.createElement(BackLinkWrapper, null,
29
29
  react_1.default.createElement(Link_1.Link, { to: backLink.slug },
30
30
  react_1.default.createElement(ArrowBack_1.ArrowBack, null),
@@ -104,6 +104,6 @@ const TableOfContentItems = styled_components_1.default.div `
104
104
  max-height: calc(100vh - var(--navbar-height) - var(--toc-offset-top));
105
105
  border-left: 1px solid var(--toc-border-color);
106
106
  overflow-y: auto;
107
- width: var(--toc-width); ;
107
+ width: var(--toc-width);
108
108
  `;
109
109
  //# sourceMappingURL=TableOfContent.js.map
package/lib/config.d.ts CHANGED
@@ -1,4 +1,88 @@
1
1
  import { z } from 'zod';
2
+ declare const MarkdownConfig: z.ZodDefault<z.ZodObject<{
3
+ frontMatterKeysToResolve: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
4
+ lastUpdatedBlock: z.ZodOptional<z.ZodDefault<z.ZodObject<z.extendShape<{
5
+ format: z.ZodOptional<z.ZodDefault<z.ZodEnum<["timeago", "iso", "long", "short"]>>>;
6
+ locale: z.ZodOptional<z.ZodDefault<z.ZodString>>;
7
+ }, {
8
+ hide: z.ZodOptional<z.ZodBoolean>;
9
+ }>, "strip", z.ZodTypeAny, {
10
+ hide?: boolean | undefined;
11
+ format?: "timeago" | "iso" | "long" | "short" | undefined;
12
+ locale?: string | undefined;
13
+ }, {
14
+ hide?: boolean | undefined;
15
+ format?: "timeago" | "iso" | "long" | "short" | undefined;
16
+ locale?: string | undefined;
17
+ }>>>;
18
+ toc: z.ZodDefault<z.ZodOptional<z.ZodObject<z.extendShape<{
19
+ header: z.ZodOptional<z.ZodDefault<z.ZodString>>;
20
+ depth: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
21
+ }, {
22
+ hide: z.ZodOptional<z.ZodBoolean>;
23
+ }>, "strip", z.ZodTypeAny, {
24
+ hide?: boolean | undefined;
25
+ header?: string | undefined;
26
+ depth?: number | undefined;
27
+ }, {
28
+ hide?: boolean | undefined;
29
+ header?: string | undefined;
30
+ depth?: number | undefined;
31
+ }>>>;
32
+ editPage: z.ZodOptional<z.ZodDefault<z.ZodObject<z.extendShape<{
33
+ baseUrl: z.ZodOptional<z.ZodString>;
34
+ icon: z.ZodOptional<z.ZodString>;
35
+ text: z.ZodDefault<z.ZodOptional<z.ZodString>>;
36
+ }, {
37
+ hide: z.ZodOptional<z.ZodBoolean>;
38
+ }>, "strip", z.ZodTypeAny, {
39
+ hide?: boolean | undefined;
40
+ baseUrl?: string | undefined;
41
+ icon?: string | undefined;
42
+ text: string;
43
+ }, {
44
+ hide?: boolean | undefined;
45
+ baseUrl?: string | undefined;
46
+ icon?: string | undefined;
47
+ text?: string | undefined;
48
+ }>>>;
49
+ }, "strict", z.ZodTypeAny, {
50
+ frontMatterKeysToResolve?: string[] | undefined;
51
+ lastUpdatedBlock?: {
52
+ hide?: boolean | undefined;
53
+ format?: "timeago" | "iso" | "long" | "short" | undefined;
54
+ locale?: string | undefined;
55
+ } | undefined;
56
+ editPage?: {
57
+ hide?: boolean | undefined;
58
+ baseUrl?: string | undefined;
59
+ icon?: string | undefined;
60
+ text: string;
61
+ } | undefined;
62
+ toc: {
63
+ hide?: boolean | undefined;
64
+ header?: string | undefined;
65
+ depth?: number | undefined;
66
+ };
67
+ }, {
68
+ frontMatterKeysToResolve?: string[] | undefined;
69
+ lastUpdatedBlock?: {
70
+ hide?: boolean | undefined;
71
+ format?: "timeago" | "iso" | "long" | "short" | undefined;
72
+ locale?: string | undefined;
73
+ } | undefined;
74
+ toc?: {
75
+ hide?: boolean | undefined;
76
+ header?: string | undefined;
77
+ depth?: number | undefined;
78
+ } | undefined;
79
+ editPage?: {
80
+ hide?: boolean | undefined;
81
+ baseUrl?: string | undefined;
82
+ icon?: string | undefined;
83
+ text?: string | undefined;
84
+ } | undefined;
85
+ }>>;
2
86
  export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
3
87
  imports: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
4
88
  logo: z.ZodOptional<z.ZodObject<{
@@ -417,9 +501,9 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
417
501
  text: string;
418
502
  }, {
419
503
  hide?: boolean | undefined;
420
- text?: string | undefined;
421
504
  baseUrl?: string | undefined;
422
505
  icon?: string | undefined;
506
+ text?: string | undefined;
423
507
  }>>>;
424
508
  }, "strict", z.ZodTypeAny, {
425
509
  frontMatterKeysToResolve?: string[] | undefined;
@@ -453,9 +537,9 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
453
537
  } | undefined;
454
538
  editPage?: {
455
539
  hide?: boolean | undefined;
456
- text?: string | undefined;
457
540
  baseUrl?: string | undefined;
458
541
  icon?: string | undefined;
542
+ text?: string | undefined;
459
543
  } | undefined;
460
544
  }>>>;
461
545
  openapi: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
@@ -479,6 +563,23 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
479
563
  logoutRedirect?: string | undefined;
480
564
  }>>>;
481
565
  }, "passthrough", z.ZodTypeAny, {
566
+ links?: {
567
+ type?: string | undefined;
568
+ crossorigin?: string | undefined;
569
+ fetchpriority?: string | undefined;
570
+ integrity?: string | undefined;
571
+ referrerpolicy?: string | undefined;
572
+ as?: string | undefined;
573
+ hreflang?: string | undefined;
574
+ imagesizes?: string | undefined;
575
+ imagesrcset?: string | undefined;
576
+ media?: string | undefined;
577
+ prefetch?: string | undefined;
578
+ rel?: string | undefined;
579
+ sizes?: string | undefined;
580
+ title?: string | undefined;
581
+ href: string;
582
+ }[] | undefined;
482
583
  imports?: string[] | undefined;
483
584
  logo?: {
484
585
  image?: string | undefined;
@@ -526,23 +627,6 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
526
627
  src: string;
527
628
  }[] | undefined;
528
629
  } | undefined;
529
- links?: {
530
- type?: string | undefined;
531
- crossorigin?: string | undefined;
532
- fetchpriority?: string | undefined;
533
- integrity?: string | undefined;
534
- referrerpolicy?: string | undefined;
535
- as?: string | undefined;
536
- hreflang?: string | undefined;
537
- imagesizes?: string | undefined;
538
- imagesrcset?: string | undefined;
539
- media?: string | undefined;
540
- prefetch?: string | undefined;
541
- rel?: string | undefined;
542
- sizes?: string | undefined;
543
- title?: string | undefined;
544
- href: string;
545
- }[] | undefined;
546
630
  feedback?: {
547
631
  hide?: boolean | undefined;
548
632
  settings?: string | undefined;
@@ -611,6 +695,23 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
611
695
  logoutRedirect?: string | undefined;
612
696
  };
613
697
  }, {
698
+ links?: {
699
+ type?: string | undefined;
700
+ crossorigin?: string | undefined;
701
+ fetchpriority?: string | undefined;
702
+ integrity?: string | undefined;
703
+ referrerpolicy?: string | undefined;
704
+ as?: string | undefined;
705
+ hreflang?: string | undefined;
706
+ imagesizes?: string | undefined;
707
+ imagesrcset?: string | undefined;
708
+ media?: string | undefined;
709
+ prefetch?: string | undefined;
710
+ rel?: string | undefined;
711
+ sizes?: string | undefined;
712
+ title?: string | undefined;
713
+ href: string;
714
+ }[] | undefined;
614
715
  imports?: string[] | undefined;
615
716
  logo?: {
616
717
  image?: string | undefined;
@@ -658,23 +759,6 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
658
759
  src: string;
659
760
  }[] | undefined;
660
761
  } | undefined;
661
- links?: {
662
- type?: string | undefined;
663
- crossorigin?: string | undefined;
664
- fetchpriority?: string | undefined;
665
- integrity?: string | undefined;
666
- referrerpolicy?: string | undefined;
667
- as?: string | undefined;
668
- hreflang?: string | undefined;
669
- imagesizes?: string | undefined;
670
- imagesrcset?: string | undefined;
671
- media?: string | undefined;
672
- prefetch?: string | undefined;
673
- rel?: string | undefined;
674
- sizes?: string | undefined;
675
- title?: string | undefined;
676
- href: string;
677
- }[] | undefined;
678
762
  feedback?: {
679
763
  type?: string | undefined;
680
764
  hide?: boolean | undefined;
@@ -728,9 +812,9 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
728
812
  } | undefined;
729
813
  editPage?: {
730
814
  hide?: boolean | undefined;
731
- text?: string | undefined;
732
815
  baseUrl?: string | undefined;
733
816
  icon?: string | undefined;
817
+ text?: string | undefined;
734
818
  } | undefined;
735
819
  } | undefined;
736
820
  openapi?: {} | undefined;
@@ -759,3 +843,5 @@ export type ThemeUIConfig = Omit<ThemeConfig, 'navbar' | 'footer' | 'links' | 's
759
843
  shortcuts?: string[];
760
844
  };
761
845
  };
846
+ export type MarkdownConfig = z.infer<typeof MarkdownConfig>;
847
+ export {};
package/lib/config.js CHANGED
@@ -47,6 +47,37 @@ const LinksConfig = zod_1.z
47
47
  type: zod_1.z.string().optional(),
48
48
  })
49
49
  .passthrough();
50
+ const MarkdownConfig = zod_1.z
51
+ .object({
52
+ frontMatterKeysToResolve: zod_1.z.array(zod_1.z.string()).default(['image', 'links']).optional(),
53
+ lastUpdatedBlock: zod_1.z
54
+ .object({
55
+ format: zod_1.z.enum(['timeago', 'iso', 'long', 'short']).default('timeago').optional(),
56
+ locale: zod_1.z.string().default('en-US').optional(),
57
+ })
58
+ .extend(HideConfig.shape)
59
+ .default({})
60
+ .optional(),
61
+ toc: zod_1.z
62
+ .object({
63
+ header: zod_1.z.string().default('On this page').optional(),
64
+ depth: zod_1.z.number().default(3).optional(),
65
+ })
66
+ .extend(HideConfig.shape)
67
+ .optional()
68
+ .default({}),
69
+ editPage: zod_1.z
70
+ .object({
71
+ baseUrl: zod_1.z.string().optional(),
72
+ icon: zod_1.z.string().optional(),
73
+ text: zod_1.z.string().optional().default('Edit this page'),
74
+ })
75
+ .extend(HideConfig.shape)
76
+ .default({})
77
+ .optional(),
78
+ })
79
+ .strict()
80
+ .default({});
50
81
  exports.ThemeConfig = zod_1.z
51
82
  .object({
52
83
  imports: zod_1.z.array(zod_1.z.string()).default([]).optional(),
@@ -141,38 +172,7 @@ exports.ThemeConfig = zod_1.z
141
172
  .strict()
142
173
  .default({})
143
174
  .optional(),
144
- markdown: zod_1.z
145
- .object({
146
- frontMatterKeysToResolve: zod_1.z.array(zod_1.z.string()).default(['image', 'links']).optional(),
147
- lastUpdatedBlock: zod_1.z
148
- .object({
149
- format: zod_1.z.enum(['timeago', 'iso', 'long', 'short']).default('timeago').optional(),
150
- locale: zod_1.z.string().default('en-US').optional(),
151
- })
152
- .extend(HideConfig.shape)
153
- .default({})
154
- .optional(),
155
- toc: zod_1.z
156
- .object({
157
- header: zod_1.z.string().default('On this page').optional(),
158
- depth: zod_1.z.number().default(3).optional(),
159
- })
160
- .extend(HideConfig.shape)
161
- .optional()
162
- .default({}),
163
- editPage: zod_1.z
164
- .object({
165
- baseUrl: zod_1.z.string().optional(),
166
- icon: zod_1.z.string().optional(),
167
- text: zod_1.z.string().optional().default('Edit this page'),
168
- })
169
- .extend(HideConfig.shape)
170
- .default({})
171
- .optional(),
172
- })
173
- .strict()
174
- .default({})
175
- .optional(),
175
+ markdown: MarkdownConfig.optional(),
176
176
  openapi: zod_1.z.object({}).passthrough().optional(),
177
177
  graphql: zod_1.z.object({}).passthrough().optional(),
178
178
  analytics: zod_1.z.any().optional(),
@@ -202,7 +202,7 @@ const headingsTypography = (0, styled_components_1.css) `
202
202
  --h2-font-weight: var(--heading-font-weight); // @presenter FontWeight
203
203
  --h2-font-size: 28px; // @presenter FontSize
204
204
  --h2-line-height: 28px; // @presenter LineHeight
205
- --h2-margin-top: 0; // @presenter Spacing
205
+ --h2-margin-top: var(--heading-margin-top); // @presenter Spacing
206
206
  --h2-margin-bottom: var(--heading-margin-bottom); // @presenter Spacing
207
207
  --h2-text-color: var(--heading-text-color); // @presenter Color
208
208
 
@@ -872,6 +872,7 @@ const apiReferencePanels = (0, styled_components_1.css) `
872
872
  */
873
873
 
874
874
  .panel-try-it,
875
+ .panel-pull-right,
875
876
  .panel-request-samples,
876
877
  .panel-response-samples,
877
878
  .panel-callback-samples {
@@ -1659,7 +1660,7 @@ const loadProgressBar = (0, styled_components_1.css) `
1659
1660
  #nprogress .peg {
1660
1661
  display: block;
1661
1662
  position: absolute;
1662
- right: 0px;
1663
+ right: 0;
1663
1664
  width: 100px;
1664
1665
  height: 100%;
1665
1666
  box-shadow: var(--load-progress-bar-shadow);
@@ -7,7 +7,7 @@ function useActiveHeading(contentElement, displayedHeaders) {
7
7
  const [heading, setHeading] = (0, react_1.useState)(displayedHeaders.length > 1 ? displayedHeaders[0] : undefined);
8
8
  const [headingElements, setHeadingElements] = (0, react_1.useState)([]);
9
9
  const headingElementsRef = (0, react_1.useRef)({});
10
- const history = (0, react_router_dom_1.useHistory)();
10
+ const location = (0, react_router_dom_1.useLocation)();
11
11
  const getVisibleHeadings = () => {
12
12
  const visibleHeadings = [];
13
13
  for (const key in headingElementsRef.current) {
@@ -56,12 +56,7 @@ function useActiveHeading(contentElement, displayedHeaders) {
56
56
  return;
57
57
  }
58
58
  setHeadingElements(findHeaders(contentElement));
59
- const unlisten = history.listen(() => {
60
- setHeadingElements(findHeaders(contentElement));
61
- });
62
- return () => unlisten();
63
- // eslint-disable-next-line react-hooks/exhaustive-deps
64
- }, [contentElement]);
59
+ }, [contentElement, location]);
65
60
  (0, react_1.useEffect)(() => {
66
61
  if (!(headingElements === null || headingElements === void 0 ? void 0 : headingElements.length)) {
67
62
  return;
@@ -33,7 +33,7 @@ function useActiveSectionId(location, hasOverviewPage = false) {
33
33
  window.addEventListener('scroll', scrollListener, { capture: false });
34
34
  setTimeout(() => {
35
35
  scrollListener();
36
- }, 0);
36
+ }, 10);
37
37
  return () => {
38
38
  window.removeEventListener('scroll', scrollListener);
39
39
  };
@@ -4,7 +4,7 @@ exports.useMobileMenu = void 0;
4
4
  const react_1 = require("react");
5
5
  const react_router_dom_1 = require("react-router-dom");
6
6
  function useMobileMenu(initialState = false) {
7
- const { location } = (0, react_router_dom_1.useHistory)();
7
+ const location = (0, react_router_dom_1.useLocation)();
8
8
  const [isOpen, setIsOpen] = (0, react_1.useState)(initialState);
9
9
  (0, react_1.useEffect)(() => setIsOpen(false), [location.pathname]);
10
10
  return [isOpen, setIsOpen];
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export interface AnchorIconProps {
3
+ className?: string;
4
+ }
5
+ export declare const AnchorIcon: import("styled-components").StyledComponent<({ className }: AnchorIconProps) => JSX.Element, any, {
6
+ 'data-component-name': string;
7
+ }, "data-component-name">;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AnchorIcon = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const Icon = ({ className }) => (react_1.default.createElement("svg", { "aria-hidden": "true", focusable: "false", height: "16", version: "1.1", viewBox: "0 0 16 16", width: "16", className: className },
10
+ react_1.default.createElement("path", { fillRule: "evenodd", d: "M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" })));
11
+ exports.AnchorIcon = (0, styled_components_1.default)(Icon).attrs(() => ({
12
+ 'data-component-name': 'icons/AnchorIcon/AnchorIcon',
13
+ })) `
14
+ fill: var(--heading-anchor-color);
15
+ visibility: hidden;
16
+ cursor: pointer;
17
+
18
+ background-image: var(--heading-anchor-icon);
19
+ background-size: contain;
20
+ background-repeat: no-repeat;
21
+ background-position: center;
22
+ `;
23
+ //# sourceMappingURL=AnchorIcon.js.map
@@ -0,0 +1,2 @@
1
+ export { AnchorIcon } from '../../icons/AnchorIcon/AnchorIcon';
2
+ export type { AnchorIconProps } from '../../icons/AnchorIcon/AnchorIcon';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnchorIcon = void 0;
4
+ var AnchorIcon_1 = require("../../icons/AnchorIcon/AnchorIcon");
5
+ Object.defineProperty(exports, "AnchorIcon", { enumerable: true, get: function () { return AnchorIcon_1.AnchorIcon; } });
6
+ //# sourceMappingURL=index.js.map
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  export interface ArrowIconProps {
3
3
  direction?: 'up' | 'right' | 'left' | 'down';
4
+ visibility?: 'visible' | 'hidden';
4
5
  }
5
6
  export declare const ArrowIcon: import("styled-components").StyledComponent<({ className }: {
6
7
  className?: string | undefined;
@@ -26,6 +26,7 @@ exports.ArrowIcon = (0, styled_components_1.default)(Icon) `
26
26
  height: var(--sidebar-group-item-chevron-size);
27
27
  fill: var(--sidebar-group-item-chevron-color);
28
28
  transform: rotate(${directionToTransform}deg);
29
+ visibility: ${({ visibility = 'visible' }) => visibility};
29
30
 
30
31
  vertical-align: middle;
31
32
  `;
@@ -2,3 +2,4 @@ export * from '../icons/ShelfIcon';
2
2
  export * from '../icons/AlertIcon';
3
3
  export * from '../icons/ArrowIcon';
4
4
  export * from '../icons/ColorModeIcon';
5
+ export * from '../icons/AnchorIcon';
@@ -18,4 +18,5 @@ __exportStar(require("../icons/ShelfIcon"), exports);
18
18
  __exportStar(require("../icons/AlertIcon"), exports);
19
19
  __exportStar(require("../icons/ArrowIcon"), exports);
20
20
  __exportStar(require("../icons/ColorModeIcon"), exports);
21
+ __exportStar(require("../icons/AnchorIcon"), exports);
21
22
  //# sourceMappingURL=index.js.map
package/lib/index.d.ts CHANGED
@@ -22,3 +22,4 @@ export * from './Sidebar';
22
22
  export * from './types/config';
23
23
  export * from './config';
24
24
  export * from './Pages';
25
+ export * from './Markdown';
package/lib/index.js CHANGED
@@ -38,4 +38,5 @@ __exportStar(require("./Sidebar"), exports);
38
38
  __exportStar(require("./types/config"), exports);
39
39
  __exportStar(require("./config"), exports);
40
40
  __exportStar(require("./Pages"), exports);
41
+ __exportStar(require("./Markdown"), exports);
41
42
  //# sourceMappingURL=index.js.map
@@ -14,8 +14,8 @@ exports.Jumbotron = (0, styled_components_1.default)(Background_1.Background).at
14
14
  flex-direction: column;
15
15
  padding-top: ${({ pt }) => pt || '0'};
16
16
  padding-bottom: ${({ pb }) => pb || '8em'};
17
- padding-left: ${({ pl }) => pl || '0'};
18
- padding-right: ${({ pr }) => pr || '0'};
17
+ padding-left: ${({ pl }) => pl || '1rem'};
18
+ padding-right: ${({ pr }) => pr || '1rem'};
19
19
  ${({ bgColor }) => bgColor && `background: ${bgColor}`};
20
20
  ${({ bgImage, bgColor }) => bgImage &&
21
21
  `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.7.5",
3
+ "version": "0.8.1",
4
4
  "description": "Shared UI components lib",
5
5
  "author": "team@redocly.com",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -39,8 +39,7 @@
39
39
  "prismjs": "^1.28.0",
40
40
  "react": "^17.0.2",
41
41
  "react-dom": "^17.0.2",
42
- "react-router": "^5.3.0",
43
- "react-router-dom": "^5.3.0",
42
+ "react-router-dom": "^6.4.4",
44
43
  "styled-components": "^5.3.6",
45
44
  "styled-system": "^5.1.5",
46
45
  "zod": ">=3.19.1"
@@ -71,8 +70,6 @@
71
70
  "@types/prismjs": "^1.26.0",
72
71
  "@types/react": "^17.0.43",
73
72
  "@types/react-dom": "^17.0.14",
74
- "@types/react-router-dom": "^5.3.3",
75
- "@types/react-router": "^5.1.20",
76
73
  "@types/styled-components": "^5.1.26",
77
74
  "@types/styled-system": "^5.1.13",
78
75
  "@typescript-eslint/eslint-plugin": "^5.23.0",
@@ -87,8 +84,7 @@
87
84
  "lodash.throttle": "^4.1.1",
88
85
  "npm-run-all": "^4.1.5",
89
86
  "react-refresh": "^0.14.0",
90
- "react-router": "^5.3.0",
91
- "react-router-dom": "^5.3.0",
87
+ "react-router-dom": "^6.4.4",
92
88
  "storybook-addon-pseudo-states": "^1.15.1",
93
89
  "storybook-design-token": "^2.7.1",
94
90
  "styled-components": "^5.3.6",
@@ -9,15 +9,24 @@ interface AdmonitionTypeProps {
9
9
 
10
10
  export interface AdmonitionProps extends Partial<AdmonitionTypeProps> {
11
11
  name?: string;
12
+ 'data-source'?: string;
13
+ 'data-hash'?: string;
12
14
  }
13
15
 
14
16
  export function Admonition({
15
17
  type = 'info',
16
18
  name,
17
19
  children,
20
+ 'data-source': dataSource,
21
+ 'data-hash': dataHash,
18
22
  }: React.PropsWithChildren<AdmonitionProps>): JSX.Element {
19
23
  return (
20
- <Wrapper type={type} data-component-name="Markdown/Admonition">
24
+ <Wrapper
25
+ type={type}
26
+ data-component-name="Markdown/Admonition"
27
+ data-source={dataSource}
28
+ data-hash={dataHash}
29
+ >
21
30
  <AlertIcon type={type} />
22
31
  {name ? <Heading type={type}>{name}</Heading> : null}
23
32
  <Content>{children}</Content>
@@ -9,9 +9,17 @@ export type CodeSampleProps = {
9
9
  language: string;
10
10
  highlighted: string;
11
11
  rawContent: string;
12
+ 'data-source'?: string;
13
+ 'data-hash'?: string;
12
14
  };
13
15
 
14
- export function CodeSample({ rawContent, highlighted, language }: CodeSampleProps): JSX.Element {
16
+ export function CodeSample({
17
+ rawContent,
18
+ highlighted,
19
+ language,
20
+ 'data-source': dataSource,
21
+ 'data-hash': dataHash,
22
+ }: CodeSampleProps): JSX.Element {
15
23
  const langClassName = language ? `language-${language}` : '';
16
24
  const { codeSnippet: { copy = {}, report = {} } = {} } = useThemeConfig();
17
25
 
@@ -26,7 +34,12 @@ export function CodeSample({ rawContent, highlighted, language }: CodeSampleProp
26
34
  };
27
35
 
28
36
  return (
29
- <Wrapper className="code-sample" data-component-name="Markdown/CodeSample/CodeSample">
37
+ <Wrapper
38
+ className="code-sample"
39
+ data-component-name="Markdown/CodeSample/CodeSample"
40
+ data-source={dataSource}
41
+ data-hash={dataHash}
42
+ >
30
43
  <CodeSampleButtonContainer>
31
44
  {!copy.hide && (
32
45
  <>
@@ -3,36 +3,28 @@ import React, { createElement } from 'react';
3
3
  import type { PropsWithChildren } from 'react';
4
4
 
5
5
  import { concatClassNames } from '@theme/utils';
6
+ import { AnchorIcon } from '@theme/icons';
6
7
 
7
8
  /**
8
9
  * Class name for all MD tags
9
10
  */
10
11
  const mdClassName = 'md';
11
12
 
12
- const SvgIcon = (
13
- <svg
14
- aria-hidden="true"
15
- focusable="false"
16
- height="16"
17
- version="1.1"
18
- viewBox="0 0 16 16"
19
- width="16"
20
- >
21
- <path
22
- fillRule="evenodd"
23
- d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
24
- ></path>
25
- </svg>
26
- );
27
-
28
13
  export function Heading({
29
14
  level,
30
15
  id,
31
16
  children,
32
- }: PropsWithChildren<{ level: number; id: string }>): JSX.Element {
17
+ 'data-source': dataSource,
18
+ 'data-hash': dataHash,
19
+ }: PropsWithChildren<{
20
+ level: number;
21
+ id: string;
22
+ 'data-source'?: string;
23
+ 'data-hash'?: string;
24
+ }>): JSX.Element {
33
25
  const linkEl = (
34
26
  <a href={`#${id}`} className={concatClassNames('anchor', 'before')}>
35
- {SvgIcon}
27
+ <AnchorIcon />
36
28
  </a>
37
29
  );
38
30
 
@@ -42,6 +34,8 @@ export function Heading({
42
34
  id,
43
35
  className: concatClassNames('heading-anchor', mdClassName),
44
36
  'data-component-name': 'Markdown/Heading',
37
+ 'data-source': dataSource,
38
+ 'data-hash': dataHash,
45
39
  },
46
40
  <>
47
41
  {linkEl}
@@ -3,14 +3,22 @@ import styled from 'styled-components';
3
3
 
4
4
  type MermaidProps = {
5
5
  diagramHtml: string;
6
+ 'data-source'?: string;
7
+ 'data-hash'?: string;
6
8
  };
7
9
 
8
- export function Mermaid({ diagramHtml }: MermaidProps): JSX.Element {
10
+ export function Mermaid({
11
+ diagramHtml,
12
+ 'data-source': dataSource,
13
+ 'data-hash': dataHash,
14
+ }: MermaidProps): JSX.Element {
9
15
  return (
10
16
  <Wrapper
11
17
  className="mermaid-wrapper"
12
18
  dangerouslySetInnerHTML={{ __html: diagramHtml }}
13
19
  data-component-name="Markdown/Mermaid"
20
+ data-source={dataSource}
21
+ data-hash={dataHash}
14
22
  />
15
23
  );
16
24
  }
@@ -43,7 +43,10 @@ export function MenuGroup({
43
43
  isAlwaysExpanded={item.expanded === 'always'}
44
44
  active={item.active}
45
45
  >
46
- <MenuGroupArrow direction={isExpanded ? 'down' : 'right'} />
46
+ <MenuGroupArrow
47
+ visibility={item.items.length ? 'visible' : 'hidden'}
48
+ direction={isExpanded ? 'down' : 'right'}
49
+ />
47
50
  {item.label}
48
51
  </MenuGroupLabel>
49
52
  </MenuLinkItem>
@@ -62,7 +65,7 @@ const MenuWrapper = styled.div<{ isExpanded?: boolean }>`
62
65
  overflow: hidden;
63
66
  ${(props) =>
64
67
  props.isExpanded
65
- ? `max-height: 9999px;
68
+ ? `max-height: 99999px;
66
69
  transition: max-height .8s cubic-bezier(0.5, 0, 1, 0) 0s;`
67
70
  : `max-height: 0px;
68
71
  transition: max-height .8s cubic-bezier(0, 1, 0, 1) -.1s;`};
@@ -1,6 +1,7 @@
1
1
  import styled from 'styled-components';
2
2
 
3
3
  interface SidebarProps {
4
+ isNavbar: boolean;
4
5
  opened?: boolean;
5
6
  animate?: boolean;
6
7
  }
@@ -18,13 +19,16 @@ export const Sidebar = styled.aside.attrs(() => ({
18
19
  font-size: var(--sidebar-item-font-size);
19
20
  font-family: var(--sidebar-item-font-family);
20
21
  color: var(--sidebar-item-text-color);
21
- top: var(--navbar-height);
22
- height: calc(100vh - var(--navbar-height));
23
22
  display: flex;
24
23
  flex-direction: column;
25
24
  width: 100%;
26
25
  -webkit-font-smoothing: antialiased;
27
26
 
27
+ ${({ isNavbar }) => `
28
+ top: ${isNavbar ? 'var(--navbar-height)' : '0'};
29
+ height: calc(100vh ${isNavbar ? '- var(--navbar-height)' : ''});
30
+ `};
31
+
28
32
  ${({ opened, animate }) => `
29
33
  opacity: ${opened ? '1' : '0'};
30
34
  pointer-events: ${opened ? 'auto' : 'none'};
@@ -17,12 +17,14 @@ interface SidebarLayoutProps {
17
17
  label: string;
18
18
  slug: string;
19
19
  };
20
+ isNavbar: boolean;
20
21
  }
21
22
 
22
23
  export function SidebarLayout({
23
24
  versions,
24
25
  menu,
25
26
  backLink,
27
+ isNavbar,
26
28
  }: SidebarLayoutProps): JSX.Element | null {
27
29
  const [isOpen, setIsOpen] = useMobileMenu();
28
30
  const toggleMenu = () => setIsOpen(!isOpen);
@@ -37,7 +39,7 @@ export function SidebarLayout({
37
39
  <MobileSidebarButton opened={isOpen} onClick={toggleMenu} />
38
40
 
39
41
  {!search?.hide && search?.placement === 'sidebar' ? <SidebarSearch /> : null}
40
- <Sidebar animate={true} opened={isOpen}>
42
+ <Sidebar animate={true} opened={isOpen} isNavbar={isNavbar}>
41
43
  {(backLink && (
42
44
  <BackLinkWrapper>
43
45
  <Link to={backLink.slug}>
@@ -109,5 +109,5 @@ const TableOfContentItems = styled.div`
109
109
  max-height: calc(100vh - var(--navbar-height) - var(--toc-offset-top));
110
110
  border-left: 1px solid var(--toc-border-color);
111
111
  overflow-y: auto;
112
- width: var(--toc-width); ;
112
+ width: var(--toc-width);
113
113
  `;
package/src/config.ts CHANGED
@@ -50,6 +50,38 @@ const LinksConfig = z
50
50
  })
51
51
  .passthrough();
52
52
 
53
+ const MarkdownConfig = z
54
+ .object({
55
+ frontMatterKeysToResolve: z.array(z.string()).default(['image', 'links']).optional(),
56
+ lastUpdatedBlock: z
57
+ .object({
58
+ format: z.enum(['timeago', 'iso', 'long', 'short']).default('timeago').optional(),
59
+ locale: z.string().default('en-US').optional(),
60
+ })
61
+ .extend(HideConfig.shape)
62
+ .default({})
63
+ .optional(),
64
+ toc: z
65
+ .object({
66
+ header: z.string().default('On this page').optional(),
67
+ depth: z.number().default(3).optional(),
68
+ })
69
+ .extend(HideConfig.shape)
70
+ .optional()
71
+ .default({}),
72
+ editPage: z
73
+ .object({
74
+ baseUrl: z.string().optional(),
75
+ icon: z.string().optional(),
76
+ text: z.string().optional().default('Edit this page'),
77
+ })
78
+ .extend(HideConfig.shape)
79
+ .default({})
80
+ .optional(),
81
+ })
82
+ .strict()
83
+ .default({});
84
+
53
85
  export const ThemeConfig = z
54
86
  .object({
55
87
  imports: z.array(z.string()).default([]).optional(),
@@ -150,38 +182,7 @@ export const ThemeConfig = z
150
182
  .strict()
151
183
  .default({})
152
184
  .optional(),
153
- markdown: z
154
- .object({
155
- frontMatterKeysToResolve: z.array(z.string()).default(['image', 'links']).optional(),
156
- lastUpdatedBlock: z
157
- .object({
158
- format: z.enum(['timeago', 'iso', 'long', 'short']).default('timeago').optional(),
159
- locale: z.string().default('en-US').optional(),
160
- })
161
- .extend(HideConfig.shape)
162
- .default({})
163
- .optional(),
164
- toc: z
165
- .object({
166
- header: z.string().default('On this page').optional(),
167
- depth: z.number().default(3).optional(),
168
- })
169
- .extend(HideConfig.shape)
170
- .optional()
171
- .default({}),
172
- editPage: z
173
- .object({
174
- baseUrl: z.string().optional(),
175
- icon: z.string().optional(),
176
- text: z.string().optional().default('Edit this page'),
177
- })
178
- .extend(HideConfig.shape)
179
- .default({})
180
- .optional(),
181
- })
182
- .strict()
183
- .default({})
184
- .optional(),
185
+ markdown: MarkdownConfig.optional(),
185
186
  openapi: z.object({}).passthrough().optional(),
186
187
  graphql: z.object({}).passthrough().optional(),
187
188
  analytics: z.any().optional(),
@@ -215,3 +216,5 @@ export type ThemeUIConfig = Omit<ThemeConfig, 'navbar' | 'footer' | 'links' | 's
215
216
  shortcuts?: string[];
216
217
  };
217
218
  };
219
+
220
+ export type MarkdownConfig = z.infer<typeof MarkdownConfig>;
@@ -204,7 +204,7 @@ const headingsTypography = css`
204
204
  --h2-font-weight: var(--heading-font-weight); // @presenter FontWeight
205
205
  --h2-font-size: 28px; // @presenter FontSize
206
206
  --h2-line-height: 28px; // @presenter LineHeight
207
- --h2-margin-top: 0; // @presenter Spacing
207
+ --h2-margin-top: var(--heading-margin-top); // @presenter Spacing
208
208
  --h2-margin-bottom: var(--heading-margin-bottom); // @presenter Spacing
209
209
  --h2-text-color: var(--heading-text-color); // @presenter Color
210
210
 
@@ -880,6 +880,7 @@ const apiReferencePanels = css`
880
880
  */
881
881
 
882
882
  .panel-try-it,
883
+ .panel-pull-right,
883
884
  .panel-request-samples,
884
885
  .panel-response-samples,
885
886
  .panel-callback-samples {
@@ -1677,7 +1678,7 @@ const loadProgressBar = css`
1677
1678
  #nprogress .peg {
1678
1679
  display: block;
1679
1680
  position: absolute;
1680
- right: 0px;
1681
+ right: 0;
1681
1682
  width: 100px;
1682
1683
  height: 100%;
1683
1684
  box-shadow: var(--load-progress-bar-shadow);
@@ -1,6 +1,5 @@
1
1
  import { useState, useEffect, useRef, useCallback } from 'react';
2
- import { useHistory } from 'react-router-dom';
3
-
2
+ import { useLocation } from 'react-router-dom';
4
3
  export type UseActiveHeadingReturnType = string | undefined;
5
4
 
6
5
  type HeadingEntry = {
@@ -16,8 +15,7 @@ export function useActiveHeading(
16
15
  );
17
16
  const [headingElements, setHeadingElements] = useState<HTMLElement[]>([]);
18
17
  const headingElementsRef = useRef<HeadingEntry>({});
19
-
20
- const history = useHistory();
18
+ const location = useLocation();
21
19
 
22
20
  const getVisibleHeadings = () => {
23
21
  const visibleHeadings: IntersectionObserverEntry[] = [];
@@ -86,14 +84,7 @@ export function useActiveHeading(
86
84
  return;
87
85
  }
88
86
  setHeadingElements(findHeaders(contentElement));
89
-
90
- const unlisten = history.listen(() => {
91
- setHeadingElements(findHeaders(contentElement));
92
- });
93
-
94
- return () => unlisten();
95
- // eslint-disable-next-line react-hooks/exhaustive-deps
96
- }, [contentElement]);
87
+ }, [contentElement, location]);
97
88
 
98
89
  useEffect(() => {
99
90
  if (!headingElements?.length) {
@@ -41,7 +41,7 @@ export function useActiveSectionId(
41
41
  window.addEventListener('scroll', scrollListener, { capture: false });
42
42
  setTimeout(() => {
43
43
  scrollListener();
44
- }, 0);
44
+ }, 10);
45
45
 
46
46
  return () => {
47
47
  window.removeEventListener('scroll', scrollListener);
@@ -1,10 +1,10 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { useHistory } from 'react-router-dom';
2
+ import { useLocation } from 'react-router-dom';
3
3
 
4
4
  import type { Dispatch, SetStateAction } from 'react';
5
5
 
6
6
  export function useMobileMenu(initialState = false): [boolean, Dispatch<SetStateAction<boolean>>] {
7
- const { location } = useHistory();
7
+ const location = useLocation();
8
8
  const [isOpen, setIsOpen] = useState(initialState);
9
9
 
10
10
  useEffect(() => setIsOpen(false), [location.pathname]);
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ export interface AnchorIconProps {
5
+ className?: string;
6
+ }
7
+
8
+ const Icon = ({ className }: AnchorIconProps) => (
9
+ <svg
10
+ aria-hidden="true"
11
+ focusable="false"
12
+ height="16"
13
+ version="1.1"
14
+ viewBox="0 0 16 16"
15
+ width="16"
16
+ className={className}
17
+ >
18
+ <path
19
+ fillRule="evenodd"
20
+ d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"
21
+ />
22
+ </svg>
23
+ );
24
+
25
+ export const AnchorIcon = styled(Icon).attrs(() => ({
26
+ 'data-component-name': 'icons/AnchorIcon/AnchorIcon',
27
+ }))`
28
+ fill: var(--heading-anchor-color);
29
+ visibility: hidden;
30
+ cursor: pointer;
31
+
32
+ background-image: var(--heading-anchor-icon);
33
+ background-size: contain;
34
+ background-repeat: no-repeat;
35
+ background-position: center;
36
+ `;
@@ -0,0 +1,2 @@
1
+ export { AnchorIcon } from '@theme/icons/AnchorIcon/AnchorIcon';
2
+ export type { AnchorIconProps } from '@theme/icons/AnchorIcon/AnchorIcon';
@@ -3,6 +3,7 @@ import styled from 'styled-components';
3
3
 
4
4
  export interface ArrowIconProps {
5
5
  direction?: 'up' | 'right' | 'left' | 'down';
6
+ visibility?: 'visible' | 'hidden';
6
7
  }
7
8
 
8
9
  function directionToTransform({ direction }: ArrowIconProps) {
@@ -31,6 +32,7 @@ export const ArrowIcon = styled(Icon)`
31
32
  height: var(--sidebar-group-item-chevron-size);
32
33
  fill: var(--sidebar-group-item-chevron-color);
33
34
  transform: rotate(${directionToTransform}deg);
35
+ visibility: ${({ visibility = 'visible' }) => visibility};
34
36
 
35
37
  vertical-align: middle;
36
38
  `;
@@ -2,3 +2,4 @@ export * from '@theme/icons/ShelfIcon';
2
2
  export * from '@theme/icons/AlertIcon';
3
3
  export * from '@theme/icons/ArrowIcon';
4
4
  export * from '@theme/icons/ColorModeIcon';
5
+ export * from '@theme/icons/AnchorIcon';
package/src/index.ts CHANGED
@@ -22,3 +22,4 @@ export * from './Sidebar';
22
22
  export * from './types/config';
23
23
  export * from './config';
24
24
  export * from './Pages';
25
+ export * from './Markdown';
@@ -63,7 +63,7 @@ export declare type ResolvedNavItemWithLink = (ResolvedNavLinkItem | ResolvedNav
63
63
  export declare type ResolvedSidebar = ResolvedNavItem[];
64
64
  export interface PageProps {
65
65
  seo?: {
66
- title: string;
66
+ title?: string;
67
67
  };
68
68
  frontmatter?: Omit<PageProps, 'frontmatter'> & {
69
69
  settings?: any;
@@ -19,8 +19,8 @@ export const Jumbotron = styled(Background).attrs(() => ({
19
19
  flex-direction: column;
20
20
  padding-top: ${({ pt }) => pt || '0'};
21
21
  padding-bottom: ${({ pb }) => pb || '8em'};
22
- padding-left: ${({ pl }) => pl || '0'};
23
- padding-right: ${({ pr }) => pr || '0'};
22
+ padding-left: ${({ pl }) => pl || '1rem'};
23
+ padding-right: ${({ pr }) => pr || '1rem'};
24
24
  ${({ bgColor }) => bgColor && `background: ${bgColor}`};
25
25
  ${({ bgImage, bgColor }) =>
26
26
  bgImage &&