@redocly/theme 0.20.0 → 0.21.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/components/Menu/MenuItemSwitch.js +1 -4
- package/lib/components/Sidebar/BackButton.js +4 -1
- package/lib/components/Sidebar/Drilldown.js +4 -2
- package/lib/components/Sidebar/DrilldownMenu.js +8 -3
- package/lib/utils/highlight.d.ts +1 -0
- package/lib/utils/highlight.js +1 -0
- package/package.json +1 -1
- package/src/components/Menu/MenuItemSwitch.tsx +1 -4
- package/src/components/Sidebar/BackButton.tsx +5 -1
- package/src/components/Sidebar/Drilldown.tsx +6 -3
- package/src/components/Sidebar/DrilldownMenu.tsx +11 -4
- package/src/utils/highlight.ts +1 -0
|
@@ -16,10 +16,7 @@ const MenuItem_1 = require("../../components/Menu/MenuItem");
|
|
|
16
16
|
function MenuItemSwitch(props) {
|
|
17
17
|
var _a;
|
|
18
18
|
const type = (0, getMenuType_1.getMenuType)(props.item);
|
|
19
|
-
const { Drilldown, handleBack, handleExpand, isExpanded: drilldownIsExpanded, prevActiveItem, } = (0, useDrilldown_1.useDrilldown)(
|
|
20
|
-
item: props.item,
|
|
21
|
-
activeItem: props.activeItem,
|
|
22
|
-
});
|
|
19
|
+
const { Drilldown, handleBack, handleExpand, isExpanded: drilldownIsExpanded, prevActiveItem, } = (0, useDrilldown_1.useDrilldown)(props);
|
|
23
20
|
const { MenuGroup, handleGroupClick, isExpanded } = (0, useMenuGroup_1.useMenuGroup)(props.item);
|
|
24
21
|
switch (type) {
|
|
25
22
|
case types_1.MenuType.Separator:
|
|
@@ -9,7 +9,7 @@ const styled_components_1 = __importDefault(require("styled-components"));
|
|
|
9
9
|
const ArrowBack_1 = require("../../ui/ArrowBack");
|
|
10
10
|
function BackButton({ children, back, className, }) {
|
|
11
11
|
return (react_1.default.createElement(Button, { onClick: back, "data-component-name": "Sidebar/BackButton", className: className },
|
|
12
|
-
react_1.default.createElement(
|
|
12
|
+
react_1.default.createElement(ArrowBack, { dataComponentName: "Sidebar/ArrowBack" }),
|
|
13
13
|
children));
|
|
14
14
|
}
|
|
15
15
|
exports.BackButton = BackButton;
|
|
@@ -36,4 +36,7 @@ const Button = styled_components_1.default.button `
|
|
|
36
36
|
background: var(--sidebar-back-button-hover-background-color);
|
|
37
37
|
}
|
|
38
38
|
`;
|
|
39
|
+
const ArrowBack = (0, styled_components_1.default)(ArrowBack_1.ArrowBack) `
|
|
40
|
+
margin-right: var(--spacing-sm);
|
|
41
|
+
`;
|
|
39
42
|
//# sourceMappingURL=BackButton.js.map
|
|
@@ -21,11 +21,13 @@ const MenuItemLabel_1 = require("../../components/Menu/MenuItemLabel");
|
|
|
21
21
|
const SeparatorLine_1 = require("../../components/Separator/SeparatorLine");
|
|
22
22
|
const DrilldownMenuItem_1 = require("../../components/Sidebar/DrilldownMenuItem");
|
|
23
23
|
const DrilldownMenu_1 = require("../../components/Sidebar/DrilldownMenu");
|
|
24
|
+
const Menu_1 = require("../../components/Menu");
|
|
24
25
|
function Drilldown(_a) {
|
|
25
26
|
var { isExpanded, item, expand, className } = _a, props = __rest(_a, ["isExpanded", "item", "expand", "className"]);
|
|
26
27
|
return (react_1.default.createElement(Wrapper, { "data-component-name": "Sidebar/Drilldown", className: className },
|
|
27
|
-
react_1.default.createElement(
|
|
28
|
-
react_1.default.createElement(
|
|
28
|
+
react_1.default.createElement(Menu_1.MenuLinkItem, { item: item },
|
|
29
|
+
react_1.default.createElement(DrilldownLabel, { onClick: expand },
|
|
30
|
+
react_1.default.createElement(DrilldownMenuItem_1.DrilldownMenuItem, { item: item }))),
|
|
29
31
|
isExpanded ? react_1.default.createElement(DrilldownMenu_1.DrilldownMenu, Object.assign({ item: item }, props)) : null,
|
|
30
32
|
item.separatorLine ? react_1.default.createElement(SeparatorLine_1.SeparatorLine, null) : null));
|
|
31
33
|
}
|
|
@@ -32,16 +32,21 @@ const styled_components_1 = __importStar(require("styled-components"));
|
|
|
32
32
|
const BackButton_1 = require("../../components/Sidebar/BackButton");
|
|
33
33
|
const DrilldownMenuItem_1 = require("../../components/Sidebar/DrilldownMenuItem");
|
|
34
34
|
const hooks_1 = require("../../mocks/hooks");
|
|
35
|
+
const Menu_1 = require("../../components/Menu");
|
|
35
36
|
function DrilldownMenu({ item, back, prevActiveItem, children, className, }) {
|
|
36
37
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
37
38
|
const translationKeys = {
|
|
38
39
|
backLabel: 'theme.sidebar.menu.backLabel',
|
|
39
40
|
};
|
|
41
|
+
const label = item.label === (prevActiveItem === null || prevActiveItem === void 0 ? void 0 : prevActiveItem.label) || !(prevActiveItem === null || prevActiveItem === void 0 ? void 0 : prevActiveItem.label)
|
|
42
|
+
? translate(translationKeys.backLabel, 'Back')
|
|
43
|
+
: prevActiveItem === null || prevActiveItem === void 0 ? void 0 : prevActiveItem.label;
|
|
40
44
|
return (react_1.default.createElement(MenuContainer, { "data-component-name": "Sidebar/DrilldownMenu", className: className },
|
|
41
45
|
react_1.default.createElement(MenuContent, null,
|
|
42
46
|
react_1.default.createElement(MenuWrapper, null,
|
|
43
|
-
react_1.default.createElement(BackButton_1.BackButton, { back: back, "data-translation-key": translationKeys.backLabel },
|
|
44
|
-
react_1.default.createElement(
|
|
47
|
+
react_1.default.createElement(BackButton_1.BackButton, { back: back, "data-translation-key": translationKeys.backLabel }, label),
|
|
48
|
+
react_1.default.createElement(Menu_1.MenuLinkItem, { item: item },
|
|
49
|
+
react_1.default.createElement(DrilldownMenuItem_1.DrilldownMenuItem, { item: item }))),
|
|
45
50
|
children)));
|
|
46
51
|
}
|
|
47
52
|
exports.DrilldownMenu = DrilldownMenu;
|
|
@@ -52,6 +57,7 @@ const MenuContainer = styled_components_1.default.div `
|
|
|
52
57
|
width: 100%;
|
|
53
58
|
z-index: var(--z-index-raised);
|
|
54
59
|
background-color: var(--sidebar-item-drilldown-background-color);
|
|
60
|
+
padding: var(--sidebar-item-nested-offset) var(--sidebar-item-padding-horizontal);
|
|
55
61
|
`;
|
|
56
62
|
const slideInAnimation = (0, styled_components_1.keyframes) `
|
|
57
63
|
0% {
|
|
@@ -70,7 +76,6 @@ const MenuContent = styled_components_1.default.div `
|
|
|
70
76
|
`;
|
|
71
77
|
const MenuWrapper = styled_components_1.default.div `
|
|
72
78
|
padding: var(--sidebar-item-padding-vertical) var(--sidebar-item-padding-horizontal);
|
|
73
|
-
margin-bottom: calc(var(--sidebar-spacing-unit) * 3);
|
|
74
79
|
word-break: break-word;
|
|
75
80
|
`;
|
|
76
81
|
//# sourceMappingURL=DrilldownMenu.js.map
|
package/lib/utils/highlight.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import 'prismjs/components/prism-scala.js';
|
|
|
20
20
|
import 'prismjs/components/prism-sql.js';
|
|
21
21
|
import 'prismjs/components/prism-swift.js';
|
|
22
22
|
import 'prismjs/components/prism-graphql.js';
|
|
23
|
+
import 'prismjs/plugins/treeview/prism-treeview.js';
|
|
23
24
|
/**
|
|
24
25
|
* map language names to Prism.js names
|
|
25
26
|
*/
|
package/lib/utils/highlight.js
CHANGED
|
@@ -47,6 +47,7 @@ require("prismjs/components/prism-scala.js");
|
|
|
47
47
|
require("prismjs/components/prism-sql.js");
|
|
48
48
|
require("prismjs/components/prism-swift.js");
|
|
49
49
|
require("prismjs/components/prism-graphql.js");
|
|
50
|
+
require("prismjs/plugins/treeview/prism-treeview.js");
|
|
50
51
|
const DEFAULT_LANG = 'clike';
|
|
51
52
|
const NEW_LINE_EXP = /\n(?!$)/g;
|
|
52
53
|
Prism.languages.insertBefore('javascript', 'string', {
|
package/package.json
CHANGED
|
@@ -20,10 +20,7 @@ export function MenuItemSwitch(props: PropsWithChildren<MenuItemProps>) {
|
|
|
20
20
|
handleExpand,
|
|
21
21
|
isExpanded: drilldownIsExpanded,
|
|
22
22
|
prevActiveItem,
|
|
23
|
-
} = useDrilldown(
|
|
24
|
-
item: props.item,
|
|
25
|
-
activeItem: props.activeItem,
|
|
26
|
-
});
|
|
23
|
+
} = useDrilldown(props);
|
|
27
24
|
|
|
28
25
|
const { MenuGroup, handleGroupClick, isExpanded } = useMenuGroup(props.item);
|
|
29
26
|
switch (type) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
import { ArrowBack } from '@theme/ui/ArrowBack';
|
|
4
|
+
import { ArrowBack as ThemeArrowBack } from '@theme/ui/ArrowBack';
|
|
5
5
|
|
|
6
6
|
interface BackButtonProps {
|
|
7
7
|
back: () => void;
|
|
@@ -44,3 +44,7 @@ const Button = styled.button`
|
|
|
44
44
|
background: var(--sidebar-back-button-hover-background-color);
|
|
45
45
|
}
|
|
46
46
|
`;
|
|
47
|
+
|
|
48
|
+
const ArrowBack = styled(ThemeArrowBack)`
|
|
49
|
+
margin-right: var(--spacing-sm);
|
|
50
|
+
`;
|
|
@@ -6,6 +6,7 @@ import { SeparatorLine } from '@theme/components/Separator/SeparatorLine';
|
|
|
6
6
|
import { DrilldownMenuItem } from '@theme/components/Sidebar/DrilldownMenuItem';
|
|
7
7
|
import { DrilldownMenu } from '@theme/components/Sidebar/DrilldownMenu';
|
|
8
8
|
import type { DrilldownMenuProps } from '@theme/components/Sidebar/types';
|
|
9
|
+
import { MenuLinkItem } from '@theme/components/Menu';
|
|
9
10
|
|
|
10
11
|
interface DrilldownProps extends DrilldownMenuProps {
|
|
11
12
|
isExpanded: boolean;
|
|
@@ -22,9 +23,11 @@ export function Drilldown({
|
|
|
22
23
|
}: React.PropsWithChildren<DrilldownProps>): JSX.Element {
|
|
23
24
|
return (
|
|
24
25
|
<Wrapper data-component-name="Sidebar/Drilldown" className={className}>
|
|
25
|
-
<
|
|
26
|
-
<
|
|
27
|
-
|
|
26
|
+
<MenuLinkItem item={item}>
|
|
27
|
+
<DrilldownLabel onClick={expand}>
|
|
28
|
+
<DrilldownMenuItem item={item} />
|
|
29
|
+
</DrilldownLabel>
|
|
30
|
+
</MenuLinkItem>
|
|
28
31
|
|
|
29
32
|
{isExpanded ? <DrilldownMenu item={item} {...props} /> : null}
|
|
30
33
|
|
|
@@ -5,6 +5,7 @@ import { BackButton } from '@theme/components/Sidebar/BackButton';
|
|
|
5
5
|
import { DrilldownMenuItem } from '@theme/components/Sidebar/DrilldownMenuItem';
|
|
6
6
|
import type { DrilldownMenuProps } from '@theme/components/Sidebar/types';
|
|
7
7
|
import { useTranslate } from '@portal/hooks';
|
|
8
|
+
import { MenuLinkItem } from '@theme/components/Menu';
|
|
8
9
|
|
|
9
10
|
export function DrilldownMenu({
|
|
10
11
|
item,
|
|
@@ -17,16 +18,22 @@ export function DrilldownMenu({
|
|
|
17
18
|
const translationKeys = {
|
|
18
19
|
backLabel: 'theme.sidebar.menu.backLabel',
|
|
19
20
|
};
|
|
21
|
+
const label =
|
|
22
|
+
item.label === prevActiveItem?.label || !prevActiveItem?.label
|
|
23
|
+
? translate(translationKeys.backLabel, 'Back')
|
|
24
|
+
: prevActiveItem?.label;
|
|
25
|
+
|
|
20
26
|
return (
|
|
21
27
|
<MenuContainer data-component-name="Sidebar/DrilldownMenu" className={className}>
|
|
22
28
|
<MenuContent>
|
|
23
29
|
<MenuWrapper>
|
|
24
30
|
<BackButton back={back} data-translation-key={translationKeys.backLabel}>
|
|
25
|
-
{
|
|
31
|
+
{label}
|
|
26
32
|
</BackButton>
|
|
27
|
-
<
|
|
33
|
+
<MenuLinkItem item={item}>
|
|
34
|
+
<DrilldownMenuItem item={item} />
|
|
35
|
+
</MenuLinkItem>
|
|
28
36
|
</MenuWrapper>
|
|
29
|
-
|
|
30
37
|
{children}
|
|
31
38
|
</MenuContent>
|
|
32
39
|
</MenuContainer>
|
|
@@ -40,6 +47,7 @@ const MenuContainer = styled.div`
|
|
|
40
47
|
width: 100%;
|
|
41
48
|
z-index: var(--z-index-raised);
|
|
42
49
|
background-color: var(--sidebar-item-drilldown-background-color);
|
|
50
|
+
padding: var(--sidebar-item-nested-offset) var(--sidebar-item-padding-horizontal);
|
|
43
51
|
`;
|
|
44
52
|
|
|
45
53
|
const slideInAnimation = keyframes`
|
|
@@ -61,6 +69,5 @@ const MenuContent = styled.div`
|
|
|
61
69
|
|
|
62
70
|
const MenuWrapper = styled.div`
|
|
63
71
|
padding: var(--sidebar-item-padding-vertical) var(--sidebar-item-padding-horizontal);
|
|
64
|
-
margin-bottom: calc(var(--sidebar-spacing-unit) * 3);
|
|
65
72
|
word-break: break-word;
|
|
66
73
|
`;
|
package/src/utils/highlight.ts
CHANGED
|
@@ -21,6 +21,7 @@ import 'prismjs/components/prism-scala.js';
|
|
|
21
21
|
import 'prismjs/components/prism-sql.js';
|
|
22
22
|
import 'prismjs/components/prism-swift.js';
|
|
23
23
|
import 'prismjs/components/prism-graphql.js';
|
|
24
|
+
import 'prismjs/plugins/treeview/prism-treeview.js';
|
|
24
25
|
|
|
25
26
|
const DEFAULT_LANG = 'clike';
|
|
26
27
|
const NEW_LINE_EXP = /\n(?!$)/g;
|