@redocly/theme 0.7.5 → 0.9.0-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/Sidebar/MenuGroup.js +1 -1
- package/lib/Sidebar/MenuItemLabel.js +2 -2
- package/lib/Sidebar/Sidebar.d.ts +1 -0
- package/lib/Sidebar/Sidebar.js +5 -2
- package/lib/Sidebar/SidebarLayout.d.ts +3 -1
- package/lib/Sidebar/SidebarLayout.js +14 -3
- package/lib/TableOfContent/TableOfContent.js +1 -1
- package/lib/globalStyle.js +8 -1
- package/lib/hooks/useActiveHeading.js +2 -7
- package/lib/hooks/useActiveSectionId.js +1 -1
- package/lib/hooks/useMobileMenu.js +1 -1
- package/lib/ui/Jumbotron.js +2 -2
- package/package.json +3 -7
- package/src/Sidebar/MenuGroup.tsx +1 -1
- package/src/Sidebar/MenuItemLabel.tsx +2 -2
- package/src/Sidebar/Sidebar.tsx +6 -2
- package/src/Sidebar/SidebarLayout.tsx +18 -1
- package/src/TableOfContent/TableOfContent.tsx +1 -1
- package/src/globalStyle.ts +8 -1
- package/src/hooks/useActiveHeading.ts +3 -12
- package/src/hooks/useActiveSectionId.ts +1 -1
- package/src/hooks/useMobileMenu.ts +2 -2
- package/src/types/portal/src/shared/types/nav.d.ts +1 -1
- package/src/ui/Jumbotron.tsx +2 -2
package/lib/Sidebar/MenuGroup.js
CHANGED
|
@@ -64,7 +64,7 @@ const MenuWrapper = styled_components_1.default.div `
|
|
|
64
64
|
padding-left: var(--sidebar-item-nested-offset);
|
|
65
65
|
overflow: hidden;
|
|
66
66
|
${(props) => props.isExpanded
|
|
67
|
-
? `max-height:
|
|
67
|
+
? `max-height: 99999px;
|
|
68
68
|
transition: max-height .8s cubic-bezier(0.5, 0, 1, 0) 0s;`
|
|
69
69
|
: `max-height: 0px;
|
|
70
70
|
transition: max-height .8s cubic-bezier(0, 1, 0, 1) -.1s;`};
|
|
@@ -35,8 +35,8 @@ exports.MenuItemLabel = styled_components_1.default.li.attrs(() => ({
|
|
|
35
35
|
: null};
|
|
36
36
|
|
|
37
37
|
:hover {
|
|
38
|
-
color: var(--sidebar-item-
|
|
39
|
-
background-color: var(--sidebar-item-
|
|
38
|
+
color: var(--sidebar-item-hover-color);
|
|
39
|
+
background-color: var(--sidebar-item-hover-background-color);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
:empty {
|
package/lib/Sidebar/Sidebar.d.ts
CHANGED
package/lib/Sidebar/Sidebar.js
CHANGED
|
@@ -18,13 +18,16 @@ exports.Sidebar = styled_components_1.default.aside.attrs(() => ({
|
|
|
18
18
|
font-size: var(--sidebar-item-font-size);
|
|
19
19
|
font-family: var(--sidebar-item-font-family);
|
|
20
20
|
color: var(--sidebar-item-text-color);
|
|
21
|
-
top: var(--navbar-height);
|
|
22
|
-
height: calc(100vh - var(--navbar-height));
|
|
23
21
|
display: flex;
|
|
24
22
|
flex-direction: column;
|
|
25
23
|
width: 100%;
|
|
26
24
|
-webkit-font-smoothing: antialiased;
|
|
27
25
|
|
|
26
|
+
${({ hasNavbar }) => `
|
|
27
|
+
top: ${hasNavbar ? 'var(--navbar-height)' : '0'};
|
|
28
|
+
height: calc(100vh ${hasNavbar ? '- var(--navbar-height)' : ''});
|
|
29
|
+
`};
|
|
30
|
+
|
|
28
31
|
${({ opened, animate }) => `
|
|
29
32
|
opacity: ${opened ? '1' : '0'};
|
|
30
33
|
pointer-events: ${opened ? 'auto' : 'none'};
|
|
@@ -6,6 +6,8 @@ interface SidebarLayoutProps {
|
|
|
6
6
|
label: string;
|
|
7
7
|
slug: string;
|
|
8
8
|
};
|
|
9
|
+
footer?: React.ReactNode;
|
|
10
|
+
hasNavbar: boolean;
|
|
9
11
|
}
|
|
10
|
-
export declare function SidebarLayout({ versions, menu, backLink, }: SidebarLayoutProps): JSX.Element | null;
|
|
12
|
+
export declare function SidebarLayout({ versions, menu, backLink, footer, hasNavbar, }: SidebarLayoutProps): JSX.Element | null;
|
|
11
13
|
export {};
|
|
@@ -14,7 +14,8 @@ const SidebarSearch_1 = require("../Search/SidebarSearch");
|
|
|
14
14
|
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
15
15
|
const ArrowBack_1 = require("../Sidebar/ArrowBack");
|
|
16
16
|
const Link_1 = require("../mocks/Link");
|
|
17
|
-
|
|
17
|
+
const Button_1 = require("../Button/Button");
|
|
18
|
+
function SidebarLayout({ versions, menu, backLink, footer, hasNavbar, }) {
|
|
18
19
|
const [isOpen, setIsOpen] = (0, useMobileMenu_1.useMobileMenu)();
|
|
19
20
|
const toggleMenu = () => setIsOpen(!isOpen);
|
|
20
21
|
const { search, sidebar } = (0, useThemeConfig_1.useThemeConfig)();
|
|
@@ -24,7 +25,7 @@ function SidebarLayout({ versions, menu, backLink, }) {
|
|
|
24
25
|
return (react_1.default.createElement(Wrapper, { "data-component-name": "Sidebar/SidebarLayout" },
|
|
25
26
|
react_1.default.createElement(MobileSidebarButton_1.MobileSidebarButton, { opened: isOpen, onClick: toggleMenu }),
|
|
26
27
|
!(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
|
-
react_1.default.createElement(Sidebar_1.Sidebar, { animate: true, opened: isOpen },
|
|
28
|
+
react_1.default.createElement(Sidebar_1.Sidebar, { animate: true, opened: isOpen, hasNavbar: hasNavbar },
|
|
28
29
|
(backLink && (react_1.default.createElement(BackLinkWrapper, null,
|
|
29
30
|
react_1.default.createElement(Link_1.Link, { to: backLink.slug },
|
|
30
31
|
react_1.default.createElement(ArrowBack_1.ArrowBack, null),
|
|
@@ -32,9 +33,19 @@ function SidebarLayout({ versions, menu, backLink, }) {
|
|
|
32
33
|
backLink.label)))) ||
|
|
33
34
|
null,
|
|
34
35
|
versions,
|
|
35
|
-
react_1.default.createElement(MenuContainer_1.MenuContainer, null, menu)
|
|
36
|
+
react_1.default.createElement(MenuContainer_1.MenuContainer, null, menu),
|
|
37
|
+
footer ? react_1.default.createElement(FooterWrapper, null, footer) : null)));
|
|
36
38
|
}
|
|
37
39
|
exports.SidebarLayout = SidebarLayout;
|
|
40
|
+
const FooterWrapper = styled_components_1.default.div `
|
|
41
|
+
padding: var(--sidebar-offset-top) var(--sidebar-item-padding-horizontal)
|
|
42
|
+
var(--sidebar-item-padding-horizontal) var(--sidebar-offset-left);
|
|
43
|
+
|
|
44
|
+
${Button_1.Button} {
|
|
45
|
+
width: 100%;
|
|
46
|
+
margin: 0;
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
38
49
|
const BackLinkWrapper = styled_components_1.default.div `
|
|
39
50
|
padding: var(--sidebar-offset-top) var(--sidebar-item-padding-horizontal)
|
|
40
51
|
var(--sidebar-item-padding-horizontal)
|
|
@@ -104,6 +104,6 @@ const TableOfContentItems = styled_components_1.default.div `
|
|
|
104
104
|
max-height: calc(100vh - var(--navbar-height) - var(--toc-offset-top));
|
|
105
105
|
border-left: 1px solid var(--toc-border-color);
|
|
106
106
|
overflow-y: auto;
|
|
107
|
-
width: var(--toc-width);
|
|
107
|
+
width: var(--toc-width);
|
|
108
108
|
`;
|
|
109
109
|
//# sourceMappingURL=TableOfContent.js.map
|
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: var(--heading-margin-top); // @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
|
|
|
@@ -1980,10 +1980,17 @@ exports.styles = (0, styled_components_1.css) `
|
|
|
1980
1980
|
${apiLogsTable}
|
|
1981
1981
|
${pages}
|
|
1982
1982
|
${modal}
|
|
1983
|
+
|
|
1984
|
+
--api-onboarding-table-text-color: #4e5356;
|
|
1985
|
+
|
|
1986
|
+
background-color: var(--background-color);
|
|
1987
|
+
color: var(--text-color);
|
|
1983
1988
|
}
|
|
1984
1989
|
|
|
1985
1990
|
:root.dark {
|
|
1986
1991
|
${darkColors_1.darkMode};
|
|
1992
|
+
|
|
1993
|
+
--api-onboarding-table-text-color: #ffffff;
|
|
1987
1994
|
}
|
|
1988
1995
|
|
|
1989
1996
|
:root.notransition * {
|
|
@@ -7,7 +7,7 @@ function useActiveHeading(contentElement, displayedHeaders) {
|
|
|
7
7
|
const [heading, setHeading] = (0, react_1.useState)(displayedHeaders.length > 1 ? displayedHeaders[0] : undefined);
|
|
8
8
|
const [headingElements, setHeadingElements] = (0, react_1.useState)([]);
|
|
9
9
|
const headingElementsRef = (0, react_1.useRef)({});
|
|
10
|
-
const
|
|
10
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
11
11
|
const getVisibleHeadings = () => {
|
|
12
12
|
const visibleHeadings = [];
|
|
13
13
|
for (const key in headingElementsRef.current) {
|
|
@@ -56,12 +56,7 @@ function useActiveHeading(contentElement, displayedHeaders) {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
setHeadingElements(findHeaders(contentElement));
|
|
59
|
-
|
|
60
|
-
setHeadingElements(findHeaders(contentElement));
|
|
61
|
-
});
|
|
62
|
-
return () => unlisten();
|
|
63
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
-
}, [contentElement]);
|
|
59
|
+
}, [contentElement, location]);
|
|
65
60
|
(0, react_1.useEffect)(() => {
|
|
66
61
|
if (!(headingElements === null || headingElements === void 0 ? void 0 : headingElements.length)) {
|
|
67
62
|
return;
|
|
@@ -33,7 +33,7 @@ function useActiveSectionId(location, hasOverviewPage = false) {
|
|
|
33
33
|
window.addEventListener('scroll', scrollListener, { capture: false });
|
|
34
34
|
setTimeout(() => {
|
|
35
35
|
scrollListener();
|
|
36
|
-
},
|
|
36
|
+
}, 10);
|
|
37
37
|
return () => {
|
|
38
38
|
window.removeEventListener('scroll', scrollListener);
|
|
39
39
|
};
|
|
@@ -4,7 +4,7 @@ exports.useMobileMenu = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
6
|
function useMobileMenu(initialState = false) {
|
|
7
|
-
const
|
|
7
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
8
8
|
const [isOpen, setIsOpen] = (0, react_1.useState)(initialState);
|
|
9
9
|
(0, react_1.useEffect)(() => setIsOpen(false), [location.pathname]);
|
|
10
10
|
return [isOpen, setIsOpen];
|
package/lib/ui/Jumbotron.js
CHANGED
|
@@ -14,8 +14,8 @@ exports.Jumbotron = (0, styled_components_1.default)(Background_1.Background).at
|
|
|
14
14
|
flex-direction: column;
|
|
15
15
|
padding-top: ${({ pt }) => pt || '0'};
|
|
16
16
|
padding-bottom: ${({ pb }) => pb || '8em'};
|
|
17
|
-
padding-left: ${({ pl }) => pl || '
|
|
18
|
-
padding-right: ${({ pr }) => pr || '
|
|
17
|
+
padding-left: ${({ pl }) => pl || '1rem'};
|
|
18
|
+
padding-right: ${({ pr }) => pr || '1rem'};
|
|
19
19
|
${({ bgColor }) => bgColor && `background: ${bgColor}`};
|
|
20
20
|
${({ bgImage, bgColor }) => bgImage &&
|
|
21
21
|
`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-beta.1",
|
|
4
4
|
"description": "Shared UI components lib",
|
|
5
5
|
"author": "team@redocly.com",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -39,8 +39,7 @@
|
|
|
39
39
|
"prismjs": "^1.28.0",
|
|
40
40
|
"react": "^17.0.2",
|
|
41
41
|
"react-dom": "^17.0.2",
|
|
42
|
-
"react-router": "^
|
|
43
|
-
"react-router-dom": "^5.3.0",
|
|
42
|
+
"react-router-dom": "^6.4.4",
|
|
44
43
|
"styled-components": "^5.3.6",
|
|
45
44
|
"styled-system": "^5.1.5",
|
|
46
45
|
"zod": ">=3.19.1"
|
|
@@ -71,8 +70,6 @@
|
|
|
71
70
|
"@types/prismjs": "^1.26.0",
|
|
72
71
|
"@types/react": "^17.0.43",
|
|
73
72
|
"@types/react-dom": "^17.0.14",
|
|
74
|
-
"@types/react-router-dom": "^5.3.3",
|
|
75
|
-
"@types/react-router": "^5.1.20",
|
|
76
73
|
"@types/styled-components": "^5.1.26",
|
|
77
74
|
"@types/styled-system": "^5.1.13",
|
|
78
75
|
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
|
@@ -87,8 +84,7 @@
|
|
|
87
84
|
"lodash.throttle": "^4.1.1",
|
|
88
85
|
"npm-run-all": "^4.1.5",
|
|
89
86
|
"react-refresh": "^0.14.0",
|
|
90
|
-
"react-router": "^
|
|
91
|
-
"react-router-dom": "^5.3.0",
|
|
87
|
+
"react-router-dom": "^6.4.4",
|
|
92
88
|
"storybook-addon-pseudo-states": "^1.15.1",
|
|
93
89
|
"storybook-design-token": "^2.7.1",
|
|
94
90
|
"styled-components": "^5.3.6",
|
|
@@ -62,7 +62,7 @@ const MenuWrapper = styled.div<{ isExpanded?: boolean }>`
|
|
|
62
62
|
overflow: hidden;
|
|
63
63
|
${(props) =>
|
|
64
64
|
props.isExpanded
|
|
65
|
-
? `max-height:
|
|
65
|
+
? `max-height: 99999px;
|
|
66
66
|
transition: max-height .8s cubic-bezier(0.5, 0, 1, 0) 0s;`
|
|
67
67
|
: `max-height: 0px;
|
|
68
68
|
transition: max-height .8s cubic-bezier(0, 1, 0, 1) -.1s;`};
|
|
@@ -31,8 +31,8 @@ export const MenuItemLabel = styled.li.attrs(() => ({
|
|
|
31
31
|
: null};
|
|
32
32
|
|
|
33
33
|
:hover {
|
|
34
|
-
color: var(--sidebar-item-
|
|
35
|
-
background-color: var(--sidebar-item-
|
|
34
|
+
color: var(--sidebar-item-hover-color);
|
|
35
|
+
background-color: var(--sidebar-item-hover-background-color);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
:empty {
|
package/src/Sidebar/Sidebar.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
|
|
3
3
|
interface SidebarProps {
|
|
4
|
+
hasNavbar: boolean;
|
|
4
5
|
opened?: boolean;
|
|
5
6
|
animate?: boolean;
|
|
6
7
|
}
|
|
@@ -18,13 +19,16 @@ export const Sidebar = styled.aside.attrs(() => ({
|
|
|
18
19
|
font-size: var(--sidebar-item-font-size);
|
|
19
20
|
font-family: var(--sidebar-item-font-family);
|
|
20
21
|
color: var(--sidebar-item-text-color);
|
|
21
|
-
top: var(--navbar-height);
|
|
22
|
-
height: calc(100vh - var(--navbar-height));
|
|
23
22
|
display: flex;
|
|
24
23
|
flex-direction: column;
|
|
25
24
|
width: 100%;
|
|
26
25
|
-webkit-font-smoothing: antialiased;
|
|
27
26
|
|
|
27
|
+
${({ hasNavbar }) => `
|
|
28
|
+
top: ${hasNavbar ? 'var(--navbar-height)' : '0'};
|
|
29
|
+
height: calc(100vh ${hasNavbar ? '- var(--navbar-height)' : ''});
|
|
30
|
+
`};
|
|
31
|
+
|
|
28
32
|
${({ opened, animate }) => `
|
|
29
33
|
opacity: ${opened ? '1' : '0'};
|
|
30
34
|
pointer-events: ${opened ? 'auto' : 'none'};
|
|
@@ -9,6 +9,7 @@ import { SidebarSearch } from '@theme/Search/SidebarSearch';
|
|
|
9
9
|
import { useThemeConfig } from '@theme/hooks/useThemeConfig';
|
|
10
10
|
import { ArrowBack } from '@theme/Sidebar/ArrowBack';
|
|
11
11
|
import { Link } from '@portal/Link';
|
|
12
|
+
import { Button } from '@theme/Button/Button';
|
|
12
13
|
|
|
13
14
|
interface SidebarLayoutProps {
|
|
14
15
|
versions: React.ReactNode;
|
|
@@ -17,12 +18,17 @@ interface SidebarLayoutProps {
|
|
|
17
18
|
label: string;
|
|
18
19
|
slug: string;
|
|
19
20
|
};
|
|
21
|
+
footer?: React.ReactNode;
|
|
22
|
+
|
|
23
|
+
hasNavbar: boolean;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export function SidebarLayout({
|
|
23
27
|
versions,
|
|
24
28
|
menu,
|
|
25
29
|
backLink,
|
|
30
|
+
footer,
|
|
31
|
+
hasNavbar,
|
|
26
32
|
}: SidebarLayoutProps): JSX.Element | null {
|
|
27
33
|
const [isOpen, setIsOpen] = useMobileMenu();
|
|
28
34
|
const toggleMenu = () => setIsOpen(!isOpen);
|
|
@@ -37,7 +43,7 @@ export function SidebarLayout({
|
|
|
37
43
|
<MobileSidebarButton opened={isOpen} onClick={toggleMenu} />
|
|
38
44
|
|
|
39
45
|
{!search?.hide && search?.placement === 'sidebar' ? <SidebarSearch /> : null}
|
|
40
|
-
<Sidebar animate={true} opened={isOpen}>
|
|
46
|
+
<Sidebar animate={true} opened={isOpen} hasNavbar={hasNavbar}>
|
|
41
47
|
{(backLink && (
|
|
42
48
|
<BackLinkWrapper>
|
|
43
49
|
<Link to={backLink.slug}>
|
|
@@ -49,11 +55,22 @@ export function SidebarLayout({
|
|
|
49
55
|
null}
|
|
50
56
|
{versions}
|
|
51
57
|
<MenuContainer>{menu}</MenuContainer>
|
|
58
|
+
{footer ? <FooterWrapper>{footer}</FooterWrapper> : null}
|
|
52
59
|
</Sidebar>
|
|
53
60
|
</Wrapper>
|
|
54
61
|
);
|
|
55
62
|
}
|
|
56
63
|
|
|
64
|
+
const FooterWrapper = styled.div`
|
|
65
|
+
padding: var(--sidebar-offset-top) var(--sidebar-item-padding-horizontal)
|
|
66
|
+
var(--sidebar-item-padding-horizontal) var(--sidebar-offset-left);
|
|
67
|
+
|
|
68
|
+
${Button} {
|
|
69
|
+
width: 100%;
|
|
70
|
+
margin: 0;
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
|
|
57
74
|
const BackLinkWrapper = styled.div`
|
|
58
75
|
padding: var(--sidebar-offset-top) var(--sidebar-item-padding-horizontal)
|
|
59
76
|
var(--sidebar-item-padding-horizontal)
|
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: var(--heading-margin-top); // @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
|
|
|
@@ -2008,10 +2008,17 @@ export const styles = css`
|
|
|
2008
2008
|
${apiLogsTable}
|
|
2009
2009
|
${pages}
|
|
2010
2010
|
${modal}
|
|
2011
|
+
|
|
2012
|
+
--api-onboarding-table-text-color: #4e5356;
|
|
2013
|
+
|
|
2014
|
+
background-color: var(--background-color);
|
|
2015
|
+
color: var(--text-color);
|
|
2011
2016
|
}
|
|
2012
2017
|
|
|
2013
2018
|
:root.dark {
|
|
2014
2019
|
${darkMode};
|
|
2020
|
+
|
|
2021
|
+
--api-onboarding-table-text-color: #ffffff;
|
|
2015
2022
|
}
|
|
2016
2023
|
|
|
2017
2024
|
:root.notransition * {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
4
3
|
export type UseActiveHeadingReturnType = string | undefined;
|
|
5
4
|
|
|
6
5
|
type HeadingEntry = {
|
|
@@ -16,8 +15,7 @@ export function useActiveHeading(
|
|
|
16
15
|
);
|
|
17
16
|
const [headingElements, setHeadingElements] = useState<HTMLElement[]>([]);
|
|
18
17
|
const headingElementsRef = useRef<HeadingEntry>({});
|
|
19
|
-
|
|
20
|
-
const history = useHistory();
|
|
18
|
+
const location = useLocation();
|
|
21
19
|
|
|
22
20
|
const getVisibleHeadings = () => {
|
|
23
21
|
const visibleHeadings: IntersectionObserverEntry[] = [];
|
|
@@ -86,14 +84,7 @@ export function useActiveHeading(
|
|
|
86
84
|
return;
|
|
87
85
|
}
|
|
88
86
|
setHeadingElements(findHeaders(contentElement));
|
|
89
|
-
|
|
90
|
-
const unlisten = history.listen(() => {
|
|
91
|
-
setHeadingElements(findHeaders(contentElement));
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return () => unlisten();
|
|
95
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
-
}, [contentElement]);
|
|
87
|
+
}, [contentElement, location]);
|
|
97
88
|
|
|
98
89
|
useEffect(() => {
|
|
99
90
|
if (!headingElements?.length) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
3
|
|
|
4
4
|
import type { Dispatch, SetStateAction } from 'react';
|
|
5
5
|
|
|
6
6
|
export function useMobileMenu(initialState = false): [boolean, Dispatch<SetStateAction<boolean>>] {
|
|
7
|
-
const
|
|
7
|
+
const location = useLocation();
|
|
8
8
|
const [isOpen, setIsOpen] = useState(initialState);
|
|
9
9
|
|
|
10
10
|
useEffect(() => setIsOpen(false), [location.pathname]);
|
|
@@ -63,7 +63,7 @@ export declare type ResolvedNavItemWithLink = (ResolvedNavLinkItem | ResolvedNav
|
|
|
63
63
|
export declare type ResolvedSidebar = ResolvedNavItem[];
|
|
64
64
|
export interface PageProps {
|
|
65
65
|
seo?: {
|
|
66
|
-
title
|
|
66
|
+
title?: string;
|
|
67
67
|
};
|
|
68
68
|
frontmatter?: Omit<PageProps, 'frontmatter'> & {
|
|
69
69
|
settings?: any;
|
package/src/ui/Jumbotron.tsx
CHANGED
|
@@ -19,8 +19,8 @@ export const Jumbotron = styled(Background).attrs(() => ({
|
|
|
19
19
|
flex-direction: column;
|
|
20
20
|
padding-top: ${({ pt }) => pt || '0'};
|
|
21
21
|
padding-bottom: ${({ pb }) => pb || '8em'};
|
|
22
|
-
padding-left: ${({ pl }) => pl || '
|
|
23
|
-
padding-right: ${({ pr }) => pr || '
|
|
22
|
+
padding-left: ${({ pl }) => pl || '1rem'};
|
|
23
|
+
padding-right: ${({ pr }) => pr || '1rem'};
|
|
24
24
|
${({ bgColor }) => bgColor && `background: ${bgColor}`};
|
|
25
25
|
${({ bgImage, bgColor }) =>
|
|
26
26
|
bgImage &&
|