@redocly/theme 0.6.2-beta.3 → 0.6.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Navbar/MobileNavbarMenu.d.ts +3 -2
- package/lib/Navbar/MobileNavbarMenu.js +16 -4
- package/lib/Navbar/Navbar.js +3 -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/ui/Burger.js +3 -2
- package/package.json +5 -2
- 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/ui/Burger.tsx +3 -2
|
@@ -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;
|
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/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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3-beta.1",
|
|
4
4
|
"description": "Shared UI components",
|
|
5
5
|
"author": "team@redocly.com",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -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
|
`;
|
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
|
|