@redocly/theme 0.6.3 → 0.6.4
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/lib/Button/Button.d.ts +3 -3
- package/lib/Markdown/CodeSample/CodeSample.d.ts +1 -1
- package/lib/Markdown/Details.d.ts +1 -1
- package/lib/Markdown/MarkdownLayout.d.ts +1 -1
- package/lib/Markdown/Mermaid.d.ts +1 -1
- package/lib/Markdown/Tabs/Tab.d.ts +1 -1
- package/lib/Markdown/Tabs/Tabs.d.ts +1 -1
- package/lib/Navbar/MobileNavbarMenu.d.ts +3 -2
- package/lib/Navbar/MobileNavbarMenu.js +16 -4
- package/lib/Navbar/Navbar.js +3 -1
- package/lib/NavbarLogo/NavbarLogo.d.ts +1 -1
- package/lib/Profile/Profile.js +5 -0
- package/lib/Search/Autocomplete.js +1 -0
- package/lib/Search/Popover.js +9 -1
- package/lib/Search/Search.js +37 -4
- package/lib/Sidebar/ArrowBack.js +2 -2
- package/lib/Sidebar/SidebarLayout.d.ts +1 -5
- package/lib/Sidebar/SidebarLayout.js +1 -26
- package/lib/SourceCode/SourceCode.d.ts +1 -1
- package/lib/config.d.ts +2 -2
- package/lib/globalStyle.js +2 -2
- package/lib/hooks/useActiveHeading.d.ts +1 -1
- package/lib/hooks/useActiveSectionId.d.ts +1 -1
- package/lib/hooks/useActiveSectionId.js +0 -3
- package/lib/hooks/useControl.d.ts +1 -1
- package/lib/hooks/useNavbarHeight.d.ts +1 -1
- package/lib/mocks/types/index.d.ts +1 -1
- package/lib/mocks/types.d.ts +3 -3
- package/lib/types/config.d.ts +1 -1
- package/lib/ui/Burger.js +3 -2
- package/lib/ui/Dropdown.d.ts +1 -1
- package/lib/ui/Tiles/ThinTile.d.ts +1 -1
- package/lib/utils/jsonToHtml.d.ts +1 -1
- package/lib/utils/media-css.d.ts +1 -1
- package/package.json +6 -3
- package/src/Navbar/MobileNavbarMenu.tsx +14 -0
- package/src/Navbar/Navbar.tsx +9 -1
- package/src/Profile/Profile.tsx +5 -0
- package/src/Search/Autocomplete.tsx +1 -0
- package/src/Search/Popover.tsx +9 -1
- package/src/Search/Search.tsx +25 -15
- package/src/Sidebar/ArrowBack.tsx +2 -2
- package/src/Sidebar/SidebarLayout.tsx +1 -38
- package/src/globalStyle.ts +2 -2
- package/src/hooks/useActiveSectionId.ts +0 -2
- package/src/ui/Burger.tsx +3 -2
package/lib/Button/Button.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { FlattenSimpleInterpolation } from 'styled-components';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
export type ButtonSize = 'small' | 'medium' | 'large' | 'xlarge' | string;
|
|
4
|
+
export type ButtonColor = 'primary' | 'secondary' | 'default' | string;
|
|
5
|
+
export type ButtonVariant = 'outlined' | 'contained';
|
|
6
6
|
export interface ButtonProps {
|
|
7
7
|
color?: ButtonColor;
|
|
8
8
|
disabled?: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type { ResolvedConfigLinks } from '@theme/types/portal';
|
|
3
|
-
export declare function MobileNavbarMenu({ menuItems, closeMenu, }: {
|
|
3
|
+
export declare function MobileNavbarMenu({ menuItems, closeMenu, search, }: {
|
|
4
4
|
menuItems: ResolvedConfigLinks;
|
|
5
|
+
search: React.ReactNode | undefined;
|
|
5
6
|
closeMenu: () => void;
|
|
6
7
|
}): JSX.Element | null;
|
|
@@ -10,14 +10,16 @@ const NavbarItem_1 = require("../Navbar/NavbarItem");
|
|
|
10
10
|
const MobileNavbarItem_1 = require("../Navbar/MobileNavbarItem");
|
|
11
11
|
const NavbarDropdown_1 = require("../Navbar/NavbarDropdown");
|
|
12
12
|
const utils_1 = require("../utils");
|
|
13
|
-
function MobileNavbarMenu({ menuItems, closeMenu, }) {
|
|
13
|
+
function MobileNavbarMenu({ menuItems, closeMenu, search, }) {
|
|
14
14
|
if ((0, utils_1.isPrimitive)(menuItems) || (0, utils_1.isEmptyArray)(menuItems)) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
return (react_1.default.createElement(NavbarItemsWrapper, { "data-component-name": "Navbar/MobileNavbarMenu" },
|
|
18
|
-
react_1.default.createElement(NavbarItemsContainer, null,
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
react_1.default.createElement(NavbarItemsContainer, null,
|
|
19
|
+
react_1.default.createElement(MobileSearchWrapper, null, search || null),
|
|
20
|
+
menuItems.map((navItem, index) => {
|
|
21
|
+
return (react_1.default.createElement(MobileNavbarItem_1.MobileNavbarItem, { key: `${navItem.label}_${index}`, "data-cy": navItem.label, navItem: navItem }));
|
|
22
|
+
})),
|
|
21
23
|
react_1.default.createElement(NavbarItemsClosableArea, { onClick: closeMenu })));
|
|
22
24
|
}
|
|
23
25
|
exports.MobileNavbarMenu = MobileNavbarMenu;
|
|
@@ -89,4 +91,14 @@ const NavbarItemsContainer = styled_components_1.default.ul `
|
|
|
89
91
|
position: relative;
|
|
90
92
|
}
|
|
91
93
|
`;
|
|
94
|
+
const MobileSearchWrapper = styled_components_1.default.div `
|
|
95
|
+
padding: var(--navbar-item-padding-horizontal);
|
|
96
|
+
> div {
|
|
97
|
+
display: block;
|
|
98
|
+
width: 100%;
|
|
99
|
+
}
|
|
100
|
+
input {
|
|
101
|
+
width: 100%;
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
92
104
|
//# sourceMappingURL=MobileNavbarMenu.js.map
|
package/lib/Navbar/Navbar.js
CHANGED
|
@@ -23,7 +23,7 @@ function Navbar({ menu, logo, search, profile }) {
|
|
|
23
23
|
const closeMobileMenu = () => setIsOpen(false);
|
|
24
24
|
return (react_1.default.createElement(exports.NavbarContainer, { "data-component-name": "Navbar/Navbar" },
|
|
25
25
|
react_1.default.createElement(MobileNavbarMenuButton_1.MobileNavbarMenuButton, { onClick: openMobileMenu }),
|
|
26
|
-
isOpen && react_1.default.createElement(MobileNavbarMenu_1.MobileNavbarMenu, { closeMenu: closeMobileMenu, menuItems: menu }),
|
|
26
|
+
isOpen && (react_1.default.createElement(MobileNavbarMenu_1.MobileNavbarMenu, { closeMenu: closeMobileMenu, menuItems: menu, search: hideSearch ? null : search })),
|
|
27
27
|
react_1.default.createElement(exports.NavbarRow, null,
|
|
28
28
|
logo,
|
|
29
29
|
react_1.default.createElement(Navbar_1.NavbarMenu, { menuItems: menu }),
|
|
@@ -33,6 +33,8 @@ function Navbar({ menu, logo, search, profile }) {
|
|
|
33
33
|
}
|
|
34
34
|
exports.Navbar = Navbar;
|
|
35
35
|
exports.NavbarContainer = styled_components_1.default.nav `
|
|
36
|
+
--text-color: var(--navbar-text-color);
|
|
37
|
+
|
|
36
38
|
height: var(--navbar-height);
|
|
37
39
|
box-sizing: border-box;
|
|
38
40
|
display: flex;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { LogoConfig } from '@theme/types/portal';
|
|
3
|
-
export
|
|
3
|
+
export type NavbarLogoProps = {
|
|
4
4
|
logo: Pick<LogoConfig, 'image' | 'link' | 'altText'>;
|
|
5
5
|
};
|
|
6
6
|
export declare function NavbarLogo({ logo }: NavbarLogoProps): JSX.Element | null;
|
package/lib/Profile/Profile.js
CHANGED
|
@@ -51,6 +51,11 @@ const ProfileWrapper = styled_components_1.default.div `
|
|
|
51
51
|
`;
|
|
52
52
|
const StyledUserName = styled_components_1.default.span `
|
|
53
53
|
color: ${({ color }) => color || 'var(--navbar-text-color)'};
|
|
54
|
+
display: none;
|
|
55
|
+
|
|
56
|
+
${({ theme }) => { var _a; return (_a = theme.mediaQueries) === null || _a === void 0 ? void 0 : _a.medium; }} {
|
|
57
|
+
display: block;
|
|
58
|
+
}
|
|
54
59
|
`;
|
|
55
60
|
const AvatarWrapper = styled_components_1.default.div `
|
|
56
61
|
width: 40px;
|
|
@@ -48,6 +48,7 @@ function Autocomplete({ placeholder, value, items, change, select, renderItem, c
|
|
|
48
48
|
const stopPropagation = (event) => event.stopPropagation();
|
|
49
49
|
const onChange = (event) => {
|
|
50
50
|
setActiveIdx(-1);
|
|
51
|
+
setIsOpen(true);
|
|
51
52
|
change(event.target.value);
|
|
52
53
|
};
|
|
53
54
|
const onKeydown = (event) => {
|
package/lib/Search/Popover.js
CHANGED
|
@@ -13,7 +13,6 @@ exports.Popover = styled_components_1.default.div.attrs(() => ({
|
|
|
13
13
|
right: 0;
|
|
14
14
|
z-index: 100;
|
|
15
15
|
min-width: 100%;
|
|
16
|
-
width: 550px;
|
|
17
16
|
max-width: 90vw;
|
|
18
17
|
max-height: 400px;
|
|
19
18
|
overflow-y: auto;
|
|
@@ -22,5 +21,14 @@ exports.Popover = styled_components_1.default.div.attrs(() => ({
|
|
|
22
21
|
list-style: none;
|
|
23
22
|
border-radius: var(--search-popover-border-radius);
|
|
24
23
|
border: var(--search-popover-border);
|
|
24
|
+
width: 100%;
|
|
25
|
+
|
|
26
|
+
${({ theme }) => { var _a; return (_a = theme.mediaQueries) === null || _a === void 0 ? void 0 : _a.small; }} {
|
|
27
|
+
width: 400px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
${({ theme }) => { var _a; return (_a = theme.mediaQueries) === null || _a === void 0 ? void 0 : _a.medium; }} {
|
|
31
|
+
width: 550px;
|
|
32
|
+
}
|
|
25
33
|
`;
|
|
26
34
|
//# sourceMappingURL=Popover.js.map
|
package/lib/Search/Search.js
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.Search = void 0;
|
|
7
|
-
const
|
|
30
|
+
const React = __importStar(require("react"));
|
|
8
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
32
|
const usePreloadHistory_1 = require("../mocks/usePreloadHistory");
|
|
10
33
|
const search_1 = require("../mocks/search");
|
|
@@ -17,11 +40,21 @@ function Search() {
|
|
|
17
40
|
const { query, setQuery, items } = (0, search_1.useFuseSearch)();
|
|
18
41
|
// TODO: ask somebody about typings
|
|
19
42
|
const navigate = (item) => history.push(item.url);
|
|
20
|
-
|
|
21
|
-
|
|
43
|
+
const renderAutocomplete = () => (React.createElement(Autocomplete_1.Autocomplete, { items: items, value: query, change: setQuery, select: navigate, placeholder: "Search the docs", renderItem: (item) => React.createElement(SearchItem_1.SearchItem, { key: item.id, item: item }) }, (isOpen, reset) => (isOpen ? React.createElement(ClearIcon_1.ClearIcon, { onClick: reset }) : React.createElement(SearchIcon_1.SearchIcon, null))));
|
|
44
|
+
return React.createElement(Wrapper, { "data-component-name": "Search/Search" }, renderAutocomplete());
|
|
22
45
|
}
|
|
23
46
|
exports.Search = Search;
|
|
24
47
|
const Wrapper = styled_components_1.default.div `
|
|
25
|
-
margin:
|
|
48
|
+
margin-left: auto;
|
|
49
|
+
|
|
50
|
+
display: none;
|
|
51
|
+
|
|
52
|
+
${({ theme }) => { var _a; return (_a = theme.mediaQueries) === null || _a === void 0 ? void 0 : _a.small; }} {
|
|
53
|
+
display: block;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
${({ theme }) => { var _a; return (_a = theme.mediaQueries) === null || _a === void 0 ? void 0 : _a.medium; }} {
|
|
57
|
+
margin: 0 auto;
|
|
58
|
+
}
|
|
26
59
|
`;
|
|
27
60
|
//# sourceMappingURL=Search.js.map
|
package/lib/Sidebar/ArrowBack.js
CHANGED
|
@@ -7,12 +7,12 @@ exports.ArrowBack = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
9
|
const Arrow = ({ className }) => (react_1.default.createElement("span", { "data-component-name": "Sidebar/ArrowBack" },
|
|
10
|
-
react_1.default.createElement("svg", { fill: "none", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 10", width: "
|
|
10
|
+
react_1.default.createElement("svg", { fill: "none", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 10", width: "12px", height: "10px", className: className },
|
|
11
11
|
react_1.default.createElement("path", { d: "M2.414 5l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 1.414L2.414 5z" }),
|
|
12
12
|
react_1.default.createElement("path", { d: "M2 5a1 1 0 011-1h8a1 1 0 110 2H3a1 1 0 01-1-1z" }))));
|
|
13
13
|
exports.ArrowBack = (0, styled_components_1.default)(Arrow) `
|
|
14
14
|
fill: var(--sidebar-back-button-icon-color);
|
|
15
|
-
margin-right: calc(var(--sidebar-spacing-unit));
|
|
15
|
+
margin-right: calc(var(--sidebar-spacing-unit) * 1.5);
|
|
16
16
|
|
|
17
17
|
background-image: var(--sidebar-back-button-icon);
|
|
18
18
|
background-repeat: no-repeat;
|
|
@@ -2,10 +2,6 @@ import React from 'react';
|
|
|
2
2
|
interface SidebarLayoutProps {
|
|
3
3
|
versions: React.ReactNode;
|
|
4
4
|
menu: React.ReactNode;
|
|
5
|
-
backLink?: {
|
|
6
|
-
label: string;
|
|
7
|
-
slug: string;
|
|
8
|
-
};
|
|
9
5
|
}
|
|
10
|
-
export declare function SidebarLayout({ versions, menu
|
|
6
|
+
export declare function SidebarLayout({ versions, menu }: SidebarLayoutProps): JSX.Element | null;
|
|
11
7
|
export {};
|
|
@@ -12,9 +12,7 @@ const MobileSidebarButton_1 = require("../Sidebar/MobileSidebarButton");
|
|
|
12
12
|
const MenuContainer_1 = require("../Sidebar/MenuContainer");
|
|
13
13
|
const SidebarSearch_1 = require("../Search/SidebarSearch");
|
|
14
14
|
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
15
|
-
|
|
16
|
-
const Link_1 = require("../mocks/Link");
|
|
17
|
-
function SidebarLayout({ versions, menu, backLink, }) {
|
|
15
|
+
function SidebarLayout({ versions, menu }) {
|
|
18
16
|
const [isOpen, setIsOpen] = (0, useMobileMenu_1.useMobileMenu)();
|
|
19
17
|
const toggleMenu = () => setIsOpen(!isOpen);
|
|
20
18
|
const { search, sidebar } = (0, useThemeConfig_1.useThemeConfig)();
|
|
@@ -25,32 +23,9 @@ function SidebarLayout({ versions, menu, backLink, }) {
|
|
|
25
23
|
react_1.default.createElement(MobileSidebarButton_1.MobileSidebarButton, { opened: isOpen, onClick: toggleMenu }),
|
|
26
24
|
!(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
25
|
react_1.default.createElement(Sidebar_1.Sidebar, { animate: true, opened: isOpen },
|
|
28
|
-
(backLink && (react_1.default.createElement(BackLinkWrapper, null,
|
|
29
|
-
react_1.default.createElement(Link_1.Link, { to: backLink.slug },
|
|
30
|
-
react_1.default.createElement(ArrowBack_1.ArrowBack, null),
|
|
31
|
-
"Back to ",
|
|
32
|
-
backLink.label)))) ||
|
|
33
|
-
null,
|
|
34
26
|
versions,
|
|
35
27
|
react_1.default.createElement(MenuContainer_1.MenuContainer, null, menu))));
|
|
36
28
|
}
|
|
37
29
|
exports.SidebarLayout = SidebarLayout;
|
|
38
|
-
const BackLinkWrapper = styled_components_1.default.div `
|
|
39
|
-
padding: var(--sidebar-offset-top) var(--sidebar-item-padding-horizontal)
|
|
40
|
-
var(--sidebar-item-padding-horizontal)
|
|
41
|
-
calc(var(--sidebar-offset-left) + var(--sidebar-item-padding-horizontal));
|
|
42
|
-
|
|
43
|
-
a {
|
|
44
|
-
color: var(--sidebar-back-button-text-color);
|
|
45
|
-
font-size: var(--sidebar-back-button-font-size);
|
|
46
|
-
font-family: var(--sidebar-back-button-font-family);
|
|
47
|
-
text-decoration: none;
|
|
48
|
-
&:hover {
|
|
49
|
-
color: var(--sidebar-back-button-hover-text-color);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
border-bottom: 1px solid var(--sidebar-border-color);
|
|
54
|
-
`;
|
|
55
30
|
const Wrapper = styled_components_1.default.div ``;
|
|
56
31
|
//# sourceMappingURL=SidebarLayout.js.map
|
|
@@ -17,7 +17,7 @@ export interface Sample {
|
|
|
17
17
|
lang: string;
|
|
18
18
|
label?: string;
|
|
19
19
|
}
|
|
20
|
-
export
|
|
20
|
+
export type UnstableExternalCodeSample = Sample & {
|
|
21
21
|
get: (source: ExternalSource) => string;
|
|
22
22
|
};
|
|
23
23
|
export interface ExternalSource {
|
package/lib/config.d.ts
CHANGED
|
@@ -640,8 +640,8 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
|
|
|
640
640
|
openapi?: {} | undefined;
|
|
641
641
|
graphql?: {} | undefined;
|
|
642
642
|
}>>;
|
|
643
|
-
export
|
|
644
|
-
export
|
|
643
|
+
export type ThemeConfig = z.infer<typeof ThemeConfig>;
|
|
644
|
+
export type ThemeUIConfig = Omit<ThemeConfig, 'navbar' | 'footer' | 'links' | 'scripts'> & {
|
|
645
645
|
navbar?: any;
|
|
646
646
|
footer?: any;
|
|
647
647
|
auth?: {
|
package/lib/globalStyle.js
CHANGED
|
@@ -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:
|
|
205
|
+
--h2-margin-top: 0; // @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
|
|
|
@@ -512,7 +512,7 @@ const sidebar = (0, styled_components_1.css) `
|
|
|
512
512
|
--sidebar-back-button-font-family: var(--sidebar-item-font-family);
|
|
513
513
|
--sidebar-back-button-font-size: var(--sidebar-item-font-size);
|
|
514
514
|
--sidebar-back-button-transform: inherit;
|
|
515
|
-
--sidebar-back-button-text-color: var(--
|
|
515
|
+
--sidebar-back-button-text-color: var(--sidebar-item-text-color);
|
|
516
516
|
--sidebar-back-button-background-color: transparent;
|
|
517
517
|
--sidebar-back-button-hover-text-color: var(--sidebar-item-active-color);
|
|
518
518
|
--sidebar-back-button-hover-background-color: transparent;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type UseActiveHeadingReturnType = string | undefined;
|
|
2
2
|
export declare function useActiveHeading(contentElement: HTMLDivElement | null, displayedHeaders: Array<string | undefined>): UseActiveHeadingReturnType;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Location } from 'history';
|
|
2
|
-
export
|
|
2
|
+
export type UseActiveSectionIdReturnType = string;
|
|
3
3
|
export declare function useActiveSectionId(location: Location, hasOverviewPage?: boolean): UseActiveSectionIdReturnType;
|
|
@@ -28,9 +28,6 @@ function useActiveSectionId(location, hasOverviewPage = false) {
|
|
|
28
28
|
if (hasOverviewPage) {
|
|
29
29
|
setItemId('');
|
|
30
30
|
}
|
|
31
|
-
else {
|
|
32
|
-
setItemId((sections[0] && sections[0].getAttribute('data-section-id')) || '');
|
|
33
|
-
}
|
|
34
31
|
}, 150), [navbarHeight, hasOverviewPage]);
|
|
35
32
|
(0, react_1.useEffect)(() => {
|
|
36
33
|
window.addEventListener('scroll', scrollListener, { capture: false });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ResolvedNavLinkItem = any;
|
package/lib/mocks/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export type ActiveItem<T> = T;
|
|
2
|
+
export type SearchDocument = any;
|
|
3
|
+
export type OperationParameter = any;
|
package/lib/types/config.d.ts
CHANGED
package/lib/ui/Burger.js
CHANGED
|
@@ -14,7 +14,8 @@ function BurgerComponent({ onClick, className }) {
|
|
|
14
14
|
}
|
|
15
15
|
const Button = styled_components_1.default.button `
|
|
16
16
|
all: unset;
|
|
17
|
-
max-width:
|
|
17
|
+
max-width: 20px;
|
|
18
|
+
min-width: 20px;
|
|
18
19
|
width: 100%;
|
|
19
20
|
min-width: 10px;
|
|
20
21
|
display: block;
|
|
@@ -24,7 +25,7 @@ const Line = styled_components_1.default.div `
|
|
|
24
25
|
margin: 4px 0;
|
|
25
26
|
width: 100%;
|
|
26
27
|
height: 2px;
|
|
27
|
-
background:
|
|
28
|
+
background: var(--text-color);
|
|
28
29
|
border-radius: 1px;
|
|
29
30
|
`;
|
|
30
31
|
exports.Burger = (0, styled_components_1.default)(BurgerComponent) ``;
|
package/lib/ui/Dropdown.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import type { CSSProperties } from 'react';
|
|
3
|
-
|
|
3
|
+
type TextAlign = 'left' | 'right' | 'center' | 'justify';
|
|
4
4
|
export interface TileProps {
|
|
5
5
|
header?: string;
|
|
6
6
|
icon?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type JsonValue = JSON | Record<string, unknown>;
|
|
2
2
|
export declare function jsonToHTML(json: JsonValue, maxExpandLevel: number, startLine?: number): string;
|
|
3
3
|
export declare function getLines(json: JsonValue, maxExpandLevel: number): string;
|
|
4
4
|
export {};
|
package/lib/utils/media-css.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Shared UI components",
|
|
5
5
|
"author": "team@redocly.com",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"./config": "./lib/config.js",
|
|
13
13
|
".": "./lib/index.js",
|
|
14
14
|
"./Sidebar/*": "./lib/Sidebar/*.js",
|
|
15
|
-
"./*": "./lib
|
|
15
|
+
"./*": "./lib/index.js",
|
|
16
16
|
"./src/": "./src/"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
@@ -115,7 +115,10 @@
|
|
|
115
115
|
]
|
|
116
116
|
},
|
|
117
117
|
"test": {
|
|
118
|
-
"outputs": [
|
|
118
|
+
"outputs": [
|
|
119
|
+
"{projectRoot}/coverage",
|
|
120
|
+
"{projectRoot}/report.json"
|
|
121
|
+
]
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
}
|
|
@@ -10,8 +10,10 @@ import type { ResolvedConfigLinks, ResolvedNavItem } from '@theme/types/portal';
|
|
|
10
10
|
export function MobileNavbarMenu({
|
|
11
11
|
menuItems,
|
|
12
12
|
closeMenu,
|
|
13
|
+
search,
|
|
13
14
|
}: {
|
|
14
15
|
menuItems: ResolvedConfigLinks;
|
|
16
|
+
search: React.ReactNode | undefined;
|
|
15
17
|
closeMenu: () => void;
|
|
16
18
|
}): JSX.Element | null {
|
|
17
19
|
if (isPrimitive(menuItems) || isEmptyArray(menuItems)) {
|
|
@@ -21,6 +23,7 @@ export function MobileNavbarMenu({
|
|
|
21
23
|
return (
|
|
22
24
|
<NavbarItemsWrapper data-component-name="Navbar/MobileNavbarMenu">
|
|
23
25
|
<NavbarItemsContainer>
|
|
26
|
+
<MobileSearchWrapper>{search || null}</MobileSearchWrapper>
|
|
24
27
|
{(menuItems as ResolvedNavItem[]).map((navItem, index) => {
|
|
25
28
|
return (
|
|
26
29
|
<MobileNavbarItem
|
|
@@ -106,3 +109,14 @@ const NavbarItemsContainer = styled.ul`
|
|
|
106
109
|
position: relative;
|
|
107
110
|
}
|
|
108
111
|
`;
|
|
112
|
+
|
|
113
|
+
const MobileSearchWrapper = styled.div`
|
|
114
|
+
padding: var(--navbar-item-padding-horizontal);
|
|
115
|
+
> div {
|
|
116
|
+
display: block;
|
|
117
|
+
width: 100%;
|
|
118
|
+
}
|
|
119
|
+
input {
|
|
120
|
+
width: 100%;
|
|
121
|
+
}
|
|
122
|
+
`;
|
package/src/Navbar/Navbar.tsx
CHANGED
|
@@ -32,7 +32,13 @@ export function Navbar({ menu, logo, search, profile }: NavbarProps): JSX.Elemen
|
|
|
32
32
|
return (
|
|
33
33
|
<NavbarContainer data-component-name="Navbar/Navbar">
|
|
34
34
|
<MobileNavbarMenuButton onClick={openMobileMenu} />
|
|
35
|
-
{isOpen &&
|
|
35
|
+
{isOpen && (
|
|
36
|
+
<MobileNavbarMenu
|
|
37
|
+
closeMenu={closeMobileMenu}
|
|
38
|
+
menuItems={menu}
|
|
39
|
+
search={hideSearch ? null : search}
|
|
40
|
+
/>
|
|
41
|
+
)}
|
|
36
42
|
<NavbarRow>
|
|
37
43
|
{logo}
|
|
38
44
|
<NavbarMenu menuItems={menu} />
|
|
@@ -45,6 +51,8 @@ export function Navbar({ menu, logo, search, profile }: NavbarProps): JSX.Elemen
|
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
export const NavbarContainer = styled.nav`
|
|
54
|
+
--text-color: var(--navbar-text-color);
|
|
55
|
+
|
|
48
56
|
height: var(--navbar-height);
|
|
49
57
|
box-sizing: border-box;
|
|
50
58
|
display: flex;
|
package/src/Profile/Profile.tsx
CHANGED
|
@@ -54,6 +54,11 @@ const ProfileWrapper = styled.div`
|
|
|
54
54
|
|
|
55
55
|
const StyledUserName = styled.span`
|
|
56
56
|
color: ${({ color }) => color || 'var(--navbar-text-color)'};
|
|
57
|
+
display: none;
|
|
58
|
+
|
|
59
|
+
${({ theme }) => theme.mediaQueries?.medium} {
|
|
60
|
+
display: block;
|
|
61
|
+
}
|
|
57
62
|
`;
|
|
58
63
|
|
|
59
64
|
const AvatarWrapper = styled.div<{ background?: string }>`
|
package/src/Search/Popover.tsx
CHANGED
|
@@ -8,7 +8,6 @@ export const Popover = styled.div.attrs(() => ({
|
|
|
8
8
|
right: 0;
|
|
9
9
|
z-index: 100;
|
|
10
10
|
min-width: 100%;
|
|
11
|
-
width: 550px;
|
|
12
11
|
max-width: 90vw;
|
|
13
12
|
max-height: 400px;
|
|
14
13
|
overflow-y: auto;
|
|
@@ -17,4 +16,13 @@ export const Popover = styled.div.attrs(() => ({
|
|
|
17
16
|
list-style: none;
|
|
18
17
|
border-radius: var(--search-popover-border-radius);
|
|
19
18
|
border: var(--search-popover-border);
|
|
19
|
+
width: 100%;
|
|
20
|
+
|
|
21
|
+
${({ theme }) => theme.mediaQueries?.small} {
|
|
22
|
+
width: 400px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
${({ theme }) => theme.mediaQueries?.medium} {
|
|
26
|
+
width: 550px;
|
|
27
|
+
}
|
|
20
28
|
`;
|
package/src/Search/Search.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
4
|
import { usePreloadHistory } from '@portal/usePreloadHistory';
|
|
@@ -33,22 +33,32 @@ export function Search(): JSX.Element {
|
|
|
33
33
|
// TODO: ask somebody about typings
|
|
34
34
|
const navigate = (item: SearchDocument) => history.push(item.url);
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
</Autocomplete>
|
|
48
|
-
</Wrapper>
|
|
36
|
+
const renderAutocomplete = () => (
|
|
37
|
+
<Autocomplete
|
|
38
|
+
items={items}
|
|
39
|
+
value={query}
|
|
40
|
+
change={setQuery}
|
|
41
|
+
select={navigate}
|
|
42
|
+
placeholder="Search the docs"
|
|
43
|
+
renderItem={(item) => <SearchItem key={item.id} item={item} />}
|
|
44
|
+
>
|
|
45
|
+
{(isOpen, reset) => (isOpen ? <ClearIcon onClick={reset} /> : <SearchIcon />)}
|
|
46
|
+
</Autocomplete>
|
|
49
47
|
);
|
|
48
|
+
|
|
49
|
+
return <Wrapper data-component-name="Search/Search">{renderAutocomplete()}</Wrapper>;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const Wrapper = styled.div`
|
|
53
|
-
margin:
|
|
53
|
+
margin-left: auto;
|
|
54
|
+
|
|
55
|
+
display: none;
|
|
56
|
+
|
|
57
|
+
${({ theme }) => theme.mediaQueries?.small} {
|
|
58
|
+
display: block;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
${({ theme }) => theme.mediaQueries?.medium} {
|
|
62
|
+
margin: 0 auto;
|
|
63
|
+
}
|
|
54
64
|
`;
|
|
@@ -7,7 +7,7 @@ const Arrow = ({ className }: { className?: string }): JSX.Element => (
|
|
|
7
7
|
fill="none"
|
|
8
8
|
xmlns="http://www.w3.org/2000/svg"
|
|
9
9
|
viewBox="0 0 12 10"
|
|
10
|
-
width="
|
|
10
|
+
width="12px"
|
|
11
11
|
height="10px"
|
|
12
12
|
className={className}
|
|
13
13
|
>
|
|
@@ -19,7 +19,7 @@ const Arrow = ({ className }: { className?: string }): JSX.Element => (
|
|
|
19
19
|
|
|
20
20
|
export const ArrowBack = styled(Arrow)`
|
|
21
21
|
fill: var(--sidebar-back-button-icon-color);
|
|
22
|
-
margin-right: calc(var(--sidebar-spacing-unit));
|
|
22
|
+
margin-right: calc(var(--sidebar-spacing-unit) * 1.5);
|
|
23
23
|
|
|
24
24
|
background-image: var(--sidebar-back-button-icon);
|
|
25
25
|
background-repeat: no-repeat;
|
|
@@ -7,23 +7,13 @@ import { MobileSidebarButton } from '@theme/Sidebar/MobileSidebarButton';
|
|
|
7
7
|
import { MenuContainer } from '@theme/Sidebar/MenuContainer';
|
|
8
8
|
import { SidebarSearch } from '@theme/Search/SidebarSearch';
|
|
9
9
|
import { useThemeConfig } from '@theme/hooks/useThemeConfig';
|
|
10
|
-
import { ArrowBack } from '@theme/Sidebar/ArrowBack';
|
|
11
|
-
import { Link } from '@portal/Link';
|
|
12
10
|
|
|
13
11
|
interface SidebarLayoutProps {
|
|
14
12
|
versions: React.ReactNode;
|
|
15
13
|
menu: React.ReactNode;
|
|
16
|
-
backLink?: {
|
|
17
|
-
label: string;
|
|
18
|
-
slug: string;
|
|
19
|
-
};
|
|
20
14
|
}
|
|
21
15
|
|
|
22
|
-
export function SidebarLayout({
|
|
23
|
-
versions,
|
|
24
|
-
menu,
|
|
25
|
-
backLink,
|
|
26
|
-
}: SidebarLayoutProps): JSX.Element | null {
|
|
16
|
+
export function SidebarLayout({ versions, menu }: SidebarLayoutProps): JSX.Element | null {
|
|
27
17
|
const [isOpen, setIsOpen] = useMobileMenu();
|
|
28
18
|
const toggleMenu = () => setIsOpen(!isOpen);
|
|
29
19
|
const { search, sidebar } = useThemeConfig();
|
|
@@ -38,15 +28,6 @@ export function SidebarLayout({
|
|
|
38
28
|
|
|
39
29
|
{!search?.hide && search?.placement === 'sidebar' ? <SidebarSearch /> : null}
|
|
40
30
|
<Sidebar animate={true} opened={isOpen}>
|
|
41
|
-
{(backLink && (
|
|
42
|
-
<BackLinkWrapper>
|
|
43
|
-
<Link to={backLink.slug}>
|
|
44
|
-
<ArrowBack />
|
|
45
|
-
Back to {backLink.label}
|
|
46
|
-
</Link>
|
|
47
|
-
</BackLinkWrapper>
|
|
48
|
-
)) ||
|
|
49
|
-
null}
|
|
50
31
|
{versions}
|
|
51
32
|
<MenuContainer>{menu}</MenuContainer>
|
|
52
33
|
</Sidebar>
|
|
@@ -54,22 +35,4 @@ export function SidebarLayout({
|
|
|
54
35
|
);
|
|
55
36
|
}
|
|
56
37
|
|
|
57
|
-
const BackLinkWrapper = styled.div`
|
|
58
|
-
padding: var(--sidebar-offset-top) var(--sidebar-item-padding-horizontal)
|
|
59
|
-
var(--sidebar-item-padding-horizontal)
|
|
60
|
-
calc(var(--sidebar-offset-left) + var(--sidebar-item-padding-horizontal));
|
|
61
|
-
|
|
62
|
-
a {
|
|
63
|
-
color: var(--sidebar-back-button-text-color);
|
|
64
|
-
font-size: var(--sidebar-back-button-font-size);
|
|
65
|
-
font-family: var(--sidebar-back-button-font-family);
|
|
66
|
-
text-decoration: none;
|
|
67
|
-
&:hover {
|
|
68
|
-
color: var(--sidebar-back-button-hover-text-color);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
border-bottom: 1px solid var(--sidebar-border-color);
|
|
73
|
-
`;
|
|
74
|
-
|
|
75
38
|
const Wrapper = styled.div``;
|
package/src/globalStyle.ts
CHANGED
|
@@ -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:
|
|
207
|
+
--h2-margin-top: 0; // @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
|
|
|
@@ -517,7 +517,7 @@ const sidebar = css`
|
|
|
517
517
|
--sidebar-back-button-font-family: var(--sidebar-item-font-family);
|
|
518
518
|
--sidebar-back-button-font-size: var(--sidebar-item-font-size);
|
|
519
519
|
--sidebar-back-button-transform: inherit;
|
|
520
|
-
--sidebar-back-button-text-color: var(--
|
|
520
|
+
--sidebar-back-button-text-color: var(--sidebar-item-text-color);
|
|
521
521
|
--sidebar-back-button-background-color: transparent;
|
|
522
522
|
--sidebar-back-button-hover-text-color: var(--sidebar-item-active-color);
|
|
523
523
|
--sidebar-back-button-hover-background-color: transparent;
|
package/src/ui/Burger.tsx
CHANGED
|
@@ -20,7 +20,8 @@ function BurgerComponent({ onClick, className }: BurgerProps): JSX.Element {
|
|
|
20
20
|
|
|
21
21
|
const Button = styled.button`
|
|
22
22
|
all: unset;
|
|
23
|
-
max-width:
|
|
23
|
+
max-width: 20px;
|
|
24
|
+
min-width: 20px;
|
|
24
25
|
width: 100%;
|
|
25
26
|
min-width: 10px;
|
|
26
27
|
display: block;
|
|
@@ -31,7 +32,7 @@ const Line = styled.div`
|
|
|
31
32
|
margin: 4px 0;
|
|
32
33
|
width: 100%;
|
|
33
34
|
height: 2px;
|
|
34
|
-
background:
|
|
35
|
+
background: var(--text-color);
|
|
35
36
|
border-radius: 1px;
|
|
36
37
|
`;
|
|
37
38
|
|