@redocly/theme 0.1.16 → 0.1.21

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 (163) hide show
  1. package/Button/Button.d.ts +4 -3
  2. package/Button/Button.js +28 -1
  3. package/Footer/CustomFooter.d.ts +7 -0
  4. package/Footer/CustomFooter.js +31 -0
  5. package/Footer/CustomFooterNavItem.d.ts +7 -0
  6. package/Footer/CustomFooterNavItem.js +25 -0
  7. package/Footer/Footer.d.ts +6 -2
  8. package/Footer/Footer.js +1 -1
  9. package/Footer/FooterColumn.d.ts +2 -2
  10. package/Footer/FooterColumn.js +3 -2
  11. package/Footer/FooterColumns.d.ts +6 -4
  12. package/Footer/FooterColumns.js +3 -3
  13. package/Footer/FooterCopyright.d.ts +6 -4
  14. package/JsonViewer/JsonViewer.js +1 -2
  15. package/JsonViewer/index.d.ts +0 -1
  16. package/JsonViewer/index.js +0 -1
  17. package/Markdown/Admonition.js +1 -1
  18. package/Markdown/CodeSample/CodeSample.js +15 -5
  19. package/Markdown/CodeSample/index.d.ts +0 -1
  20. package/Markdown/CodeSample/index.js +0 -1
  21. package/Navbar/Navbar.d.ts +2 -1
  22. package/Navbar/Navbar.js +9 -2
  23. package/Navbar/NavbarDropdown.d.ts +8 -0
  24. package/Navbar/NavbarDropdown.js +21 -0
  25. package/Navbar/NavbarItem.d.ts +3 -36
  26. package/Navbar/NavbarItem.js +22 -13
  27. package/Navbar/NavbarMenu.d.ts +2 -1
  28. package/Navbar/NavbarMenu.js +1 -1
  29. package/PageNavigation/NextPageLink.js +8 -5
  30. package/PageNavigation/PreviousPageLink.js +8 -5
  31. package/Search/SidebarSearch.d.ts +2 -0
  32. package/Search/SidebarSearch.js +15 -0
  33. package/Sidebar/MenuGroup.js +2 -2
  34. package/Sidebar/SidebarLayout.js +5 -0
  35. package/TableOfContent/TableOfContent.js +8 -1
  36. package/Typography/CompactTypography.d.ts +11 -0
  37. package/Typography/CompactTypography.js +18 -0
  38. package/Typography/Emphasis.d.ts +3 -0
  39. package/Typography/Emphasis.js +15 -0
  40. package/Typography/H1.d.ts +3 -0
  41. package/Typography/H1.js +16 -0
  42. package/Typography/H2.d.ts +3 -0
  43. package/Typography/H2.js +16 -0
  44. package/Typography/H3.d.ts +3 -0
  45. package/Typography/H3.js +16 -0
  46. package/Typography/SectionHeader.d.ts +1 -0
  47. package/Typography/SectionHeader.js +13 -0
  48. package/Typography/Typography.d.ts +8 -0
  49. package/Typography/Typography.js +22 -0
  50. package/Typography/index.d.ts +7 -0
  51. package/{Headings → Typography}/index.js +7 -1
  52. package/globalStyle.js +1 -1
  53. package/{ui → icons/AlertIcon}/AlertIcon.d.ts +2 -2
  54. package/{ui → icons/AlertIcon}/AlertIcon.js +1 -1
  55. package/icons/AlertIcon/index.d.ts +2 -0
  56. package/icons/AlertIcon/index.js +5 -0
  57. package/icons/ArrowIcon/ArrowIcon.d.ts +7 -0
  58. package/{ui/Arrow.js → icons/ArrowIcon/ArrowIcon.js} +3 -3
  59. package/icons/ArrowIcon/index.d.ts +2 -0
  60. package/icons/ArrowIcon/index.js +5 -0
  61. package/icons/index.d.ts +2 -0
  62. package/icons/index.js +2 -0
  63. package/index.d.ts +1 -1
  64. package/index.js +1 -1
  65. package/mocks/constants/index.d.ts +2 -0
  66. package/mocks/constants/index.js +5 -0
  67. package/mocks/hooks/index.d.ts +6 -0
  68. package/mocks/hooks/index.js +16 -0
  69. package/package.json +1 -1
  70. package/settings.yaml +9 -0
  71. package/src/Button/Button.tsx +19 -1
  72. package/src/Footer/CustomFooter.tsx +45 -0
  73. package/src/Footer/CustomFooterNavItem.tsx +40 -0
  74. package/src/Footer/Footer.tsx +6 -2
  75. package/src/Footer/FooterColumn.tsx +4 -4
  76. package/src/Footer/FooterColumns.tsx +9 -9
  77. package/src/Footer/FooterCopyright.tsx +6 -6
  78. package/src/JsonViewer/JsonViewer.tsx +106 -2
  79. package/src/JsonViewer/index.ts +0 -1
  80. package/src/Markdown/Admonition.tsx +1 -1
  81. package/src/Markdown/CodeSample/CodeSample.tsx +160 -6
  82. package/src/Markdown/CodeSample/index.ts +0 -1
  83. package/src/Navbar/Navbar.tsx +13 -3
  84. package/src/Navbar/NavbarDropdown.tsx +44 -0
  85. package/src/Navbar/NavbarItem.tsx +44 -51
  86. package/src/Navbar/NavbarMenu.tsx +6 -3
  87. package/src/PageNavigation/NextPageLink.tsx +9 -3
  88. package/src/PageNavigation/PreviousPageLink.tsx +9 -3
  89. package/src/Search/SidebarSearch.tsx +13 -0
  90. package/src/Sidebar/MenuGroup.tsx +2 -2
  91. package/src/Sidebar/SidebarLayout.tsx +5 -0
  92. package/src/TableOfContent/TableOfContent.tsx +7 -1
  93. package/src/Typography/CompactTypography.ts +9 -0
  94. package/src/Typography/Emphasis.ts +7 -0
  95. package/src/Typography/H1.ts +12 -0
  96. package/src/Typography/H2.ts +12 -0
  97. package/src/Typography/H3.ts +11 -0
  98. package/src/Typography/SectionHeader.ts +11 -0
  99. package/src/Typography/Typography.ts +21 -0
  100. package/src/Typography/index.ts +7 -0
  101. package/src/globalStyle.ts +1 -0
  102. package/src/{ui → icons/AlertIcon}/AlertIcon.tsx +3 -3
  103. package/src/icons/AlertIcon/index.ts +2 -0
  104. package/src/{ui/Arrow.tsx → icons/ArrowIcon/ArrowIcon.tsx} +5 -5
  105. package/src/icons/ArrowIcon/index.ts +2 -0
  106. package/src/icons/index.ts +2 -0
  107. package/src/index.ts +1 -1
  108. package/src/mocks/constants/index.ts +2 -0
  109. package/src/mocks/hooks/index.ts +17 -0
  110. package/src/types/portal/index.d.ts +0 -1
  111. package/src/types/portal/src/client/app/Sidebar/types.d.ts +1 -1
  112. package/src/types/portal/src/server/{utils → content}/content-provider.d.ts +9 -9
  113. package/src/types/portal/src/server/{version-store.d.ts → content/versions-config.d.ts} +7 -7
  114. package/src/types/portal/src/server/plugins/markdown/types.d.ts +14 -11
  115. package/src/types/portal/src/server/plugins/portal-config/types.d.ts +16 -19
  116. package/src/types/portal/src/server/plugins/types.d.ts +23 -15
  117. package/src/types/portal/src/server/store.d.ts +32 -33
  118. package/src/types/portal/src/server/utils/fs.d.ts +2 -1
  119. package/src/types/portal/src/server/utils/index.d.ts +0 -1
  120. package/src/types/portal/src/server/utils/paths.d.ts +3 -3
  121. package/src/types/portal/src/server/utils/reporter/formatter.d.ts +2 -1
  122. package/src/types/portal/src/server/utils/reporter/reporter.d.ts +2 -1
  123. package/src/types/portal/src/shared/constants.d.ts +2 -0
  124. package/src/types/portal/src/shared/models/active-item.d.ts +3 -0
  125. package/src/types/portal/src/shared/models/config.d.ts +28 -0
  126. package/src/types/portal/src/shared/models/index.d.ts +6 -0
  127. package/src/types/portal/src/shared/models/json-index.d.ts +5 -0
  128. package/src/types/portal/src/shared/models/operation-parameter.d.ts +6 -0
  129. package/src/types/portal/src/shared/models/search-data.d.ts +5 -0
  130. package/src/types/portal/src/shared/models/search-document.d.ts +11 -0
  131. package/src/types/portal/src/shared/types.d.ts +8 -2
  132. package/src/types/portal/src/shared/urls.d.ts +2 -0
  133. package/src/types/portal/src/shared/utils.d.ts +8 -2
  134. package/src/ui/Jumbotron.tsx +1 -1
  135. package/src/ui/index.tsx +0 -4
  136. package/src/utils/ClipboardService.ts +19 -0
  137. package/ui/Jumbotron.js +1 -1
  138. package/ui/index.d.ts +0 -4
  139. package/ui/index.js +0 -4
  140. package/utils/ClipboardService.d.ts +1 -0
  141. package/utils/ClipboardService.js +19 -0
  142. package/Headings/Headings.d.ts +0 -3
  143. package/Headings/Headings.js +0 -16
  144. package/Headings/index.d.ts +0 -1
  145. package/JsonViewer/styled.d.ts +0 -1
  146. package/JsonViewer/styled.js +0 -10
  147. package/Markdown/CodeSample/styled.d.ts +0 -4
  148. package/Markdown/CodeSample/styled.js +0 -85
  149. package/src/Headings/Headings.ts +0 -23
  150. package/src/Headings/index.ts +0 -1
  151. package/src/JsonViewer/styled.ts +0 -103
  152. package/src/Markdown/CodeSample/styled.ts +0 -209
  153. package/src/types/portal/src/client/app/media-css.d.ts +0 -7
  154. package/src/types/portal/src/client/styling/default.d.ts +0 -601
  155. package/src/types/portal/src/client/styling/index.d.ts +0 -10
  156. package/src/types/portal/src/client/styling/resolve.d.ts +0 -1
  157. package/src/ui/Button.tsx +0 -19
  158. package/src/ui/Typography.tsx +0 -90
  159. package/ui/Arrow.d.ts +0 -7
  160. package/ui/Button.d.ts +0 -7
  161. package/ui/Button.js +0 -30
  162. package/ui/Typography.d.ts +0 -41
  163. package/ui/Typography.js +0 -59
@@ -2,7 +2,9 @@ import React from 'react';
2
2
 
3
3
  import type { ResolvedNavLinkItem } from '@theme/types/portal';
4
4
  import { usePageData } from '@portal/hooks/usePageData';
5
- import { Button } from '@theme/ui';
5
+ import { useThemeSettings } from '@portal/hooks/';
6
+ import { DEFAULT_THEME_NAME } from '@portal/constants/';
7
+ import { Button } from '@theme/Button/Button';
6
8
 
7
9
  interface NextPageType {
8
10
  nextPage?: ResolvedNavLinkItem | null;
@@ -10,13 +12,17 @@ interface NextPageType {
10
12
 
11
13
  export function NextPageLink(): JSX.Element {
12
14
  const { nextPage }: NextPageType = usePageData() || {};
13
- if (!nextPage) {
15
+ const { themeSettings } = useThemeSettings(DEFAULT_THEME_NAME);
16
+
17
+ if (!nextPage || themeSettings?.navigation?.hide) {
14
18
  return <div>&nbsp;</div>;
15
19
  }
16
20
 
21
+ const label = themeSettings?.navigation?.nextPageLink?.label || `Next to ${nextPage.label}`;
22
+
17
23
  return (
18
24
  <Button variant="outlined" size="large" to={nextPage.link}>
19
- Next to {nextPage.label}
25
+ {label}
20
26
  </Button>
21
27
  );
22
28
  }
@@ -2,7 +2,9 @@ import React from 'react';
2
2
 
3
3
  import type { ResolvedNavLinkItem } from '@theme/types/portal';
4
4
  import { usePageData } from '@portal/hooks/usePageData';
5
- import { Button } from '@theme/ui';
5
+ import { useThemeSettings } from '@portal/hooks';
6
+ import { DEFAULT_THEME_NAME } from '@portal/constants';
7
+ import { Button } from '@theme/Button/Button';
6
8
 
7
9
  interface PreviousPageType {
8
10
  prevPage?: ResolvedNavLinkItem | null;
@@ -10,13 +12,17 @@ interface PreviousPageType {
10
12
 
11
13
  export function PreviousPageLink(): JSX.Element {
12
14
  const { prevPage }: PreviousPageType = usePageData() || {};
13
- if (!prevPage) {
15
+ const { themeSettings } = useThemeSettings(DEFAULT_THEME_NAME);
16
+
17
+ if (!prevPage || themeSettings?.navigation?.hide) {
14
18
  return <div>&nbsp;</div>;
15
19
  }
16
20
 
21
+ const label = themeSettings?.navigation?.nextPageLink?.label || `Back to ${prevPage.label}`;
22
+
17
23
  return (
18
24
  <Button variant="outlined" size="large" to={prevPage.link}>
19
- Back to {prevPage.label}
25
+ {label}
20
26
  </Button>
21
27
  );
22
28
  }
@@ -0,0 +1,13 @@
1
+ import styled from 'styled-components';
2
+
3
+ import { Search } from '@theme/Search/Search';
4
+ import { Popover } from '@theme/Search/Popover';
5
+
6
+ export const SidebarSearch = styled(Search)`
7
+ --search-input-text-color: var(--sidebar-item-active-color);
8
+
9
+ ${Popover} {
10
+ right: unset;
11
+ top: 100%;
12
+ }
13
+ `;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
- import { Arrow } from '@theme/ui/Arrow';
4
+ import { ArrowIcon } from '@theme/icons/ArrowIcon/ArrowIcon';
5
5
  import { ItemState } from '@theme/Sidebar/types/ItemState';
6
6
  import { MenuLinkItem } from '@theme/Sidebar/MenuLinkItem';
7
7
  import { MenuItemLabel } from '@theme/Sidebar/MenuItemLabel';
@@ -50,6 +50,6 @@ const MenuGroupLabel = styled(MenuItemLabel)<{ isAlwaysExpanded?: boolean }>`
50
50
  cursor: ${(props) => (props.isAlwaysExpanded ? 'default' : 'pointer')};
51
51
  `;
52
52
 
53
- const MenuGroupArrow = styled(Arrow)`
53
+ const MenuGroupArrow = styled(ArrowIcon)`
54
54
  margin-right: calc(var(--sidebar-spacing-unit) / 2);
55
55
  `;
@@ -5,6 +5,9 @@ import { Sidebar } from '@theme/Sidebar/Sidebar';
5
5
  import { useMobileMenu } from '@theme/hooks/useMobileMenu';
6
6
  import { MobileSidebarButton } from '@theme/Sidebar/MobileSidebarButton';
7
7
  import { MenuContainer } from '@theme/Sidebar/MenuContainer';
8
+ import { useThemeSettings } from '@portal/hooks/';
9
+ import { DEFAULT_THEME_NAME } from '@portal/constants/';
10
+ import { SidebarSearch } from '@theme/Search/SidebarSearch';
8
11
 
9
12
  interface SidebarLayoutProps {
10
13
  versions: React.ReactNode;
@@ -14,11 +17,13 @@ interface SidebarLayoutProps {
14
17
  export function SidebarLayout({ versions, menu }: SidebarLayoutProps): JSX.Element {
15
18
  const [isOpen, setIsOpen] = useMobileMenu();
16
19
  const toggleMenu = () => setIsOpen(!isOpen);
20
+ const { hide, placement } = useThemeSettings(DEFAULT_THEME_NAME).search || {};
17
21
 
18
22
  return (
19
23
  <Wrapper data-component-name="Sidebar/SidebarLayout">
20
24
  <MobileSidebarButton opened={isOpen} onClick={toggleMenu} />
21
25
 
26
+ {!hide && placement === 'sidebar' ? <SidebarSearch /> : null}
22
27
  <Sidebar animate={true} opened={isOpen}>
23
28
  {versions}
24
29
  <MenuContainer>{menu}</MenuContainer>
@@ -2,8 +2,10 @@ import React, { useRef } from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import { useFullHeight } from '@theme/hooks/useFullHeight';
5
+ import { useThemeSettings } from '@portal/hooks';
5
6
  import { useActiveHeading } from '@theme/hooks/useActiveHeading';
6
7
  import { MdHeading } from '@theme/types/portal';
8
+ import { DEFAULT_THEME_NAME } from '@portal/constants';
7
9
 
8
10
  interface TableOfContentProps {
9
11
  headings?: Array<MdHeading | null> | null | undefined;
@@ -17,7 +19,11 @@ export function TableOfContent(props: TableOfContentProps): JSX.Element | null {
17
19
  const sidebar = useRef<HTMLDivElement | null>(null);
18
20
  useFullHeight(sidebar);
19
21
  const activeHeadingId = useActiveHeading(contentWrapper);
22
+ const { themeSettings } = useThemeSettings(DEFAULT_THEME_NAME);
20
23
 
24
+ if (themeSettings?.toc?.hide) {
25
+ return null;
26
+ }
21
27
  if (headings && headings.length === 1 && (!headings[0] || headings[0].depth === 1)) {
22
28
  return null;
23
29
  }
@@ -30,7 +36,7 @@ export function TableOfContent(props: TableOfContentProps): JSX.Element | null {
30
36
  {headings && (
31
37
  <TableOfContentMenu data-component-name="TableOfContent/TableOfContent">
32
38
  <TableOfContentItems ref={sidebar}>
33
- <TocHeader>On this page</TocHeader>
39
+ <TocHeader>{themeSettings?.toc?.header?.label || 'On this page'}</TocHeader>
34
40
  {headings.map((heading: MdHeading | null, idx: number) => {
35
41
  // TODO: not sure about !heading
36
42
  if (!heading) {
@@ -0,0 +1,9 @@
1
+ import styled from 'styled-components';
2
+
3
+ import { Typography } from '@theme/Typography/Typography';
4
+
5
+ export const CompactTypography = styled(Typography).attrs(() => ({
6
+ mt: '0em',
7
+ mb: '0em',
8
+ 'data-component-name': 'Typography/CompactTypography',
9
+ }))``;
@@ -0,0 +1,7 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const Emphasis = styled.strong.attrs(() => ({
4
+ 'data-component-name': 'Typography/Emphasis',
5
+ }))`
6
+ font-weight: var(--font-weight-bold);
7
+ `;
@@ -0,0 +1,12 @@
1
+ import styled from 'styled-components';
2
+
3
+ import { typography } from '@theme/utils';
4
+
5
+ export const H1 = styled.h1.attrs(() => ({
6
+ 'data-component-name': 'Headings/H1',
7
+ }))`
8
+ color: var(--color-content);
9
+ margin: 0 0 25px;
10
+
11
+ ${typography('h1', 'h')};
12
+ `;
@@ -0,0 +1,12 @@
1
+ import styled from 'styled-components';
2
+
3
+ import { typography } from '@theme/utils';
4
+
5
+ export const H2 = styled.h2.attrs(() => ({
6
+ 'data-component-name': 'Headings/H2',
7
+ }))`
8
+ color: var(--color-content);
9
+ margin: 0 0 20px;
10
+
11
+ ${typography('h2', 'h')};
12
+ `;
@@ -0,0 +1,11 @@
1
+ import styled from 'styled-components';
2
+
3
+ import { typography } from '@theme/utils';
4
+
5
+ export const H3 = styled.h3.attrs(() => ({
6
+ 'data-component-name': 'Headings/H3',
7
+ }))`
8
+ color: var(--color-content);
9
+
10
+ ${typography('h3', 'h')};
11
+ `;
@@ -0,0 +1,11 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const SectionHeader = styled.h2`
4
+ color: var(--h-color);
5
+ font-size: 1.75em;
6
+ font-weight: var(--font-weight-regular);
7
+ text-align: center;
8
+ margin: 2.65em 0;
9
+ padding: 0 20px;
10
+ font-family: var(--h-font-family);
11
+ `;
@@ -0,0 +1,21 @@
1
+ import styled from 'styled-components';
2
+ import { color, typography as typographySystem, TypographyProps } from 'styled-system';
3
+
4
+ export const Typography = styled.p.attrs(() => ({
5
+ 'data-component-name': 'Typography/Typography',
6
+ }))<
7
+ TypographyProps & {
8
+ color?: string;
9
+ mt?: string;
10
+ mb?: string;
11
+ }
12
+ >`
13
+ font-size: var(--font-size-base);
14
+ font-family: var(--font-family-base);
15
+ line-height: var(--line-height-base);
16
+ color: var(--color-content);
17
+ ${color};
18
+ margin-top: ${({ mt }) => mt || '1em'};
19
+ margin-bottom: ${({ mb }) => mb || '1em'};
20
+ ${typographySystem}
21
+ `;
@@ -0,0 +1,7 @@
1
+ export * from '@theme/Typography/H1';
2
+ export * from '@theme/Typography/H2';
3
+ export * from '@theme/Typography/H3';
4
+ export * from '@theme/Typography/Emphasis';
5
+ export * from '@theme/Typography/SectionHeader';
6
+ export * from '@theme/Typography/Typography';
7
+ export * from '@theme/Typography/CompactTypography';
@@ -735,6 +735,7 @@ const navbar = css`
735
735
  --navbar-height: 60px; // @presenter Spacing
736
736
  --navbar-text-color: #fff; // @presenter Color
737
737
  --navbar-background-color: var(--color-primary-500); // @presenter Color
738
+ --navbar-drowpdown-shadow: 4px 4px 15px -2px rgba(0, 0, 0, 0.5);
738
739
 
739
740
  /**
740
741
  * @tokens Navbar Item
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
- interface IconProps {
4
+ export interface AlertIconProps {
5
5
  type: 'warning' | 'success' | 'danger' | 'attention' | 'info';
6
6
  className?: string;
7
7
  }
8
8
 
9
- function Icon({ type, className }: IconProps) {
9
+ function Icon({ type, className }: AlertIconProps) {
10
10
  switch (type) {
11
11
  case 'warning':
12
12
  return (
@@ -96,7 +96,7 @@ function Icon({ type, className }: IconProps) {
96
96
  }
97
97
 
98
98
  export const AlertIcon = styled(Icon).attrs(() => ({
99
- 'data-component-name': 'ui/AlertIcon',
99
+ 'data-component-name': 'icons/AlertIcon/AlertIcon',
100
100
  }))`
101
101
  position: absolute;
102
102
  left: var(--admonition-padding-horizontal);
@@ -0,0 +1,2 @@
1
+ export { AlertIcon } from '@theme/icons/AlertIcon/AlertIcon';
2
+ export type { AlertIconProps } from '@theme/icons/AlertIcon/AlertIcon';
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
- export interface ArrowProps {
5
- direction?: string;
4
+ export interface ArrowIconProps {
5
+ direction?: 'up' | 'right' | 'left' | 'down';
6
6
  }
7
7
 
8
- function directionToTransform({ direction }: ArrowProps) {
8
+ function directionToTransform({ direction }: ArrowIconProps) {
9
9
  switch (direction) {
10
10
  case 'up':
11
11
  return 180;
@@ -19,14 +19,14 @@ function directionToTransform({ direction }: ArrowProps) {
19
19
  }
20
20
 
21
21
  const Icon = ({ className }: { className?: string }) => (
22
- <span data-component-name="ui/Arrow/Arrow">
22
+ <span data-component-name="icons/ArrowIcon/ArrowIcon">
23
23
  <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 7 5" className={className}>
24
24
  <path d="M3.5 2.51L5.806.205a.7.7 0 01.99.99l-2.8 2.8a.698.698 0 01-.99 0l-2.8-2.8a.7.7 0 11.99-.99L3.5 2.51z" />
25
25
  </svg>
26
26
  </span>
27
27
  );
28
28
 
29
- export const Arrow = styled(Icon)`
29
+ export const ArrowIcon = styled(Icon)`
30
30
  width: var(--sidebar-chevron-size);
31
31
  height: var(--sidebar-chevron-size);
32
32
  fill: var(--sidebar-chevron-color);
@@ -0,0 +1,2 @@
1
+ export { ArrowIcon } from '@theme/icons/ArrowIcon/ArrowIcon';
2
+ export type { ArrowIconProps } from '@theme/icons/ArrowIcon/ArrowIcon';
@@ -1 +1,3 @@
1
1
  export * from '@theme/icons/ShelfIcon';
2
+ export * from '@theme/icons/AlertIcon';
3
+ export * from '@theme/icons/ArrowIcon';
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from './Button';
2
2
  export * from './CopyButton';
3
3
  export * from './JsonViewer';
4
- export * from './Headings';
4
+ export * from './Typography';
5
5
  export * from './SidebarLogo';
6
6
  export * from './CodeBlock';
7
7
  export * from './SamplesPanelControls';
@@ -0,0 +1,2 @@
1
+ export const DEFAULT_THEME_NAME = '@redocly/theme';
2
+ export const USER_THEME_ALIAS = '@theme';
@@ -0,0 +1,17 @@
1
+ interface RawTheme {
2
+ name: string;
3
+ settings?: any;
4
+ }
5
+
6
+ export function useThemeSettings(name: string): RawTheme['settings'] {
7
+ return {
8
+ name,
9
+ settings: {
10
+ toc: { header: 'header', hide: false },
11
+ navigation: {
12
+ nextPageLink: { label: 'next page' },
13
+ previousPageLink: { label: 'prev page' },
14
+ },
15
+ },
16
+ };
17
+ }
@@ -1,4 +1,3 @@
1
- export * from './src/client/styling';
2
1
  export * from './src/client/app/Sidebar/types';
3
2
  export * from './src/server/plugins/portal-config/types';
4
3
  export * from './src/shared/types';
@@ -27,7 +27,7 @@ export interface ItemState extends SidebarNavItem {
27
27
  items: ItemState[];
28
28
  active: boolean;
29
29
  hasActiveSubItem: boolean;
30
- menuStyle?: MenuStyle | null;
30
+ menuStyle?: MenuStyle;
31
31
  }
32
32
  export declare enum MenuType {
33
33
  Separator = "separator",
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import * as chokidar from 'chokidar';
3
3
  import * as fs from 'fs';
4
- import { VersionStore } from '../version-store.js';
5
4
  import { PathVersionInfo } from '../plugins/types.js';
5
+ import { VersionsConfig } from './versions-config.js';
6
6
  declare type WatchCb = (event: 'add' | 'change' | 'unlink', path: string, stats?: fs.Stats) => Promise<void>;
7
7
  export interface ContentRecord {
8
8
  content: string;
@@ -16,15 +16,15 @@ export interface ParsedContentRecord<T = unknown> extends ContentRecord {
16
16
  export interface ContentProvider {
17
17
  cwd: string;
18
18
  filesList: Set<string>;
19
- versions: VersionStore;
19
+ versions: VersionsConfig;
20
20
  loadContent(relativePath: string, parse?: undefined): ContentRecord;
21
21
  loadContent<T = unknown>(relativePath: string, parse: 'yaml'): ParsedContentRecord<T>;
22
22
  loadContent(relativePath: string, parse: 'frontmatter'): ParsedContentRecord<{
23
23
  content: string;
24
- data: unknown;
24
+ data: Record<string, any>;
25
25
  }>;
26
26
  loadContent(relativePath: string, parse: 'yaml' | 'frontmatter' | undefined): ParsedContentRecord;
27
- getVersionInfoByFsPath: (relativePath: string) => PathVersionInfo;
27
+ getVersionInfoByFsPath: (relativePath: string) => PathVersionInfo | undefined;
28
28
  has(relativePath: string): boolean;
29
29
  }
30
30
  export declare class FsContentProvider implements ContentProvider {
@@ -32,20 +32,20 @@ export declare class FsContentProvider implements ContentProvider {
32
32
  cwd: string;
33
33
  private initialContentLoaded;
34
34
  filesList: Set<string>;
35
- versions: VersionStore;
35
+ versions: VersionsConfig;
36
36
  constructor(cwd: string, initialCache?: Map<string, ContentRecord>);
37
37
  private emit;
38
38
  has(relativePath: string): boolean;
39
- getVersionInfoByFsPath(relativePath: string): PathVersionInfo;
39
+ getVersionInfoByFsPath(relativePath: string): PathVersionInfo | undefined;
40
40
  loadContent(relativePath: string, parse?: undefined): ContentRecord;
41
- loadContent(relativePath: string, parse: 'yaml'): ParsedContentRecord<unknown>;
41
+ loadContent<T = unknown>(relativePath: string, parse: 'yaml'): ParsedContentRecord<T>;
42
42
  loadContent(relativePath: string, parse: 'frontmatter'): ParsedContentRecord<{
43
43
  content: string;
44
- data: unknown;
44
+ data: Record<string, any>;
45
45
  }>;
46
46
  watch(test: RegExp, cb: WatchCb): void;
47
47
  stop(): Promise<void>;
48
48
  start(): void;
49
- ready(): Promise<chokidar.FSWatcher>;
49
+ ready(): Promise<chokidar.FSWatcher | undefined>;
50
50
  }
51
51
  export {};
@@ -1,7 +1,7 @@
1
- import type { Version } from '../shared/types';
2
- import { ContentProvider } from './utils/index.js';
3
- import { PathVersionInfo } from './plugins/types';
4
- export declare class VersionStore {
1
+ import type { Version } from '../../shared/types';
2
+ import { PathVersionInfo } from '../plugins/types';
3
+ import type { ContentProvider } from './content-provider';
4
+ export declare class VersionsConfig {
5
5
  contentProvider: ContentProvider;
6
6
  private config;
7
7
  constructor(contentProvider: ContentProvider);
@@ -29,7 +29,7 @@ export declare class VersionStore {
29
29
  * @param allFilePaths
30
30
  */
31
31
  resolveConfig(allFilePaths: Set<string>): void;
32
- getPageVersions(pagePath: string, suffix?: string): Version[];
33
- getDefaultByPath(path: string): string;
34
- getVersionInfoByFsPath(path: string): PathVersionInfo | null;
32
+ getPageVersions(pagePath: string, suffix?: string): Version[] | undefined;
33
+ getDefaultByPath(path: string): string | null | undefined;
34
+ getVersionInfoByFsPath(path: string): PathVersionInfo | undefined;
35
35
  }
@@ -1,23 +1,26 @@
1
- import { Config, RenderNodes } from '@markdoc/markdoc/dist/src/types';
2
- import type { ContentProvider, ContentRecord } from '../../utils/content-provider.js';
1
+ import { Config, Node, RenderableTreeNode } from '@markdoc/markdoc/dist/src/types';
2
+ import type { ContentProvider, ContentRecord } from '../../content/content-provider.js';
3
+ import { PluginDefaultOptions } from '../types.js';
3
4
  import type { RouteDetails } from '../types.js';
4
- export declare type MarkdownOptions = {
5
- contentDir: string;
6
- outdir: string;
7
- getRouteByFsPath: (relativePath: string) => RouteDetails;
8
- getRouteBySlug: (slug: string) => RouteDetails;
9
- contentProvider: ContentProvider;
10
- };
11
5
  export interface MdHeading {
12
6
  id: string;
13
7
  value: string;
14
8
  depth: number;
15
9
  }
10
+ export declare type MarkdownOptions = {
11
+ getRouteByFsPath: (relativePath: string) => RouteDetails | undefined;
12
+ getRouteBySlug?: (slug: string) => RouteDetails | undefined;
13
+ contentProvider: ContentProvider;
14
+ };
15
+ export interface MdPartialsContext {
16
+ partials: Record<string, Node>;
17
+ }
18
+ export declare type MdRenderContext = ContentRecord & PluginDefaultOptions & MdPartialsContext;
19
+ export declare type MdCompilationContext = MdRenderContext & MarkdownOptions;
16
20
  export interface MdCompilationResult {
17
- result: RenderNodes;
21
+ result: RenderableTreeNode;
18
22
  headings: MdHeading[];
19
23
  }
20
- export declare type MdCompilationContext = ContentRecord & MarkdownOptions;
21
24
  export interface ExtendedMarkdocConfig extends Config {
22
25
  currentProcessedPage?: string;
23
26
  }
@@ -1,23 +1,20 @@
1
- import { LogoConfig, RawNavItem, ResolvedNavItem } from '../../../shared/types.js';
2
- export interface PortalConfig extends Record<string, any> {
3
- nav?: RawNavItem[];
4
- logo?: LogoConfig;
5
- themes?: CustomTheme[];
6
- footer?: FooterConfig;
1
+ import { ResolvedConfigLinks } from '../../../shared/types.js';
2
+ import { PortalConfig, RawTheme } from '../../../shared/models/config.js';
3
+ import { Redirect } from '../types';
4
+ export interface GlobalData {
5
+ nav?: ResolvedConfigLinks;
6
+ logo?: PortalConfig['logo'];
7
+ footer?: ResolvedConfigLinks;
8
+ themeSettings?: PortalConfig['themes'];
7
9
  }
8
- export interface CustomTheme {
9
- name: string;
10
- settings?: any;
11
- themeStyles?: string;
12
- }
13
- export interface FooterConfig {
14
- copyrightText?: string;
15
- columns?: FooterColumn[];
16
- }
17
- export interface FooterColumn {
18
- group: string;
19
- label?: string;
20
- items: ResolvedNavItem[];
10
+ export interface GlobalConfig {
11
+ themes: RawTheme[];
12
+ scripts?: string;
13
+ stylesheets?: string;
14
+ redirects: Record<string, Redirect>;
15
+ fileName: string;
16
+ [k: string]: unknown;
21
17
  }
18
+ export declare type RbacConfig = Record<string, string[]>;
22
19
  export declare type CustomEntryPropertyType = Record<string, string | boolean>;
23
20
  export declare type ScriptOrStylesheetConfig = string | CustomEntryPropertyType;
@@ -1,9 +1,11 @@
1
1
  import type { PageProps, ResolvedNavItem } from '../../shared/types.js';
2
2
  import type { Template } from '../store';
3
- import type { ContentProvider } from '../utils/content-provider.js';
3
+ import type { ContentProvider } from '../content/content-provider.js';
4
+ import { SearchData, SearchDocument } from '../../shared/models';
5
+ import type { GlobalData, GlobalConfig, RbacConfig } from './portal-config/types.js';
4
6
  export declare type DataLoaderContext = {
5
- getRouteByFsPath: (relativePath: string) => RouteDetails;
6
- getRouteBySlug: (relativePath: string) => RouteDetails;
7
+ getRouteByFsPath: (relativePath: string) => RouteDetails | undefined;
8
+ getRouteBySlug: (relativePath: string) => RouteDetails | undefined;
7
9
  };
8
10
  export declare type DataLoader<T = any> = (contentProvider: ContentProvider, context: DataLoaderContext) => Promise<T>;
9
11
  export interface RouteDetails {
@@ -16,6 +18,11 @@ export interface RouteDetails {
16
18
  };
17
19
  getNavText?: () => Promise<string>;
18
20
  getSidebar?(): ResolvedNavItem[];
21
+ getSearchDocuments?(): Promise<SearchDocument[]>;
22
+ }
23
+ export interface Redirect {
24
+ to: string;
25
+ type: number;
19
26
  }
20
27
  export interface PathVersionInfo {
21
28
  version: string;
@@ -23,23 +30,22 @@ export interface PathVersionInfo {
23
30
  versionFolderId: string;
24
31
  }
25
32
  export interface ProcessContentActions {
33
+ createSharedData(id: string, data: unknown): string;
34
+ addRouteSharedData(slug: string, dataKey: string, dataId: string): void;
26
35
  addRoute: (route: RouteDetails) => void;
27
36
  createTemplate: (template: Template) => Template;
28
- createSharedData(id: string, data: any): string;
29
- addRouteSharedData(slug: string, dataKey: string, dataId: string): void;
37
+ setRbacConfig: (rbacConfig: RbacConfig) => void;
30
38
  }
31
39
  export interface AfterRoutesCreatedActions {
32
- createSharedData(id: string, data: any): string;
40
+ createSharedData(id: string, data: unknown): string;
33
41
  addRouteSharedData(routeSlug: string, dataKey: string, dataId: string): void;
34
- getRouteByFsPath: (relativePath: string) => RouteDetails;
35
- getRouteBySlug: (relativePath: string) => RouteDetails;
42
+ getRouteByFsPath: (relativePath: string) => RouteDetails | undefined;
43
+ getRouteBySlug: (relativePath: string) => RouteDetails | undefined;
36
44
  getAllRoutes: () => RouteDetails[];
37
- setGlobalData: (data: Record<string, unknown>) => void;
38
- setGlobalConfig: (data: Record<string, unknown>) => void;
39
- addRedirect: (from: string, to: {
40
- to: string;
41
- type: number;
42
- }) => void;
45
+ setGlobalData: (data: GlobalData) => void;
46
+ setGlobalConfig: (data: Partial<GlobalConfig>) => void;
47
+ setSearchData: (data: SearchData) => void;
48
+ addRedirect: (from: string, to: Redirect) => void;
43
49
  contentDir: string;
44
50
  }
45
51
  export interface PluginInstance {
@@ -47,9 +53,11 @@ export interface PluginInstance {
47
53
  processContent?: (content: ContentProvider, actions: ProcessContentActions) => Promise<void>;
48
54
  afterRoutesCreated?: (content: ContentProvider, actions: AfterRoutesCreatedActions) => Promise<void>;
49
55
  }
50
- export interface PluginOptions {
56
+ export interface PluginDefaultOptions {
51
57
  contentDir: string;
52
58
  outdir: string;
59
+ }
60
+ export interface PluginOptions extends PluginDefaultOptions {
53
61
  [k: string]: unknown;
54
62
  }
55
63
  export declare type Plugin = (opts: PluginOptions) => PluginInstance;