@redocly/theme 0.6.2 → 0.6.3
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/Sidebar/ArrowBack.js +2 -2
- package/lib/Sidebar/SidebarLayout.d.ts +5 -1
- package/lib/Sidebar/SidebarLayout.js +26 -1
- package/lib/globalStyle.js +1 -1
- package/package.json +1 -1
- package/src/Sidebar/ArrowBack.tsx +2 -2
- package/src/Sidebar/SidebarLayout.tsx +38 -1
- package/src/globalStyle.ts +1 -1
- package/src/types/portal/src/shared/types/nav.d.ts +1 -1
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: "10px", 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));
|
|
16
16
|
|
|
17
17
|
background-image: var(--sidebar-back-button-icon);
|
|
18
18
|
background-repeat: no-repeat;
|
|
@@ -2,6 +2,10 @@ 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
|
+
};
|
|
5
9
|
}
|
|
6
|
-
export declare function SidebarLayout({ versions, menu }: SidebarLayoutProps): JSX.Element | null;
|
|
10
|
+
export declare function SidebarLayout({ versions, menu, backLink, }: SidebarLayoutProps): JSX.Element | null;
|
|
7
11
|
export {};
|
|
@@ -12,7 +12,9 @@ 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
|
-
|
|
15
|
+
const ArrowBack_1 = require("../Sidebar/ArrowBack");
|
|
16
|
+
const Link_1 = require("../mocks/Link");
|
|
17
|
+
function SidebarLayout({ versions, menu, backLink, }) {
|
|
16
18
|
const [isOpen, setIsOpen] = (0, useMobileMenu_1.useMobileMenu)();
|
|
17
19
|
const toggleMenu = () => setIsOpen(!isOpen);
|
|
18
20
|
const { search, sidebar } = (0, useThemeConfig_1.useThemeConfig)();
|
|
@@ -23,9 +25,32 @@ function SidebarLayout({ versions, menu }) {
|
|
|
23
25
|
react_1.default.createElement(MobileSidebarButton_1.MobileSidebarButton, { opened: isOpen, onClick: toggleMenu }),
|
|
24
26
|
!(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,
|
|
25
27
|
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,
|
|
26
34
|
versions,
|
|
27
35
|
react_1.default.createElement(MenuContainer_1.MenuContainer, null, menu))));
|
|
28
36
|
}
|
|
29
37
|
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
|
+
`;
|
|
30
55
|
const Wrapper = styled_components_1.default.div ``;
|
|
31
56
|
//# sourceMappingURL=SidebarLayout.js.map
|
package/lib/globalStyle.js
CHANGED
|
@@ -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(--link-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;
|
package/package.json
CHANGED
|
@@ -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="10px"
|
|
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));
|
|
23
23
|
|
|
24
24
|
background-image: var(--sidebar-back-button-icon);
|
|
25
25
|
background-repeat: no-repeat;
|
|
@@ -7,13 +7,23 @@ 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';
|
|
10
12
|
|
|
11
13
|
interface SidebarLayoutProps {
|
|
12
14
|
versions: React.ReactNode;
|
|
13
15
|
menu: React.ReactNode;
|
|
16
|
+
backLink?: {
|
|
17
|
+
label: string;
|
|
18
|
+
slug: string;
|
|
19
|
+
};
|
|
14
20
|
}
|
|
15
21
|
|
|
16
|
-
export function SidebarLayout({
|
|
22
|
+
export function SidebarLayout({
|
|
23
|
+
versions,
|
|
24
|
+
menu,
|
|
25
|
+
backLink,
|
|
26
|
+
}: SidebarLayoutProps): JSX.Element | null {
|
|
17
27
|
const [isOpen, setIsOpen] = useMobileMenu();
|
|
18
28
|
const toggleMenu = () => setIsOpen(!isOpen);
|
|
19
29
|
const { search, sidebar } = useThemeConfig();
|
|
@@ -28,6 +38,15 @@ export function SidebarLayout({ versions, menu }: SidebarLayoutProps): JSX.Eleme
|
|
|
28
38
|
|
|
29
39
|
{!search?.hide && search?.placement === 'sidebar' ? <SidebarSearch /> : null}
|
|
30
40
|
<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}
|
|
31
50
|
{versions}
|
|
32
51
|
<MenuContainer>{menu}</MenuContainer>
|
|
33
52
|
</Sidebar>
|
|
@@ -35,4 +54,22 @@ export function SidebarLayout({ versions, menu }: SidebarLayoutProps): JSX.Eleme
|
|
|
35
54
|
);
|
|
36
55
|
}
|
|
37
56
|
|
|
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
|
+
|
|
38
75
|
const Wrapper = styled.div``;
|
package/src/globalStyle.ts
CHANGED
|
@@ -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(--link-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;
|