@redocly/theme 0.1.26 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Button/Button.js +3 -3
- package/CodeBlock/CodeBlock.js +1 -1
- package/CopyButton/CopyButton.js +17 -1
- package/CopyButton/CopyButtonWrapper.js +1 -1
- package/Footer/Footer.js +2 -1
- package/Footer/FooterColumn.js +1 -1
- package/Footer/FooterColumns.d.ts +2 -2
- package/Footer/FooterColumns.js +1 -1
- package/JsonViewer/JsonViewer.d.ts +2 -0
- package/JsonViewer/JsonViewer.js +53 -22
- package/Markdown/Admonition.js +1 -1
- package/Markdown/CodeSample/CodeSample.js +17 -1
- package/Markdown/Heading.js +11 -2
- package/Markdown/MarkdownWrapper.js +2 -2
- package/Markdown/Mermaid.js +1 -1
- package/Markdown/Sup.d.ts +2 -0
- package/Markdown/Sup.js +19 -0
- package/Markdown/Tabs/Tabs.js +17 -1
- package/Markdown/index.d.ts +4 -3
- package/Markdown/index.js +4 -3
- package/Navbar/MobileNavbarDropdown.d.ts +8 -0
- package/Navbar/MobileNavbarDropdown.js +21 -0
- package/Navbar/MobileNavbarItem.d.ts +15 -0
- package/Navbar/MobileNavbarItem.js +102 -0
- package/Navbar/MobileNavbarMenu.d.ts +6 -0
- package/Navbar/MobileNavbarMenu.js +32 -0
- package/Navbar/MobileNavbarMenuButton.d.ts +4 -0
- package/Navbar/MobileNavbarMenuButton.js +19 -0
- package/Navbar/Navbar.js +26 -4
- package/Navbar/NavbarDropdown.js +1 -1
- package/Navbar/NavbarItem.d.ts +9 -3
- package/Navbar/NavbarItem.js +9 -9
- package/Navbar/NavbarMenu.js +3 -2
- package/PageNavigation/NextPageLink.js +4 -4
- package/PageNavigation/PreviousPageLink.js +4 -4
- package/Panel/PanelComponent.js +18 -2
- package/Profile/Profile.d.ts +8 -0
- package/Profile/Profile.js +60 -0
- package/Profile/index.d.ts +2 -0
- package/Profile/index.js +5 -0
- package/Search/Autocomplete.js +18 -2
- package/Search/utils.js +17 -1
- package/Sidebar/SidebarLayout.js +17 -1
- package/SourceCode/SourceCode.d.ts +10 -3
- package/SourceCode/SourceCode.js +10 -5
- package/TableOfContent/TableOfContent.js +4 -4
- package/Tooltip/Tooltip.d.ts +5 -4
- package/Tooltip/Tooltip.js +43 -21
- package/globalStyle.js +2 -2
- package/hooks/useActiveHeading.js +17 -1
- package/hooks/useActiveSectionId.d.ts +1 -1
- package/hooks/useActiveSectionId.js +17 -1
- package/hooks/useControl.js +17 -1
- package/hooks/useMobileMenu.js +17 -1
- package/hooks/useNavbarHeight.js +17 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/src/Button/Button.tsx +5 -1
- package/src/CodeBlock/CodeBlock.ts +12 -0
- package/src/CopyButton/CopyButtonWrapper.tsx +1 -1
- package/src/Footer/Footer.tsx +4 -3
- package/src/Footer/FooterColumn.tsx +3 -1
- package/src/Footer/FooterColumns.tsx +3 -3
- package/src/JsonViewer/JsonViewer.tsx +55 -40
- package/src/Markdown/Admonition.tsx +1 -1
- package/src/Markdown/Heading.tsx +13 -2
- package/src/Markdown/MarkdownWrapper.tsx +58 -58
- package/src/Markdown/Mermaid.tsx +1 -1
- package/src/Markdown/Sup.tsx +8 -0
- package/src/Markdown/index.ts +4 -3
- package/src/Navbar/MobileNavbarDropdown.tsx +37 -0
- package/src/Navbar/MobileNavbarItem.tsx +116 -0
- package/src/Navbar/MobileNavbarMenu.tsx +106 -0
- package/src/Navbar/MobileNavbarMenuButton.tsx +13 -0
- package/src/Navbar/Navbar.tsx +11 -3
- package/src/Navbar/NavbarDropdown.tsx +1 -1
- package/src/Navbar/NavbarItem.tsx +9 -8
- package/src/Navbar/NavbarMenu.tsx +9 -4
- package/src/PageNavigation/NextPageLink.tsx +3 -3
- package/src/PageNavigation/PreviousPageLink.tsx +3 -3
- package/src/Profile/Profile.tsx +91 -0
- package/src/Profile/index.ts +2 -0
- package/src/SourceCode/SourceCode.tsx +32 -5
- package/src/TableOfContent/TableOfContent.tsx +3 -3
- package/src/Tooltip/Tooltip.tsx +87 -63
- package/src/globalStyle.ts +2 -0
- package/src/hooks/useActiveSectionId.ts +1 -1
- package/src/index.ts +1 -0
- package/src/types/portal/src/client/app/Sidebar/types.d.ts +2 -1
- package/src/types/portal/src/server/constants.d.ts +2 -0
- package/src/types/portal/src/server/dev-server/types.d.ts +22 -0
- package/src/types/portal/src/server/plugins/markdown/types.d.ts +15 -5
- package/src/types/portal/src/server/plugins/portal-config/get-frontmatter-keys-to-resolve.d.ts +2 -0
- package/src/types/portal/src/server/plugins/portal-config/types.d.ts +6 -2
- package/src/types/portal/src/server/plugins/reference-docs/utils.d.ts +26 -0
- package/src/types/portal/src/server/plugins/types.d.ts +29 -12
- package/src/types/portal/src/server/store.d.ts +16 -16
- package/src/types/portal/src/server/utils/fs.d.ts +2 -1
- package/src/types/portal/src/server/utils/index.d.ts +1 -0
- package/src/types/portal/src/server/utils/paths.d.ts +4 -0
- package/src/types/portal/src/server/utils/rbac.d.ts +15 -0
- package/src/types/portal/src/shared/constants.d.ts +7 -0
- package/src/types/portal/src/shared/models/config.d.ts +24 -12
- package/src/types/portal/src/shared/types.d.ts +17 -4
- package/src/types/portal/src/shared/urls.d.ts +1 -1
- package/src/types/portal/src/shared/utils.d.ts +2 -0
- package/src/ui/Burger.tsx +36 -0
- package/src/ui/Flex.tsx +1 -0
- package/src/utils/args-typecheck.ts +9 -0
- package/src/utils/class-names.ts +8 -0
- package/src/utils/color.ts +9 -0
- package/src/utils/highlight.ts +11 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/jsonToHtml.ts +171 -59
- package/src/utils/theme-helpers.ts +3 -1
- package/ui/Burger.d.ts +8 -0
- package/ui/Burger.js +23 -0
- package/ui/Dropdown.js +17 -1
- package/ui/Flex.js +1 -1
- package/ui/UniversalLink.js +17 -1
- package/utils/args-typecheck.d.ts +2 -0
- package/utils/args-typecheck.js +13 -0
- package/utils/class-names.d.ts +1 -0
- package/utils/class-names.js +15 -0
- package/utils/color.d.ts +2 -0
- package/utils/color.js +12 -0
- package/utils/highlight.d.ts +1 -0
- package/utils/highlight.js +12 -1
- package/utils/index.d.ts +3 -0
- package/utils/index.js +3 -0
- package/utils/jsonToHtml.d.ts +4 -1
- package/utils/jsonToHtml.js +287 -83
- package/utils/media-css.js +40 -3
- package/utils/theme-helpers.js +59 -10
package/src/Navbar/Navbar.tsx
CHANGED
|
@@ -5,6 +5,9 @@ import { useThemeSettings } from '@portal/hooks';
|
|
|
5
5
|
import { DEFAULT_THEME_NAME } from '@portal/constants';
|
|
6
6
|
import { ResolvedConfigLinks } from '@theme/types/portal';
|
|
7
7
|
import { NavbarMenu } from '@theme/Navbar';
|
|
8
|
+
import { useMobileMenu } from '@theme/hooks/useMobileMenu';
|
|
9
|
+
import { MobileNavbarMenuButton } from '@theme/Navbar/MobileNavbarMenuButton';
|
|
10
|
+
import { MobileNavbarMenu } from '@theme/Navbar/MobileNavbarMenu';
|
|
8
11
|
|
|
9
12
|
interface NavbarProps {
|
|
10
13
|
menu: ResolvedConfigLinks;
|
|
@@ -13,17 +16,22 @@ interface NavbarProps {
|
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export function Navbar({ menu, logo, search }: NavbarProps): JSX.Element | null {
|
|
16
|
-
const
|
|
17
|
-
const searchSettings =
|
|
19
|
+
const [isOpen, setIsOpen] = useMobileMenu(false);
|
|
20
|
+
const { search: searchSettings, navbar } = useThemeSettings(DEFAULT_THEME_NAME);
|
|
18
21
|
const hideSearch =
|
|
19
22
|
searchSettings?.hide || (searchSettings?.placement && searchSettings?.placement !== 'navbar');
|
|
20
23
|
|
|
21
|
-
if (
|
|
24
|
+
if (navbar?.hide) {
|
|
22
25
|
return null;
|
|
23
26
|
}
|
|
24
27
|
|
|
28
|
+
const openMobileMenu = () => setIsOpen(true);
|
|
29
|
+
const closeMobileMenu = () => setIsOpen(false);
|
|
30
|
+
|
|
25
31
|
return (
|
|
26
32
|
<NavbarContainer data-component-name="Navbar/Navbar">
|
|
33
|
+
<MobileNavbarMenuButton onClick={openMobileMenu} />
|
|
34
|
+
{isOpen && <MobileNavbarMenu closeMenu={closeMobileMenu} menuItems={menu} />}
|
|
27
35
|
{logo}
|
|
28
36
|
<NavbarMenu menuItems={menu} />
|
|
29
37
|
{hideSearch ? null : search}
|
|
@@ -11,18 +11,19 @@ import { Link } from '@portal/Link';
|
|
|
11
11
|
import { withPathPrefix } from '@portal/utils';
|
|
12
12
|
import { NavbarDropdown, DropdownWrapper } from '@theme/Navbar/NavbarDropdown';
|
|
13
13
|
|
|
14
|
-
interface NavbarItemProps {
|
|
14
|
+
export interface NavbarItemProps {
|
|
15
15
|
navItem: ResolvedNavItem;
|
|
16
|
+
className?: string;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export function NavbarItem({ navItem }: NavbarItemProps): JSX.Element | null {
|
|
19
|
+
export function NavbarItem({ navItem, className }: NavbarItemProps): JSX.Element | null {
|
|
19
20
|
const { pathname } = useLocation();
|
|
20
21
|
|
|
21
22
|
if ((navItem as ResolvedNavLinkItem).link) {
|
|
22
23
|
const item = navItem as ResolvedNavLinkItem;
|
|
23
24
|
const isActive = pathname === withPathPrefix(item.link);
|
|
24
25
|
return (
|
|
25
|
-
<NavMenuItem active={isActive} data-component-name="Navbar/NavbarItem">
|
|
26
|
+
<NavMenuItem active={isActive} data-component-name="Navbar/NavbarItem" className={className}>
|
|
26
27
|
<NavLink to={item.link} active={isActive}>
|
|
27
28
|
<NavLabel>{item.label}</NavLabel>
|
|
28
29
|
</NavLink>
|
|
@@ -34,7 +35,7 @@ export function NavbarItem({ navItem }: NavbarItemProps): JSX.Element | null {
|
|
|
34
35
|
const item = navItem as ResolvedNavGroupItem;
|
|
35
36
|
return (
|
|
36
37
|
<NavMenuItemWithDropdownWrapper>
|
|
37
|
-
<NavMenuItem active={false} data-component-name="Navbar/NavbarItem">
|
|
38
|
+
<NavMenuItem active={false} data-component-name="Navbar/NavbarItem" className={className}>
|
|
38
39
|
<NavLabel>{item.label}</NavLabel>
|
|
39
40
|
</NavMenuItem>
|
|
40
41
|
<NavbarDropdown items={item.items as ResolvedNavLinkItem[]} />
|
|
@@ -45,7 +46,7 @@ export function NavbarItem({ navItem }: NavbarItemProps): JSX.Element | null {
|
|
|
45
46
|
return null;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
const NavMenuItemWithDropdownWrapper = styled.div`
|
|
49
|
+
export const NavMenuItemWithDropdownWrapper = styled.div`
|
|
49
50
|
display: inline-block;
|
|
50
51
|
position: relative;
|
|
51
52
|
border-radius: var(--navbar-item-border-radius);
|
|
@@ -57,9 +58,9 @@ const NavMenuItemWithDropdownWrapper = styled.div`
|
|
|
57
58
|
}
|
|
58
59
|
`;
|
|
59
60
|
|
|
60
|
-
const NavMenuItem = styled.li<{ active?: boolean }>`
|
|
61
|
+
export const NavMenuItem = styled.li<{ active?: boolean }>`
|
|
61
62
|
display: inline-block;
|
|
62
|
-
padding:
|
|
63
|
+
padding: 8px calc(var(--sidebar-spacing-horizontal) * 2);
|
|
63
64
|
text-align: center;
|
|
64
65
|
line-height: 1;
|
|
65
66
|
font-size: var(--navbar-item-font-size);
|
|
@@ -70,7 +71,7 @@ const NavMenuItem = styled.li<{ active?: boolean }>`
|
|
|
70
71
|
background: ${({ active }) => (active ? 'var(--navbar-item-active-background-color)' : 'none')};
|
|
71
72
|
`;
|
|
72
73
|
|
|
73
|
-
const NavLink = styled(Link)`
|
|
74
|
+
export const NavLink = styled(Link)`
|
|
74
75
|
color: ${({ active }) =>
|
|
75
76
|
active ? 'var(--navbar-item-active-text-color)' : 'var(--navbar-text-color)'};
|
|
76
77
|
text-decoration: ${({ active }) =>
|
|
@@ -3,9 +3,10 @@ import styled from 'styled-components';
|
|
|
3
3
|
|
|
4
4
|
import { NavbarItem } from '@theme/Navbar/NavbarItem';
|
|
5
5
|
import type { ResolvedConfigLinks, ResolvedNavItem } from '@theme/types/portal';
|
|
6
|
+
import { isPrimitive, isEmptyArray } from '@theme/utils';
|
|
6
7
|
|
|
7
8
|
export function NavbarMenu({ menuItems }: { menuItems: ResolvedConfigLinks }): JSX.Element | null {
|
|
8
|
-
if (
|
|
9
|
+
if (isPrimitive(menuItems) || isEmptyArray(menuItems)) {
|
|
9
10
|
return null;
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -22,11 +23,15 @@ export function NavbarMenu({ menuItems }: { menuItems: ResolvedConfigLinks }): J
|
|
|
22
23
|
|
|
23
24
|
const NavItemsContainer = styled.ul`
|
|
24
25
|
list-style: none;
|
|
25
|
-
margin: 0;
|
|
26
|
+
margin: 0 7px;
|
|
26
27
|
padding: 0;
|
|
27
|
-
display:
|
|
28
|
+
display: none;
|
|
29
|
+
flex-wrap: nowrap;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: flex-end;
|
|
32
|
+
flex: 1;
|
|
28
33
|
|
|
29
34
|
${({ theme }) => theme.mediaQueries.medium} {
|
|
30
|
-
display:
|
|
35
|
+
display: flex;
|
|
31
36
|
}
|
|
32
37
|
`;
|
|
@@ -12,13 +12,13 @@ interface NextPageType {
|
|
|
12
12
|
|
|
13
13
|
export function NextPageLink(): JSX.Element {
|
|
14
14
|
const { nextPage }: NextPageType = useSidebarSiblingsData() || {};
|
|
15
|
-
const {
|
|
15
|
+
const { navigation } = useThemeSettings(DEFAULT_THEME_NAME);
|
|
16
16
|
|
|
17
|
-
if (!nextPage ||
|
|
17
|
+
if (!nextPage || navigation?.hide) {
|
|
18
18
|
return <div> </div>;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const label =
|
|
21
|
+
const label = navigation?.nextPageLink?.label || `Next to ${nextPage.label}`;
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<StyledButton
|
|
@@ -12,13 +12,13 @@ interface PreviousPageType {
|
|
|
12
12
|
|
|
13
13
|
export function PreviousPageLink(): JSX.Element {
|
|
14
14
|
const { prevPage }: PreviousPageType = useSidebarSiblingsData() || {};
|
|
15
|
-
const {
|
|
15
|
+
const { navigation } = useThemeSettings(DEFAULT_THEME_NAME);
|
|
16
16
|
|
|
17
|
-
if (!prevPage ||
|
|
17
|
+
if (!prevPage || navigation?.hide) {
|
|
18
18
|
return <div> </div>;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const label =
|
|
21
|
+
const label = navigation?.nextPageLink?.label || `Back to ${prevPage.label}`;
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<StyledButton
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { getRandomColor } from '@theme/utils';
|
|
5
|
+
|
|
6
|
+
export interface ProfileProps {
|
|
7
|
+
name: string;
|
|
8
|
+
imageUrl?: string;
|
|
9
|
+
color?: string;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const RANDOM_BG_COLOR: string = getRandomColor();
|
|
14
|
+
|
|
15
|
+
function ProfileComponent({ name, imageUrl, onClick, color }: ProfileProps): JSX.Element {
|
|
16
|
+
if (imageUrl) {
|
|
17
|
+
return (
|
|
18
|
+
<ProfileWrapper onClick={onClick}>
|
|
19
|
+
<StyledUserName data-cy="user-name" color={color}>
|
|
20
|
+
{name}
|
|
21
|
+
</StyledUserName>
|
|
22
|
+
{imageUrl && (
|
|
23
|
+
<AvatarWrapper>
|
|
24
|
+
<img data-cy="user-avatar" src={imageUrl} alt="profile" />
|
|
25
|
+
</AvatarWrapper>
|
|
26
|
+
)}
|
|
27
|
+
</ProfileWrapper>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const avatarLetters = `${name.charAt(0).toUpperCase()}${
|
|
32
|
+
name.split(' ')[1]?.charAt(0).toUpperCase() || ''
|
|
33
|
+
}`;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ProfileWrapper onClick={onClick}>
|
|
37
|
+
<StyledUserName data-cy="user-name" color={color}>
|
|
38
|
+
{name}
|
|
39
|
+
</StyledUserName>
|
|
40
|
+
<AvatarWrapper background={RANDOM_BG_COLOR}>
|
|
41
|
+
<span>{avatarLetters}</span>
|
|
42
|
+
</AvatarWrapper>
|
|
43
|
+
</ProfileWrapper>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const Profile = memo<ProfileProps>(ProfileComponent);
|
|
48
|
+
|
|
49
|
+
const ProfileWrapper = styled.div`
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
width: auto;
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const StyledUserName = styled.span`
|
|
57
|
+
color: ${({ color }) => color || 'var(--color-content)'};
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
const AvatarWrapper = styled.div<{ background?: string }>`
|
|
61
|
+
width: 40px;
|
|
62
|
+
height: 40px;
|
|
63
|
+
display: flex;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
position: relative;
|
|
66
|
+
font-size: 1.25rem;
|
|
67
|
+
align-items: center;
|
|
68
|
+
flex-shrink: 0;
|
|
69
|
+
line-height: 1;
|
|
70
|
+
user-select: none;
|
|
71
|
+
border-radius: 50%;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
margin-left: 16px;
|
|
74
|
+
|
|
75
|
+
${({ background }) => css`
|
|
76
|
+
background-color: ${background};
|
|
77
|
+
span {
|
|
78
|
+
color: ${background};
|
|
79
|
+
filter: invert(100%);
|
|
80
|
+
}
|
|
81
|
+
`}
|
|
82
|
+
|
|
83
|
+
& > img {
|
|
84
|
+
color: transparent;
|
|
85
|
+
width: 100%;
|
|
86
|
+
height: 100%;
|
|
87
|
+
object-fit: cover;
|
|
88
|
+
text-align: center;
|
|
89
|
+
text-indent: 10000px;
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { highlight } from '@theme/utils';
|
|
3
|
+
import { highlight, addLineNumbers } from '@theme/utils';
|
|
4
4
|
import {
|
|
5
5
|
SampleControls,
|
|
6
6
|
SampleControlsWrap,
|
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
} from '@theme/SamplesPanelControls';
|
|
9
9
|
import { CopyButtonWrapper } from '@theme/CopyButton';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
interface CommonCodeProps {
|
|
12
|
+
withLineNumbers?: boolean;
|
|
13
|
+
startLineNumber?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SourceCodeProps extends CommonCodeProps {
|
|
12
17
|
lang: string;
|
|
13
18
|
source?: string;
|
|
14
19
|
externalSource?: ExternalSource;
|
|
@@ -16,6 +21,10 @@ export interface SourceCodeProps {
|
|
|
16
21
|
dataTestId?: string;
|
|
17
22
|
}
|
|
18
23
|
|
|
24
|
+
interface CodeProps
|
|
25
|
+
extends Required<Pick<SourceCodeProps, 'lang' | 'source' | 'dataTestId'>>,
|
|
26
|
+
CommonCodeProps {}
|
|
27
|
+
|
|
19
28
|
export interface Sample {
|
|
20
29
|
lang: string;
|
|
21
30
|
label?: string;
|
|
@@ -37,10 +46,18 @@ export function Code({
|
|
|
37
46
|
source,
|
|
38
47
|
lang,
|
|
39
48
|
dataTestId,
|
|
40
|
-
|
|
49
|
+
withLineNumbers,
|
|
50
|
+
startLineNumber,
|
|
51
|
+
}: CodeProps): JSX.Element {
|
|
52
|
+
const highlightedCode = highlight(source, lang);
|
|
53
|
+
|
|
41
54
|
return (
|
|
42
55
|
<PreformattedCodeBlock
|
|
43
|
-
dangerouslySetInnerHTML={{
|
|
56
|
+
dangerouslySetInnerHTML={{
|
|
57
|
+
__html: withLineNumbers
|
|
58
|
+
? addLineNumbers(highlightedCode, startLineNumber)
|
|
59
|
+
: highlightedCode,
|
|
60
|
+
}}
|
|
44
61
|
data-cy={dataTestId}
|
|
45
62
|
/>
|
|
46
63
|
);
|
|
@@ -52,6 +69,8 @@ export function SourceCode({
|
|
|
52
69
|
externalSource,
|
|
53
70
|
withCopyButton,
|
|
54
71
|
dataTestId = 'source-code',
|
|
72
|
+
withLineNumbers,
|
|
73
|
+
startLineNumber,
|
|
55
74
|
}: SourceCodeProps): JSX.Element {
|
|
56
75
|
const _source = source || externalSource?.sample?.get?.(externalSource) || '';
|
|
57
76
|
if (withCopyButton) {
|
|
@@ -60,7 +79,13 @@ export function SourceCode({
|
|
|
60
79
|
{({ renderCopyButton }) => (
|
|
61
80
|
<SampleControlsWrap>
|
|
62
81
|
<SampleControls data-cy="copy-button">{renderCopyButton()}</SampleControls>
|
|
63
|
-
<Code
|
|
82
|
+
<Code
|
|
83
|
+
lang={lang}
|
|
84
|
+
source={_source}
|
|
85
|
+
withLineNumbers={withLineNumbers}
|
|
86
|
+
startLineNumber={startLineNumber}
|
|
87
|
+
dataTestId={dataTestId}
|
|
88
|
+
/>
|
|
64
89
|
</SampleControlsWrap>
|
|
65
90
|
)}
|
|
66
91
|
</CopyButtonWrapper>
|
|
@@ -72,6 +97,8 @@ export function SourceCode({
|
|
|
72
97
|
dataTestId={dataTestId}
|
|
73
98
|
lang={lang}
|
|
74
99
|
source={_source}
|
|
100
|
+
withLineNumbers={withLineNumbers}
|
|
101
|
+
startLineNumber={startLineNumber}
|
|
75
102
|
data-component-name="SourceCode/SourceCode"
|
|
76
103
|
/>
|
|
77
104
|
);
|
|
@@ -19,9 +19,9 @@ export function TableOfContent(props: TableOfContentProps): JSX.Element | null {
|
|
|
19
19
|
const sidebar = useRef<HTMLDivElement | null>(null);
|
|
20
20
|
useFullHeight(sidebar);
|
|
21
21
|
const activeHeadingId = useActiveHeading(contentWrapper);
|
|
22
|
-
const {
|
|
22
|
+
const { toc } = useThemeSettings(DEFAULT_THEME_NAME);
|
|
23
23
|
|
|
24
|
-
if (
|
|
24
|
+
if (toc?.hide) {
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
27
|
if (headings && headings.length === 1 && (!headings[0] || headings[0].depth === 1)) {
|
|
@@ -36,7 +36,7 @@ export function TableOfContent(props: TableOfContentProps): JSX.Element | null {
|
|
|
36
36
|
{headings && (
|
|
37
37
|
<TableOfContentMenu data-component-name="TableOfContent/TableOfContent">
|
|
38
38
|
<TableOfContentItems ref={sidebar}>
|
|
39
|
-
<TocHeader>{
|
|
39
|
+
<TocHeader>{toc?.header?.label || 'On this page'}</TocHeader>
|
|
40
40
|
{headings.map((heading: MdHeading | null, idx: number) => {
|
|
41
41
|
// TODO: not sure about !heading
|
|
42
42
|
if (!heading) {
|
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { PropsWithChildren } from 'react';
|
|
2
|
-
import React, {
|
|
1
|
+
import type { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import React, { useEffect, memo } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
|
|
5
5
|
import { useControl } from '@theme/hooks';
|
|
6
6
|
|
|
7
7
|
export interface TooltipProps {
|
|
8
|
-
tip: string;
|
|
9
|
-
|
|
8
|
+
tip: string | ReactNode;
|
|
9
|
+
isOpen?: boolean;
|
|
10
|
+
withArrow?: boolean;
|
|
10
11
|
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
11
12
|
className?: string;
|
|
12
13
|
width?: string;
|
|
@@ -15,46 +16,48 @@ export interface TooltipProps {
|
|
|
15
16
|
|
|
16
17
|
export function TooltipComponent({
|
|
17
18
|
children,
|
|
18
|
-
|
|
19
|
+
isOpen,
|
|
19
20
|
tip,
|
|
21
|
+
withArrow = true,
|
|
20
22
|
placement = 'top',
|
|
21
23
|
className = 'default',
|
|
22
24
|
width,
|
|
23
|
-
dataTestId
|
|
25
|
+
dataTestId,
|
|
24
26
|
}: PropsWithChildren<TooltipProps>): JSX.Element {
|
|
25
|
-
const { isOpened, handleOpen, handleClose } = useControl(
|
|
27
|
+
const { isOpened, handleOpen, handleClose } = useControl(isOpen);
|
|
26
28
|
|
|
27
|
-
const isControlled =
|
|
29
|
+
const isControlled = isOpen !== undefined;
|
|
28
30
|
|
|
29
31
|
useEffect(() => {
|
|
30
32
|
if (isControlled) {
|
|
31
|
-
if (
|
|
33
|
+
if (isOpen) {
|
|
32
34
|
handleOpen();
|
|
33
35
|
} else {
|
|
34
36
|
handleClose();
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
|
-
}, [
|
|
39
|
+
}, [isOpen, isControlled, handleOpen, handleClose]);
|
|
38
40
|
|
|
39
|
-
const
|
|
40
|
-
handleOpen
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
handleClose();
|
|
45
|
-
}, [handleClose]);
|
|
41
|
+
const controllers = !isControlled && {
|
|
42
|
+
onMouseEnter: handleOpen,
|
|
43
|
+
onMouseLeave: handleClose,
|
|
44
|
+
onClick: handleClose,
|
|
45
|
+
};
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<TooltipWrapper
|
|
49
|
-
|
|
50
|
-
onMouseLeave={isControlled ? undefined : handleLeave}
|
|
51
|
-
onClick={isControlled ? undefined : handleLeave}
|
|
49
|
+
{...controllers}
|
|
52
50
|
className={`tooltip-${className}`}
|
|
53
51
|
data-component-name="Tooltip/Tooltip"
|
|
54
52
|
>
|
|
55
53
|
{children}
|
|
56
54
|
{isOpened && (
|
|
57
|
-
<TooltipBody
|
|
55
|
+
<TooltipBody
|
|
56
|
+
data-cy={dataTestId || (typeof tip === 'string' ? tip : '')}
|
|
57
|
+
placement={placement}
|
|
58
|
+
width={width}
|
|
59
|
+
withArrow={withArrow}
|
|
60
|
+
>
|
|
58
61
|
{tip}
|
|
59
62
|
</TooltipBody>
|
|
60
63
|
)}
|
|
@@ -65,69 +68,85 @@ export function TooltipComponent({
|
|
|
65
68
|
export const Tooltip = memo<PropsWithChildren<TooltipProps>>(TooltipComponent);
|
|
66
69
|
|
|
67
70
|
const PLACEMENTS = {
|
|
68
|
-
top: css
|
|
71
|
+
top: css<Pick<TooltipProps, 'withArrow'>>`
|
|
69
72
|
top: 0;
|
|
70
73
|
left: 50%;
|
|
71
74
|
transform: translate(-50%, -99%);
|
|
72
75
|
margin-top: -10px;
|
|
73
76
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
${({ withArrow }) =>
|
|
78
|
+
withArrow &&
|
|
79
|
+
css`
|
|
80
|
+
&::after {
|
|
81
|
+
border-left: 5px solid transparent;
|
|
82
|
+
border-right: 5px solid transparent;
|
|
83
|
+
border-top-width: 6px;
|
|
84
|
+
border-top-style: solid;
|
|
85
|
+
bottom: 0;
|
|
86
|
+
left: 50%;
|
|
87
|
+
transform: translate(-50%, 99%);
|
|
88
|
+
}
|
|
89
|
+
`}
|
|
83
90
|
`,
|
|
84
|
-
bottom: css
|
|
91
|
+
bottom: css<Pick<TooltipProps, 'withArrow'>>`
|
|
85
92
|
bottom: 0;
|
|
86
93
|
left: 50%;
|
|
87
94
|
transform: translate(-50%, 99%);
|
|
88
95
|
margin-bottom: -10px;
|
|
89
96
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
${({ withArrow }) =>
|
|
98
|
+
withArrow &&
|
|
99
|
+
css`
|
|
100
|
+
&::after {
|
|
101
|
+
border-left: 5px solid transparent;
|
|
102
|
+
border-right: 5px solid transparent;
|
|
103
|
+
border-bottom-width: 6px;
|
|
104
|
+
border-bottom-style: solid;
|
|
105
|
+
top: 0;
|
|
106
|
+
left: 50%;
|
|
107
|
+
transform: translate(-50%, -99%);
|
|
108
|
+
}
|
|
109
|
+
`}
|
|
99
110
|
`,
|
|
100
|
-
left: css
|
|
111
|
+
left: css<Pick<TooltipProps, 'withArrow'>>`
|
|
101
112
|
top: 50%;
|
|
102
113
|
left: 0;
|
|
103
114
|
transform: translate(-100%, -50%);
|
|
104
115
|
margin-left: -10px;
|
|
105
116
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
${({ withArrow }) =>
|
|
118
|
+
withArrow &&
|
|
119
|
+
css`
|
|
120
|
+
&::after {
|
|
121
|
+
border-top: 5px solid transparent;
|
|
122
|
+
border-bottom: 5px solid transparent;
|
|
123
|
+
border-left-width: 6px;
|
|
124
|
+
border-left-style: solid;
|
|
125
|
+
top: 50%;
|
|
126
|
+
right: 0;
|
|
127
|
+
transform: translate(99%, -50%);
|
|
128
|
+
}
|
|
129
|
+
`}
|
|
115
130
|
`,
|
|
116
|
-
right: css
|
|
131
|
+
right: css<Pick<TooltipProps, 'withArrow'>>`
|
|
117
132
|
top: 50%;
|
|
118
133
|
right: 0;
|
|
119
134
|
transform: translate(100%, -50%);
|
|
120
135
|
margin-right: -10px;
|
|
121
136
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
${({ withArrow }) =>
|
|
138
|
+
withArrow &&
|
|
139
|
+
css`
|
|
140
|
+
&::after {
|
|
141
|
+
border-top: 5px solid transparent;
|
|
142
|
+
border-bottom: 5px solid transparent;
|
|
143
|
+
border-right-width: 6px;
|
|
144
|
+
border-right-style: solid;
|
|
145
|
+
top: 50%;
|
|
146
|
+
left: 0;
|
|
147
|
+
transform: translate(-99%, -50%);
|
|
148
|
+
}
|
|
149
|
+
`}
|
|
131
150
|
`,
|
|
132
151
|
};
|
|
133
152
|
|
|
@@ -136,7 +155,9 @@ const TooltipWrapper = styled.div`
|
|
|
136
155
|
display: inline-block;
|
|
137
156
|
`;
|
|
138
157
|
|
|
139
|
-
const TooltipBody = styled.span<
|
|
158
|
+
const TooltipBody = styled.span<
|
|
159
|
+
Pick<Required<TooltipProps>, 'placement' | 'withArrow'> & { width?: string }
|
|
160
|
+
>`
|
|
140
161
|
display: inline-block;
|
|
141
162
|
|
|
142
163
|
position: absolute;
|
|
@@ -168,5 +189,8 @@ const TooltipBody = styled.span<Pick<Required<TooltipProps>, 'placement'> & { wi
|
|
|
168
189
|
box-shadow: rgb(0 0 0 / 25%) 0 2px 4px;
|
|
169
190
|
|
|
170
191
|
width: ${({ width }) => width || '120px'};
|
|
171
|
-
${({ placement }) =>
|
|
192
|
+
${({ placement }) =>
|
|
193
|
+
css`
|
|
194
|
+
${PLACEMENTS[placement]};
|
|
195
|
+
`}
|
|
172
196
|
`;
|
package/src/globalStyle.ts
CHANGED
|
@@ -299,6 +299,7 @@ const buttons = css`
|
|
|
299
299
|
* @tokens Button borders
|
|
300
300
|
*/
|
|
301
301
|
--button-border-radius: var(--global-border-radius); // @presenter BorderRadius
|
|
302
|
+
--button-margin: 5px; // @presenter Margin
|
|
302
303
|
--button-box-shadow: none; // @presenter Shadow
|
|
303
304
|
--button-active-box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.1); // @presenter Shadow
|
|
304
305
|
|
|
@@ -751,6 +752,7 @@ const navbar = css`
|
|
|
751
752
|
--navbar-item-font-weight: var(--font-weight-bold); // @presenter FontWeight
|
|
752
753
|
--navbar-item-active-background-color: #1b75fa; // @presenter Color
|
|
753
754
|
--navbar-item-active-text-color: var(--navbar-text-color); // @presenter Color
|
|
755
|
+
--navbar-item-separator-line-color: var(--sidebar-separator-line-color); // @presenter Color
|
|
754
756
|
--navbar-item-active-text-decoration: none;
|
|
755
757
|
|
|
756
758
|
// @tokens End
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PERMISSION_PROP_NAME } from '../../../shared/constants';
|
|
1
2
|
import { MenuStyle } from '../../../shared/types';
|
|
2
3
|
export interface SidebarNavItem {
|
|
3
4
|
label?: string;
|
|
@@ -18,7 +19,7 @@ export interface SidebarNavItem {
|
|
|
18
19
|
target?: string;
|
|
19
20
|
external?: boolean;
|
|
20
21
|
items?: SidebarNavItem[];
|
|
21
|
-
|
|
22
|
+
[PERMISSION_PROP_NAME]?: string;
|
|
22
23
|
menuStyle?: MenuStyle;
|
|
23
24
|
separatorLine?: boolean;
|
|
24
25
|
version?: string;
|
|
@@ -5,3 +5,5 @@ export declare enum cliCommandNames {
|
|
|
5
5
|
export declare const VERSION_SEPARATOR = "@";
|
|
6
6
|
export declare const DEFAULT_VERSION_NAME = "default";
|
|
7
7
|
export declare const VERSIONED_FOLDER_REGEXP_MATCH: RegExp;
|
|
8
|
+
export declare const PORTAL_CONFIG_FILE_NAME = "portal.yaml";
|
|
9
|
+
export declare const JWT_SECRET_KEY: string;
|