@redocly/theme 0.1.15 → 0.1.20

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 (118) hide show
  1. package/CopyButton/CopyButton.js +24 -13
  2. package/CopyButton/CopyButtonWrapper.js +25 -13
  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 +5 -14
  9. package/Footer/FooterColumn.d.ts +2 -2
  10. package/Footer/FooterColumn.js +10 -18
  11. package/Footer/FooterColumns.d.ts +6 -4
  12. package/Footer/FooterColumns.js +5 -15
  13. package/Footer/FooterCopyright.d.ts +6 -4
  14. package/Footer/FooterCopyright.js +2 -13
  15. package/JsonViewer/JsonViewer.js +33 -16
  16. package/JsonViewer/styled.js +1 -1
  17. package/Layout/PageLayout.js +4 -13
  18. package/Layout/RootLayout.js +5 -13
  19. package/Markdown/Admonition.js +5 -13
  20. package/Markdown/CodeSample/CodeSample.js +29 -13
  21. package/Markdown/CodeSample/styled.js +51 -4
  22. package/Markdown/Heading.js +29 -15
  23. package/Markdown/MarkdownLayout.js +8 -12
  24. package/Markdown/Mermaid.js +2 -2
  25. package/Markdown/Tabs/Tab.js +2 -13
  26. package/Markdown/Tabs/Tabs.js +33 -20
  27. package/Navbar/Navbar.d.ts +2 -1
  28. package/Navbar/Navbar.js +6 -13
  29. package/Navbar/NavbarDropdown.d.ts +8 -0
  30. package/Navbar/NavbarDropdown.js +21 -0
  31. package/Navbar/NavbarItem.d.ts +3 -36
  32. package/Navbar/NavbarItem.js +23 -23
  33. package/Navbar/NavbarMenu.d.ts +2 -1
  34. package/Navbar/NavbarMenu.js +4 -15
  35. package/NavbarLogo/NavbarLogo.js +3 -14
  36. package/PageNavigation/NextPageLink.js +7 -13
  37. package/PageNavigation/PageNavigation.js +4 -13
  38. package/PageNavigation/PreviousPageLink.js +7 -13
  39. package/Panel/PanelComponent.js +30 -14
  40. package/Search/Autocomplete.js +30 -3
  41. package/Search/ClearIcon.js +3 -2
  42. package/Search/Parameters.js +17 -17
  43. package/Search/Search.js +3 -13
  44. package/Search/SearchIcon.js +3 -2
  45. package/Search/SearchItem.js +30 -13
  46. package/Search/utils.js +28 -2
  47. package/Sidebar/ApiCallItem.js +7 -13
  48. package/Sidebar/ArrowBack.js +5 -13
  49. package/Sidebar/BackButton.js +4 -13
  50. package/Sidebar/Drilldown.js +6 -2
  51. package/Sidebar/DrilldownMenu.js +10 -13
  52. package/Sidebar/DrilldownMenuItem.js +6 -13
  53. package/Sidebar/ExternalIcon.js +7 -13
  54. package/Sidebar/MenuGroup.js +8 -13
  55. package/Sidebar/MenuItem.js +7 -13
  56. package/Sidebar/MenuLinkItem.js +2 -2
  57. package/Sidebar/Separator.js +4 -13
  58. package/Sidebar/SidebarLayout.js +6 -13
  59. package/SidebarLogo/SidebarLogo.js +3 -14
  60. package/SourceCode/SourceCode.js +11 -17
  61. package/TableOfContent/TableOfContent.js +40 -26
  62. package/Tooltip/Tooltip.js +4 -14
  63. package/globalStyle.js +1 -1
  64. package/icons/ShelfIcon/ShelfIcon.js +4 -13
  65. package/mocks/Link.js +5 -2
  66. package/package.json +1 -1
  67. package/src/Footer/CustomFooter.tsx +45 -0
  68. package/src/Footer/CustomFooterNavItem.tsx +40 -0
  69. package/src/Footer/Footer.tsx +6 -2
  70. package/src/Footer/FooterColumn.tsx +4 -4
  71. package/src/Footer/FooterColumns.tsx +9 -9
  72. package/src/Footer/FooterCopyright.tsx +6 -6
  73. package/src/JsonViewer/styled.ts +10 -3
  74. package/src/Markdown/CodeSample/styled.ts +48 -48
  75. package/src/Navbar/Navbar.tsx +5 -2
  76. package/src/Navbar/NavbarDropdown.tsx +44 -0
  77. package/src/Navbar/NavbarItem.tsx +44 -51
  78. package/src/Navbar/NavbarMenu.tsx +6 -3
  79. package/src/globalStyle.ts +1 -0
  80. package/src/types/portal/index.d.ts +0 -1
  81. package/src/types/portal/src/client/app/Sidebar/types.d.ts +1 -1
  82. package/src/types/portal/src/server/{utils → content}/content-provider.d.ts +9 -9
  83. package/src/types/portal/src/server/{version-store.d.ts → content/versions-config.d.ts} +7 -7
  84. package/src/types/portal/src/server/plugins/markdown/types.d.ts +14 -11
  85. package/src/types/portal/src/server/plugins/portal-config/types.d.ts +16 -19
  86. package/src/types/portal/src/server/plugins/types.d.ts +23 -15
  87. package/src/types/portal/src/server/store.d.ts +32 -33
  88. package/src/types/portal/src/server/utils/fs.d.ts +2 -1
  89. package/src/types/portal/src/server/utils/index.d.ts +0 -1
  90. package/src/types/portal/src/server/utils/paths.d.ts +3 -3
  91. package/src/types/portal/src/server/utils/reporter/formatter.d.ts +2 -1
  92. package/src/types/portal/src/server/utils/reporter/reporter.d.ts +2 -1
  93. package/src/types/portal/src/shared/constants.d.ts +2 -0
  94. package/src/types/portal/src/shared/models/active-item.d.ts +3 -0
  95. package/src/types/portal/src/shared/models/config.d.ts +28 -0
  96. package/src/types/portal/src/shared/models/index.d.ts +6 -0
  97. package/src/types/portal/src/shared/models/json-index.d.ts +5 -0
  98. package/src/types/portal/src/shared/models/operation-parameter.d.ts +6 -0
  99. package/src/types/portal/src/shared/models/search-data.d.ts +5 -0
  100. package/src/types/portal/src/shared/models/search-document.d.ts +11 -0
  101. package/src/types/portal/src/shared/types.d.ts +8 -2
  102. package/src/types/portal/src/shared/urls.d.ts +2 -0
  103. package/src/types/portal/src/shared/utils.d.ts +8 -2
  104. package/src/utils/ClipboardService.ts +19 -0
  105. package/ui/AlertIcon.js +20 -17
  106. package/ui/Arrow.js +4 -13
  107. package/ui/Button.js +6 -3
  108. package/ui/Dropdown.js +32 -14
  109. package/ui/Flex.js +2 -2
  110. package/ui/Tiles/ThinTile.js +29 -13
  111. package/ui/Tiles/WideTile.js +29 -13
  112. package/ui/UniversalLink.js +26 -3
  113. package/utils/ClipboardService.d.ts +1 -0
  114. package/utils/ClipboardService.js +19 -0
  115. package/src/types/portal/src/client/app/media-css.d.ts +0 -7
  116. package/src/types/portal/src/client/styling/default.d.ts +0 -601
  117. package/src/types/portal/src/client/styling/index.d.ts +0 -10
  118. package/src/types/portal/src/client/styling/resolve.d.ts +0 -1
package/mocks/Link.js CHANGED
@@ -10,15 +10,18 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
13
16
  Object.defineProperty(exports, "__esModule", { value: true });
14
17
  exports.Link = void 0;
15
- var jsx_runtime_1 = require("react/jsx-runtime");
18
+ var react_1 = __importDefault(require("react"));
16
19
  var lodash_1 = require("lodash");
17
20
  // TODO: use real typings here
18
21
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
19
22
  function Link(props) {
20
23
  // We omit "active" property to avoid "Warning: Received `false` for a non-boolean attribute `active`."
21
24
  var filteredProps = (0, lodash_1.omit)(props, ['active', 'httpVerb', 'hasActiveSubItem']);
22
- return (0, jsx_runtime_1.jsx)("a", __assign({ href: filteredProps.to }, filteredProps));
25
+ return react_1.default.createElement("a", __assign({ href: filteredProps.to }, filteredProps));
23
26
  }
24
27
  exports.Link = Link;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.1.15",
3
+ "version": "0.1.20",
4
4
  "description": "Shared UI components",
5
5
  "author": "team@redocly.com",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import { CustomFooterNavItem } from '@theme/Footer/CustomFooterNavItem';
5
+ import { FooterCopyright } from '@theme/Footer/FooterCopyright';
6
+ import { NavGroupRecord, ResolvedNavItem } from '@theme/types/portal';
7
+
8
+ interface FooterProps {
9
+ data: NavGroupRecord;
10
+ }
11
+
12
+ export function CustomFooter({ data }: FooterProps): JSX.Element | null {
13
+ if (!data) {
14
+ return null;
15
+ }
16
+
17
+ return (
18
+ <FooterContainer data-component-name="Footer/CustomFooter">
19
+ {(data.links as ResolvedNavItem[]).map((navItem, index) => {
20
+ return (
21
+ <CustomFooterNavItem
22
+ key={`${navItem.label}_${index}`}
23
+ data-cy={navItem.label}
24
+ navItem={navItem}
25
+ />
26
+ );
27
+ })}
28
+ <FooterCopyright copyrightText={data.copyrightText} />
29
+ </FooterContainer>
30
+ );
31
+ }
32
+
33
+ const FooterContainer = styled.div`
34
+ list-style: none;
35
+ margin: 0;
36
+ padding: 0;
37
+ display: block;
38
+ background-color: var(--footer-background-color);
39
+ text-align: center;
40
+ font-family: var(--font-family-base);
41
+
42
+ ${({ theme }) => theme.mediaQueries.medium} {
43
+ display: block;
44
+ }
45
+ `;
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import { Link } from '@portal/Link';
5
+ import type { ResolvedNavItem, ResolvedNavLinkItem } from '@theme/types/portal';
6
+
7
+ interface CustomFooterNavItemProps {
8
+ navItem: ResolvedNavItem;
9
+ }
10
+
11
+ export function CustomFooterNavItem({ navItem }: CustomFooterNavItemProps): JSX.Element {
12
+ const item = navItem as ResolvedNavLinkItem;
13
+
14
+ return (
15
+ <FooterItem data-component-name="Navbar/NavbarItem">
16
+ <FooterLink to={item.link}>
17
+ <FooterLabel>{item.label}</FooterLabel>
18
+ </FooterLink>
19
+ </FooterItem>
20
+ );
21
+ }
22
+
23
+ const FooterItem = styled.li`
24
+ display: inline-block;
25
+ text-align: center;
26
+ line-height: var(--line-height-base);
27
+ font-size: var(--navbar-item-font-size);
28
+ margin: calc(var(--spacing-unit) * 2) calc(var(--spacing-unit) * 3);
29
+ font-weight: var(--font-weight-regular);
30
+ `;
31
+
32
+ const FooterLink = styled(Link)`
33
+ color: var(--footer-text-color);
34
+ text-decoration: none;
35
+ `;
36
+
37
+ const FooterLabel = styled.span`
38
+ cursor: pointer;
39
+ vertical-align: middle;
40
+ `;
@@ -3,9 +3,13 @@ import styled from 'styled-components';
3
3
 
4
4
  import { FooterColumns } from '@theme/Footer/FooterColumns';
5
5
  import { FooterCopyright } from '@theme/Footer/FooterCopyright';
6
- import type { FooterConfig } from '@theme/types/portal';
6
+ import type { NavGroupRecord } from '@theme/types/portal';
7
7
 
8
- export function Footer({ columns, copyrightText }: FooterConfig): JSX.Element | null {
8
+ interface FooterProps {
9
+ data: NavGroupRecord;
10
+ }
11
+
12
+ export function Footer({ data: { columns, copyrightText } }: FooterProps): JSX.Element | null {
9
13
  if (!(columns?.length || copyrightText)) {
10
14
  return null;
11
15
  }
@@ -2,17 +2,17 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import { Link } from '@portal/Link';
5
- import type { FooterColumn as Column } from '@theme/types/portal';
5
+ import type { ResolvedNavItem } from '@theme/types/portal';
6
6
 
7
7
  interface FooterColumnProps {
8
- column: Column;
8
+ column: ResolvedNavItem;
9
9
  }
10
10
 
11
11
  export function FooterColumn({ column }: FooterColumnProps): JSX.Element {
12
12
  return (
13
13
  <FooterColumnContainer data-component-name="Footer/FooterColumn">
14
- <FooterColumnTitle>{column.group || column.label}</FooterColumnTitle>
15
- {column.items.map((columnItem, columnItemIndex) => {
14
+ <FooterColumnTitle>{column.label}</FooterColumnTitle>
15
+ {column?.items?.map((columnItem, columnItemIndex) => {
16
16
  if (columnItem.type === 'error') {
17
17
  return null;
18
18
  }
@@ -2,14 +2,14 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import { FooterColumn } from '@theme/Footer/FooterColumn';
5
- import type { FooterConfig } from '@theme/types/portal';
6
-
7
- export function FooterColumns({
8
- columns = [],
9
- }: {
10
- columns?: FooterConfig['columns'];
11
- }): JSX.Element | null {
12
- if (!columns?.length) {
5
+ import type { NavGroup } from '@theme/types/portal';
6
+
7
+ interface FooterColumnsProps {
8
+ columns: NavGroup;
9
+ }
10
+
11
+ export function FooterColumns({ columns }: FooterColumnsProps): JSX.Element | null {
12
+ if (typeof columns === 'string' || typeof columns === 'undefined' || !columns?.length) {
13
13
  return null;
14
14
  }
15
15
 
@@ -17,7 +17,7 @@ export function FooterColumns({
17
17
  <FooterColumnsContainer data-component-name="Footer/FooterColumns">
18
18
  <FooterRow>
19
19
  {columns.map((column, index) => (
20
- <FooterColumn key={index} column={column} />
20
+ <FooterColumn key={`${column.label}_${index}`} column={column} />
21
21
  ))}
22
22
  </FooterRow>
23
23
  </FooterColumnsContainer>
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
- import type { FooterConfig } from '@theme/types/portal';
4
+ import type { NavGroup } from '@theme/types/portal';
5
5
 
6
- export function FooterCopyright({
7
- copyrightText = '',
8
- }: {
9
- copyrightText?: FooterConfig['copyrightText'];
10
- }): JSX.Element | null {
6
+ interface FooterCopyrightProps {
7
+ copyrightText: NavGroup;
8
+ }
9
+
10
+ export function FooterCopyright({ copyrightText = '' }: FooterCopyrightProps): JSX.Element | null {
11
11
  return copyrightText ? (
12
12
  <Wrapper data-component-name="Footer/FooterCopyright">{copyrightText}</Wrapper>
13
13
  ) : null;
@@ -1,9 +1,16 @@
1
1
  import { css } from 'styled-components';
2
2
 
3
3
  export const jsonStyles = css`
4
- .redoc-json code > .collapser {
5
- display: none;
6
- pointer-events: none;
4
+ .redoc-json code {
5
+ background-color: var(--samples-panel-controls-background-color);
6
+ color: var(--color-content-inverse);
7
+ padding: inherit;
8
+ border: none;
9
+
10
+ & > .collapser {
11
+ display: none;
12
+ pointer-events: none;
13
+ }
7
14
  }
8
15
 
9
16
  contain: content;
@@ -21,54 +21,54 @@ export const DoneIndicator = styled.div`
21
21
  cursor: default;
22
22
  `;
23
23
 
24
- const lightStyleTokens = css`
25
- .token.comment,
26
- .token.prolog,
27
- .token.doctype,
28
- .token.cdata {
29
- color: #999988;
30
- font-style: italic;
31
- }
32
- .token.namespace {
33
- opacity: 0.7;
34
- }
35
- .token.string,
36
- .token.attr-value {
37
- color: #e3116c;
38
- }
39
- .token.punctuation,
40
- .token.operator {
41
- color: #393a34; /* no highlight */
42
- }
43
- .token.entity,
44
- .token.url,
45
- .token.symbol,
46
- .token.number,
47
- .token.boolean,
48
- .token.variable,
49
- .token.constant,
50
- .token.property,
51
- .token.regex,
52
- .token.inserted {
53
- color: #36acaa;
54
- }
55
- .token.atrule,
56
- .token.keyword,
57
- .token.attr-name,
58
- .language-autohotkey .token.selector {
59
- color: #00a4db;
60
- }
61
- .token.function,
62
- .token.deleted,
63
- .language-autohotkey .token.tag {
64
- color: #9a050f;
65
- }
66
- .token.tag,
67
- .token.selector,
68
- .language-autohotkey .token.keyword {
69
- color: #00009f;
70
- }
71
- `;
24
+ // const lightStyleTokens = css`
25
+ // .token.comment,
26
+ // .token.prolog,
27
+ // .token.doctype,
28
+ // .token.cdata {
29
+ // color: #999988;
30
+ // font-style: italic;
31
+ // }
32
+ // .token.namespace {
33
+ // opacity: 0.7;
34
+ // }
35
+ // .token.string,
36
+ // .token.attr-value {
37
+ // color: #e3116c;
38
+ // }
39
+ // .token.punctuation,
40
+ // .token.operator {
41
+ // color: #393a34; /* no highlight */
42
+ // }
43
+ // .token.entity,
44
+ // .token.url,
45
+ // .token.symbol,
46
+ // .token.number,
47
+ // .token.boolean,
48
+ // .token.variable,
49
+ // .token.constant,
50
+ // .token.property,
51
+ // .token.regex,
52
+ // .token.inserted {
53
+ // color: #36acaa;
54
+ // }
55
+ // .token.atrule,
56
+ // .token.keyword,
57
+ // .token.attr-name,
58
+ // .language-autohotkey .token.selector {
59
+ // color: #00a4db;
60
+ // }
61
+ // .token.function,
62
+ // .token.deleted,
63
+ // .language-autohotkey .token.tag {
64
+ // color: #9a050f;
65
+ // }
66
+ // .token.tag,
67
+ // .token.selector,
68
+ // .language-autohotkey .token.keyword {
69
+ // color: #00009f;
70
+ // }
71
+ // `;
72
72
 
73
73
  const darkStyleTokens = css`
74
74
  .token.comment,
@@ -1,8 +1,11 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
+ import { ResolvedConfigLinks } from '@theme/types/portal';
5
+ import { NavbarMenu } from '@theme/Navbar';
6
+
4
7
  interface NavbarProps {
5
- menu: React.ReactNode;
8
+ menu: ResolvedConfigLinks;
6
9
  logo: React.ReactNode;
7
10
  search: React.ReactNode;
8
11
  }
@@ -11,7 +14,7 @@ export function Navbar({ menu, logo, search }: NavbarProps): JSX.Element {
11
14
  return (
12
15
  <NavbarContainer data-component-name="Navbar/Navbar">
13
16
  {logo}
14
- {menu}
17
+ <NavbarMenu menuItems={menu} />
15
18
  {search}
16
19
  </NavbarContainer>
17
20
  );
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import type { ResolvedNavLinkItem } from '@theme/types/portal';
5
+ import { Link } from '@portal/Link';
6
+
7
+ interface NavbarDropdownProps {
8
+ items: ResolvedNavLinkItem[];
9
+ }
10
+
11
+ export function NavbarDropdown({ items }: NavbarDropdownProps): JSX.Element {
12
+ return (
13
+ <DropdownWrapper data-component-name="Navbar/NavbarDropdown">
14
+ {items.map((item, index) => (
15
+ <div key={`${item.label}_${index}`}>
16
+ <Link to={item.link}>{item.label}</Link>
17
+ </div>
18
+ ))}
19
+ </DropdownWrapper>
20
+ );
21
+ }
22
+
23
+ export const DropdownWrapper = styled.div`
24
+ display: none;
25
+ position: absolute;
26
+ background: var(--navbar-item-active-background-color);
27
+ border-radius: var(--navbar-item-border-radius);
28
+ padding: 10px 15px;
29
+ width: max-content;
30
+ line-height: 1rem;
31
+ box-shadow: var(--navbar-dropdown-shadow);
32
+ & > div {
33
+ text-align: left;
34
+ padding: 10px 0px;
35
+ cursor: pointer;
36
+ a {
37
+ color: var(--navbar-text-color);
38
+ text-decoration: none;
39
+ }
40
+ :hover {
41
+ text-decoration: underline;
42
+ }
43
+ }
44
+ `;
@@ -2,67 +2,60 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { useLocation } from 'react-router-dom';
4
4
 
5
+ import type {
6
+ ResolvedNavItem,
7
+ ResolvedNavLinkItem,
8
+ ResolvedNavGroupItem,
9
+ } from '@theme/types/portal';
5
10
  import { Link } from '@portal/Link';
6
11
  import { withPathPrefix } from '@portal/utils';
12
+ import { NavbarDropdown, DropdownWrapper } from '@theme/Navbar/NavbarDropdown';
7
13
 
8
- export enum MenuStyle {
9
- Drilldown = 'drilldown',
14
+ interface NavbarItemProps {
15
+ navItem: ResolvedNavItem;
10
16
  }
11
17
 
12
- export type ResolvedNavLinkItem = {
13
- type: 'link';
14
- link: string;
15
- label: string;
16
- items?: ResolvedNavItem[];
17
- external?: boolean;
18
- version?: string;
19
- default?: string;
20
- httpVerb?: string; // TODO: make a separate type of item
21
- separatorLine?: boolean;
22
- active?: boolean;
23
- };
18
+ export function NavbarItem({ navItem }: NavbarItemProps): JSX.Element | null {
19
+ const { pathname } = useLocation();
24
20
 
25
- export type ResolvedNavGroupItem = {
26
- type: 'group';
27
- link?: string;
28
- label: string;
29
- items: ResolvedNavItem[];
30
- version?: string;
31
- default?: string;
32
- menuStyle?: MenuStyle;
33
- separatorLine?: boolean;
34
- active?: boolean;
35
- };
21
+ if ((navItem as ResolvedNavLinkItem).link) {
22
+ const item = navItem as ResolvedNavLinkItem;
23
+ const isActive = pathname === withPathPrefix(item.link);
24
+ return (
25
+ <NavMenuItem active={isActive} data-component-name="Navbar/NavbarItem">
26
+ <NavLink to={item.link} active={isActive}>
27
+ <NavLabel>{item.label}</NavLabel>
28
+ </NavLink>
29
+ </NavMenuItem>
30
+ );
31
+ }
36
32
 
37
- export type ResolvedNavItem =
38
- | ResolvedNavLinkItem
39
- | ResolvedNavGroupItem
40
- | {
41
- type: 'separator';
42
- label?: string;
43
- separatorLine?: boolean;
44
- }
45
- | {
46
- type: 'error';
47
- label: string;
48
- };
33
+ if ((navItem as ResolvedNavGroupItem).items) {
34
+ const item = navItem as ResolvedNavGroupItem;
35
+ return (
36
+ <NavMenuItemWithDropdownWrapper>
37
+ <NavMenuItem active={false} data-component-name="Navbar/NavbarItem">
38
+ <NavLabel>{item.label}</NavLabel>
39
+ </NavMenuItem>
40
+ <NavbarDropdown items={item.items as ResolvedNavLinkItem[]} />
41
+ </NavMenuItemWithDropdownWrapper>
42
+ );
43
+ }
49
44
 
50
- interface NavbarItemProps {
51
- navItem: ResolvedNavLinkItem;
45
+ return null;
52
46
  }
53
47
 
54
- export function NavbarItem({ navItem }: NavbarItemProps): JSX.Element {
55
- const { pathname } = useLocation();
56
- const isActive = pathname === withPathPrefix(navItem.link);
57
-
58
- return (
59
- <NavMenuItem active={isActive} data-component-name="Navbar/NavbarItem">
60
- <NavLink to={navItem.link} active={isActive}>
61
- <NavLabel>{navItem.label}</NavLabel>
62
- </NavLink>
63
- </NavMenuItem>
64
- );
65
- }
48
+ const NavMenuItemWithDropdownWrapper = styled.div`
49
+ display: inline-block;
50
+ position: relative;
51
+ border-radius: var(--navbar-item-border-radius);
52
+ &:hover {
53
+ background: var(--navbar-item-active-background-color);
54
+ ${DropdownWrapper} {
55
+ display: block;
56
+ }
57
+ }
58
+ `;
66
59
 
67
60
  const NavMenuItem = styled.li<{ active?: boolean }>`
68
61
  display: inline-block;
@@ -2,16 +2,19 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import { NavbarItem } from '@theme/Navbar/NavbarItem';
5
+ import type { ResolvedConfigLinks, ResolvedNavItem } from '@theme/types/portal';
5
6
 
6
- export function NavbarMenu({ menuItems }: { menuItems: any[] }): JSX.Element | null {
7
+ export function NavbarMenu({ menuItems }: { menuItems: ResolvedConfigLinks }): JSX.Element | null {
7
8
  if (!menuItems?.length) {
8
9
  return null;
9
10
  }
10
11
 
11
12
  return (
12
13
  <NavItemsContainer data-component-name="Navbar/NavbarMenu">
13
- {menuItems.map((navItem, index) => {
14
- return <NavbarItem key={index} data-cy={navItem.label} navItem={navItem} />;
14
+ {(menuItems as ResolvedNavItem[]).map((navItem, index) => {
15
+ return (
16
+ <NavbarItem key={`${navItem.label}_${index}`} data-cy={navItem.label} navItem={navItem} />
17
+ );
15
18
  })}
16
19
  </NavItemsContainer>
17
20
  );
@@ -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,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
  }