@redocly/theme 0.40.0 → 0.40.2
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/ColorModeSwitcher/ColorModeSwitcher.js +3 -3
- package/lib/components/Dropdown/Dropdown.js +2 -1
- package/lib/components/Filter/FilterContent.d.ts +2 -2
- package/lib/components/Filter/FilterPopover.d.ts +2 -2
- package/lib/config.d.ts +2 -2
- package/lib/core/contexts/ThemeDataContext.d.ts +2 -2
- package/lib/core/hooks/menu/use-mobile-menu-items.js +1 -1
- package/lib/core/hooks/menu/use-mobile-menu-levels.js +1 -1
- package/lib/core/hooks/search/use-suggested-pages.d.ts +1 -1
- package/lib/core/hooks/use-color-switcher.d.ts +1 -2
- package/lib/core/hooks/use-color-switcher.js +6 -1
- package/lib/core/hooks/use-theme-config.d.ts +2 -2
- package/lib/core/hooks/use-theme-config.js +6 -5
- package/lib/core/templates/Markdown.d.ts +2 -4
- package/lib/core/templates/Markdown.js +2 -2
- package/lib/core/types/filter.d.ts +2 -2
- package/lib/icons/CloseOutlineIcon/CloseOutlineIcon.d.ts +9 -0
- package/lib/icons/CloseOutlineIcon/CloseOutlineIcon.js +24 -0
- package/lib/icons/DocumentAddIcon/DocumentAddIcon.d.ts +9 -0
- package/lib/icons/DocumentAddIcon/DocumentAddIcon.js +23 -0
- package/lib/icons/ExportIcon/ExportIcon.d.ts +9 -0
- package/lib/icons/ExportIcon/ExportIcon.js +23 -0
- package/lib/icons/FolderIcon/FolderIcon.d.ts +9 -0
- package/lib/icons/FolderIcon/FolderIcon.js +22 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/plugin.d.ts +3 -0
- package/lib/plugin.js +7 -0
- package/package.json +3 -2
- package/src/components/ColorModeSwitcher/ColorModeSwitcher.tsx +3 -3
- package/src/components/Dropdown/Dropdown.tsx +10 -10
- package/src/components/Filter/FilterContent.tsx +2 -2
- package/src/components/Filter/FilterPopover.tsx +2 -2
- package/src/config.ts +8 -4
- package/src/core/contexts/ThemeDataContext.tsx +2 -2
- package/src/core/hooks/menu/use-mobile-menu-items.ts +1 -1
- package/src/core/hooks/menu/use-mobile-menu-levels.ts +1 -1
- package/src/core/hooks/use-color-switcher.ts +9 -1
- package/src/core/hooks/use-theme-config.ts +11 -10
- package/src/core/templates/Markdown.tsx +3 -3
- package/src/core/types/filter.ts +2 -2
- package/src/icons/CloseOutlineIcon/CloseOutlineIcon.tsx +26 -0
- package/src/icons/DocumentAddIcon/DocumentAddIcon.tsx +24 -0
- package/src/icons/ExportIcon/ExportIcon.tsx +24 -0
- package/src/icons/FolderIcon/FolderIcon.tsx +23 -0
- package/src/index.ts +4 -0
- package/src/markdoc/tags/partial.ts +2 -2
- package/src/plugin.ts +3 -0
|
@@ -9,14 +9,14 @@ const hooks_1 = require("../../core/hooks");
|
|
|
9
9
|
const ColorModeIcon_1 = require("../../components/ColorModeSwitcher/ColorModeIcon");
|
|
10
10
|
const Button_1 = require("../../components/Button/Button");
|
|
11
11
|
function ColorModeSwitcher({ className }) {
|
|
12
|
-
const { isSwitcherHidden,
|
|
12
|
+
const { isSwitcherHidden, initActiveColorMode, switchColorMode, activeColorMode } = (0, hooks_1.useColorSwitcher)();
|
|
13
13
|
(0, hooks_1.useMount)(() => {
|
|
14
|
-
|
|
14
|
+
initActiveColorMode();
|
|
15
15
|
});
|
|
16
16
|
if (isSwitcherHidden) {
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
-
return (react_1.default.createElement(Button_1.Button, { "data-component-name": "ColorModeSwitcher/ColorModeSwitcher", "data-testid": "color-mode-switcher", onClick: () =>
|
|
19
|
+
return (react_1.default.createElement(Button_1.Button, { "data-component-name": "ColorModeSwitcher/ColorModeSwitcher", "data-testid": "color-mode-switcher", onClick: () => switchColorMode(), extraClass: className, variant: "secondary", size: "medium", icon: react_1.default.createElement(ColorModeIcon_1.ColorModeIcon, { mode: activeColorMode }) }));
|
|
20
20
|
}
|
|
21
21
|
exports.ColorModeSwitcher = ColorModeSwitcher;
|
|
22
22
|
//# sourceMappingURL=ColorModeSwitcher.js.map
|
|
@@ -59,7 +59,7 @@ function Dropdown({ children, className, active, trigger, triggerEvent = 'click'
|
|
|
59
59
|
const dropdownTrigger = (0, react_1.cloneElement)(triggerChild, Object.assign(Object.assign(Object.assign(Object.assign({ onClick: triggerEvent === 'click' ? handleToggle : undefined, icon: withArrow ? isOpen ? react_1.default.createElement(ChevronUpIcon_1.ChevronUpIcon, null) : react_1.default.createElement(ChevronDownIcon_1.ChevronDownIcon, null) : undefined }, (withArrow ? { iconPosition: 'right' } : {})), { tabIndex: 0 }), triggerChild.props), { onKeyDown: triggerEvent === 'click' ? handleKeyDown : undefined }));
|
|
60
60
|
return (react_1.default.createElement(DropdownWrapper, Object.assign({ "data-component-name": "Dropdown/Dropdown", "data-testid": "dropdown" }, dataAttributes, { className: className, ref: dropdownRef, onPointerEnter: triggerEvent === 'hover' ? handleOpen : undefined, onPointerLeave: triggerEvent === 'hover' ? handleClose : undefined, onClick: onClick }),
|
|
61
61
|
dropdownTrigger,
|
|
62
|
-
|
|
62
|
+
react_1.default.createElement(ChildrenWrapper, { placement: placement, alignment: alignment, isOpen: isOpen, onClick: closeOnClick ? handleChildClick : undefined }, children)));
|
|
63
63
|
}
|
|
64
64
|
exports.Dropdown = Dropdown;
|
|
65
65
|
const DropdownWrapper = styled_components_1.default.div `
|
|
@@ -84,6 +84,7 @@ const ChildrenWrapper = styled_components_1.default.div `
|
|
|
84
84
|
bottom: ${({ placement }) => (placement === 'top' ? '100%' : 'auto')};
|
|
85
85
|
left: ${({ alignment }) => (alignment === 'start' ? '0' : 'auto')};
|
|
86
86
|
right: ${({ alignment }) => (alignment === 'end' ? '0' : 'auto')};
|
|
87
|
+
display: ${({ isOpen }) => (isOpen ? 'block' : 'none')};
|
|
87
88
|
|
|
88
89
|
z-index: var(--z-index-raised);
|
|
89
90
|
`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ResolvedFilter } from '../../core/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RedoclyConfig } from '../../config';
|
|
3
3
|
export type FilterContentProps = {
|
|
4
4
|
setFilterTerm: (value: string) => void;
|
|
5
5
|
filters: ResolvedFilter[];
|
|
6
6
|
filterTerm: string;
|
|
7
|
-
filterValuesCasing?: NonNullable<
|
|
7
|
+
filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
|
|
8
8
|
};
|
|
9
9
|
export declare function FilterContent({ setFilterTerm, filters, filterTerm, filterValuesCasing, }: FilterContentProps): JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ResolvedFilter } from '../../core/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RedoclyConfig } from '../../config';
|
|
3
3
|
export type FilterPopoverProps = {
|
|
4
4
|
onClose: () => void;
|
|
5
5
|
filters: ResolvedFilter[];
|
|
6
|
-
filterValuesCasing?: NonNullable<
|
|
6
|
+
filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
|
|
7
7
|
filterTerm: string;
|
|
8
8
|
setFilterTerm: (term: string) => void;
|
|
9
9
|
};
|
package/lib/config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type {
|
|
1
|
+
import type { ProductConfig, CatalogFilterConfig, CatalogConfig, AmplitudeAnalyticsConfig, GoogleAnalyticsConfig, SegmentAnalyticsConfig, RudderstackAnalyticsConfig, GtmAnalyticsConfig, ScorecardConfig, ProductGoogleAnalyticsConfig, ProductThemeOverrideConfig, ProductUiConfig, RedoclyConfig, UiAccessibleConfig, ThemeConfig, ThemeUIConfig } from '@redocly/config';
|
|
2
|
+
export type { ProductConfig, CatalogFilterConfig, CatalogConfig, AmplitudeAnalyticsConfig, GoogleAnalyticsConfig, SegmentAnalyticsConfig, RudderstackAnalyticsConfig, GtmAnalyticsConfig, ScorecardConfig, ProductGoogleAnalyticsConfig, ProductThemeOverrideConfig, ProductUiConfig, RedoclyConfig, UiAccessibleConfig, ThemeConfig, ThemeUIConfig, };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ThemeHooks } from '../../core/types';
|
|
3
3
|
import type { LinkProps } from '../../components/Link/Link';
|
|
4
|
-
import type {
|
|
4
|
+
import type { UiAccessibleConfig } from '../../config';
|
|
5
5
|
export interface ThemeDataTransferObject {
|
|
6
6
|
hooks: ThemeHooks;
|
|
7
7
|
components: {
|
|
8
8
|
LinkComponent: (props: React.PropsWithChildren<LinkProps>) => JSX.Element;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
config: UiAccessibleConfig;
|
|
11
11
|
}
|
|
12
12
|
export declare const ThemeDataContext: import("react").Context<ThemeDataTransferObject | null>;
|
|
@@ -19,7 +19,7 @@ const useMobileMenuItems = (menuType) => {
|
|
|
19
19
|
const { currentItems: sidebarItems, pushDrilldownState, popDrilldownState, backLink, } = useSidebarItems(activeVersion);
|
|
20
20
|
const location = (0, react_router_dom_1.useLocation)();
|
|
21
21
|
const currentProduct = useCurrentProduct();
|
|
22
|
-
const hasProductNavbarOverride = (_a = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.
|
|
22
|
+
const hasProductNavbarOverride = (_a = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.configOverride) === null || _a === void 0 ? void 0 : _a.navbar;
|
|
23
23
|
const productThemeConfig = (0, hooks_1.useThemeConfig)();
|
|
24
24
|
const baseThemeConfig = (0, hooks_1.useThemeConfig)(false);
|
|
25
25
|
const baseNavItems = (((_b = baseThemeConfig.navbar) === null || _b === void 0 ? void 0 : _b.items) || []);
|
|
@@ -15,7 +15,7 @@ const useMobileMenuLevels = () => {
|
|
|
15
15
|
const currentProduct = useCurrentProduct();
|
|
16
16
|
const productThemeConfig = (0, hooks_1.useThemeConfig)();
|
|
17
17
|
const location = (0, react_router_dom_1.useLocation)();
|
|
18
|
-
const hasProductNavbarOverride = (_a = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.
|
|
18
|
+
const hasProductNavbarOverride = (_a = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.configOverride) === null || _a === void 0 ? void 0 : _a.navbar;
|
|
19
19
|
const productNavItems = (hasProductNavbarOverride ? ((_b = productThemeConfig.navbar) === null || _b === void 0 ? void 0 : _b.items) || [] : []);
|
|
20
20
|
const menuLevels = (0, react_1.useMemo)(() => {
|
|
21
21
|
const menuLevels = [
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export declare const useColorSwitcher: () => {
|
|
3
2
|
isSwitcherHidden: boolean | undefined;
|
|
4
|
-
|
|
3
|
+
initActiveColorMode: () => void;
|
|
5
4
|
switchColorMode: () => string;
|
|
6
5
|
activeColorMode: string;
|
|
7
6
|
};
|
|
@@ -11,6 +11,10 @@ const useColorSwitcher = () => {
|
|
|
11
11
|
const modes = (colorMode === null || colorMode === void 0 ? void 0 : colorMode.modes) || ['light', 'dark'];
|
|
12
12
|
const defaultColor = modes[0] || 'light';
|
|
13
13
|
const [activeColorMode, setActiveColorMode] = (0, react_1.useState)(defaultColor);
|
|
14
|
+
const initActiveColorMode = () => {
|
|
15
|
+
const activeMode = Array.from(document.documentElement.classList).find((c) => modes.includes(c));
|
|
16
|
+
setActiveColorMode(activeMode || defaultColor);
|
|
17
|
+
};
|
|
14
18
|
const switchColorMode = () => {
|
|
15
19
|
const activeIndex = modes.indexOf(activeColorMode);
|
|
16
20
|
const mode = activeIndex < modes.length - 1 ? modes[activeIndex + 1] : modes[0];
|
|
@@ -20,11 +24,12 @@ const useColorSwitcher = () => {
|
|
|
20
24
|
document.documentElement.classList.remove('notransition');
|
|
21
25
|
});
|
|
22
26
|
telemetry.send('color_mode_switched', { from: activeColorMode, to: mode });
|
|
27
|
+
setActiveColorMode(mode);
|
|
23
28
|
return mode;
|
|
24
29
|
};
|
|
25
30
|
return {
|
|
26
31
|
isSwitcherHidden: colorMode === null || colorMode === void 0 ? void 0 : colorMode.hide,
|
|
27
|
-
|
|
32
|
+
initActiveColorMode,
|
|
28
33
|
switchColorMode,
|
|
29
34
|
activeColorMode,
|
|
30
35
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function useThemeConfig<T extends Record<string, unknown>>(useProductConfig?: boolean): T & NonNullable<
|
|
1
|
+
import type { UiAccessibleConfig } from '../../config';
|
|
2
|
+
export declare function useThemeConfig<T extends Record<string, unknown>>(useProductConfig?: boolean): T & NonNullable<UiAccessibleConfig>;
|
|
@@ -3,20 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useThemeConfig = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const contexts_1 = require("../../core/contexts");
|
|
6
|
+
// TODO: rename and additionally export as alias for backward compatibility
|
|
6
7
|
function useThemeConfig(useProductConfig = true) {
|
|
7
8
|
const context = (0, react_1.useContext)(contexts_1.ThemeDataContext);
|
|
8
9
|
if (!context) {
|
|
9
10
|
return {};
|
|
10
11
|
}
|
|
11
|
-
const {
|
|
12
|
+
const { config, hooks } = context;
|
|
12
13
|
const { useCurrentProduct } = hooks;
|
|
13
14
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14
15
|
const currentProduct = useCurrentProduct();
|
|
15
|
-
const
|
|
16
|
-
? Object.assign(Object.assign(Object.assign({},
|
|
16
|
+
const mergedConfig = useProductConfig && (currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.configOverride)
|
|
17
|
+
? Object.assign(Object.assign(Object.assign({}, config), currentProduct.configOverride), {
|
|
17
18
|
// Do not override analytics config from product
|
|
18
|
-
analytics:
|
|
19
|
-
return
|
|
19
|
+
analytics: config.analytics }) : config;
|
|
20
|
+
return mergedConfig;
|
|
20
21
|
}
|
|
21
22
|
exports.useThemeConfig = useThemeConfig;
|
|
22
23
|
//# sourceMappingURL=use-theme-config.js.map
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { UiAccessibleConfig } from '../../config';
|
|
3
3
|
import type { MdHeading } from '../../core/types';
|
|
4
4
|
type MarkdownTemplateProps = {
|
|
5
5
|
pageProps: {
|
|
6
|
-
frontmatter?:
|
|
7
|
-
theme?: ThemeUIConfig;
|
|
8
|
-
};
|
|
6
|
+
frontmatter?: UiAccessibleConfig;
|
|
9
7
|
headings?: (MdHeading | null)[];
|
|
10
8
|
editPage?: {
|
|
11
9
|
to: string;
|
|
@@ -32,7 +32,7 @@ const TableOfContent_1 = require("../../components/TableOfContent/TableOfContent
|
|
|
32
32
|
const Feedback_1 = require("../../components/Feedback/Feedback");
|
|
33
33
|
const utils_1 = require("../../core/utils");
|
|
34
34
|
function default_1({ pageProps, children }) {
|
|
35
|
-
var _a
|
|
35
|
+
var _a;
|
|
36
36
|
const [wrapperElement, setWrapperElement] = React.useState(null);
|
|
37
37
|
const { useSidebarSiblingsData } = (0, hooks_1.useThemeHooks)();
|
|
38
38
|
const { markdown } = (0, hooks_1.useThemeConfig)();
|
|
@@ -48,7 +48,7 @@ function default_1({ pageProps, children }) {
|
|
|
48
48
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
49
|
[pageProps.headings]);
|
|
50
50
|
const tableOfContent = (React.createElement(TableOfContent_1.TableOfContent, { headings: pageProps.headings, contentWrapper: wrapperElement }));
|
|
51
|
-
const { type, settings, hide } = ((
|
|
51
|
+
const { type, settings, hide } = ((_a = pageProps.frontmatter) === null || _a === void 0 ? void 0 : _a.feedback) || {};
|
|
52
52
|
const feedback = React.createElement(Feedback_1.Feedback, { type: type, hide: hide, settings: settings, path: pathname });
|
|
53
53
|
const documentationLayoutProps = {
|
|
54
54
|
tableOfContent,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ResolvedFilter } from '../../core/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RedoclyConfig } from '@redocly/config';
|
|
3
3
|
export type FilterProps = {
|
|
4
4
|
filter: ResolvedFilter & {
|
|
5
5
|
selectedOptions: any;
|
|
6
6
|
};
|
|
7
|
-
filterValuesCasing?: NonNullable<
|
|
7
|
+
filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
|
|
8
8
|
};
|
|
9
9
|
export type FilterTypes = NonNullable<FilterProps['filter']['type']>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IconProps } from '../../icons/types';
|
|
3
|
+
export declare const CloseOutlineIcon: import("styled-components").StyledComponent<(props: IconProps) => React.JSX.Element, any, {
|
|
4
|
+
'data-component-name': string;
|
|
5
|
+
} & {
|
|
6
|
+
color?: string | undefined;
|
|
7
|
+
size?: string | undefined;
|
|
8
|
+
className?: string | undefined;
|
|
9
|
+
} & React.SVGProps<SVGSVGElement>, "data-component-name">;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CloseOutlineIcon = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const utils_1 = require("../../core/utils");
|
|
10
|
+
const Icon = (props) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", fill: "none" }, props),
|
|
11
|
+
react_1.default.createElement("g", null,
|
|
12
|
+
react_1.default.createElement("path", { d: "M7 0.875C3.5875 0.875 0.875 3.5875 0.875 7C0.875 10.4125 3.5875 13.125 7 13.125C10.4125 13.125 13.125 10.4125 13.125 7C13.125 3.5875 10.4125 0.875 7 0.875ZM7 12.25C4.1125 12.25 1.75 9.8875 1.75 7C1.75 4.1125 4.1125 1.75 7 1.75C9.8875 1.75 12.25 4.1125 12.25 7C12.25 9.8875 9.8875 12.25 7 12.25Z" }),
|
|
13
|
+
react_1.default.createElement("path", { d: "M9.3625 10.0625L7 7.7L4.6375 10.0625L3.9375 9.3625L6.3 7L3.9375 4.6375L4.6375 3.9375L7 6.3L9.3625 3.9375L10.0625 4.6375L7.7 7L10.0625 9.3625L9.3625 10.0625Z" }))));
|
|
14
|
+
exports.CloseOutlineIcon = (0, styled_components_1.default)(Icon).attrs(() => ({
|
|
15
|
+
'data-component-name': 'icons/CloseOutlineIcon/CloseOutlineIcon',
|
|
16
|
+
})) `
|
|
17
|
+
path {
|
|
18
|
+
fill: ${({ color }) => (0, utils_1.getCssColorVariable)(color)};
|
|
19
|
+
}
|
|
20
|
+
height: ${({ size }) => size || '16px'};
|
|
21
|
+
width: ${({ size }) => size || '16px'};
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
`;
|
|
24
|
+
//# sourceMappingURL=CloseOutlineIcon.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IconProps } from '../../icons/types';
|
|
3
|
+
export declare const DocumentAddIcon: import("styled-components").StyledComponent<(props: IconProps) => React.JSX.Element, any, {
|
|
4
|
+
'data-component-name': string;
|
|
5
|
+
} & {
|
|
6
|
+
color?: string | undefined;
|
|
7
|
+
size?: string | undefined;
|
|
8
|
+
className?: string | undefined;
|
|
9
|
+
} & React.SVGProps<SVGSVGElement>, "data-component-name">;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DocumentAddIcon = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const utils_1 = require("../../core/utils");
|
|
10
|
+
const Icon = (props) => (react_1.default.createElement("svg", Object.assign({ viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props),
|
|
11
|
+
react_1.default.createElement("path", { d: "M15 11.9999H13V9.99993H12V11.9999H10V12.9999H12V14.9999H13V12.9999H15V11.9999Z" }),
|
|
12
|
+
react_1.default.createElement("path", { d: "M8 13.9999H4V1.99993H8V4.99993C8.00077 5.26491 8.10637 5.51882 8.29374 5.70619C8.48111 5.89356 8.73502 5.99916 9 5.99993H12V7.99993H13V4.99993C13.0018 4.93421 12.9893 4.86889 12.9634 4.80847C12.9375 4.74804 12.8988 4.69395 12.85 4.64993L9.35 1.14993C9.30599 1.10109 9.2519 1.06239 9.19147 1.03649C9.13104 1.01059 9.06572 0.99812 9 0.999928H4C3.73502 1.00069 3.48111 1.1063 3.29374 1.29367C3.10637 1.48104 3.00077 1.73495 3 1.99993V13.9999C3.00077 14.2649 3.10637 14.5188 3.29374 14.7062C3.48111 14.8936 3.73502 14.9992 4 14.9999H8V13.9999ZM9 2.19993L11.8 4.99993H9V2.19993Z" })));
|
|
13
|
+
exports.DocumentAddIcon = (0, styled_components_1.default)(Icon).attrs(() => ({
|
|
14
|
+
'data-component-name': 'icons/DocumentAddIcon/DocumentAddIcon',
|
|
15
|
+
})) `
|
|
16
|
+
path {
|
|
17
|
+
fill: ${({ color }) => (0, utils_1.getCssColorVariable)(color)};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
height: ${({ size }) => size || '16px'};
|
|
21
|
+
width: ${({ size }) => size || '16px'};
|
|
22
|
+
`;
|
|
23
|
+
//# sourceMappingURL=DocumentAddIcon.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IconProps } from '../../icons/types';
|
|
3
|
+
export declare const ExportIcon: import("styled-components").StyledComponent<(props: IconProps) => React.JSX.Element, any, {
|
|
4
|
+
'data-component-name': string;
|
|
5
|
+
} & {
|
|
6
|
+
color?: string | undefined;
|
|
7
|
+
size?: string | undefined;
|
|
8
|
+
className?: string | undefined;
|
|
9
|
+
} & React.SVGProps<SVGSVGElement>, "data-component-name">;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ExportIcon = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const utils_1 = require("../../core/utils");
|
|
10
|
+
const Icon = (props) => (react_1.default.createElement("svg", Object.assign({ viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props),
|
|
11
|
+
react_1.default.createElement("path", { d: "M13 12V14H3V12H2V14L2.0038 13.9976C2.00333 14.1288 2.02873 14.2589 2.07854 14.3803C2.12836 14.5017 2.20163 14.6121 2.29414 14.7052C2.38666 14.7983 2.49662 14.8723 2.61774 14.9229C2.73885 14.9734 2.86875 14.9997 3 15H13C13.2652 15 13.5196 14.8946 13.7071 14.7071C13.8946 14.5196 14 14.2652 14 14V12H13Z" }),
|
|
12
|
+
react_1.default.createElement("path", { d: "M3 6L3.7055 6.7025L7.5 2.9125V12H8.5V2.9125L12.2955 6.7025L13 6L8 1L3 6Z" })));
|
|
13
|
+
exports.ExportIcon = (0, styled_components_1.default)(Icon).attrs(() => ({
|
|
14
|
+
'data-component-name': 'icons/ExportIcon/ExportIcon',
|
|
15
|
+
})) `
|
|
16
|
+
path {
|
|
17
|
+
fill: ${({ color }) => (0, utils_1.getCssColorVariable)(color)};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
height: ${({ size }) => size || '16px'};
|
|
21
|
+
width: ${({ size }) => size || '16px'};
|
|
22
|
+
`;
|
|
23
|
+
//# sourceMappingURL=ExportIcon.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IconProps } from '../../icons/types';
|
|
3
|
+
export declare const FolderIcon: import("styled-components").StyledComponent<(props: IconProps) => React.JSX.Element, any, {
|
|
4
|
+
'data-component-name': string;
|
|
5
|
+
} & {
|
|
6
|
+
color?: string | undefined;
|
|
7
|
+
size?: string | undefined;
|
|
8
|
+
className?: string | undefined;
|
|
9
|
+
} & React.SVGProps<SVGSVGElement>, "data-component-name">;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FolderIcon = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const utils_1 = require("../../core/utils");
|
|
10
|
+
const Icon = (props) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 14 14", fill: "none" }, props),
|
|
11
|
+
react_1.default.createElement("path", { d: "M4.88688 2.625L6.38313 4.11688L6.63688 4.375H12.25V11.375H1.75V2.625H4.88688ZM4.88688 1.75H1.75C1.51794 1.75 1.29538 1.84219 1.13128 2.00628C0.967187 2.17038 0.875 2.39294 0.875 2.625V11.375C0.875 11.6071 0.967187 11.8296 1.13128 11.9937C1.29538 12.1578 1.51794 12.25 1.75 12.25H12.25C12.4821 12.25 12.7046 12.1578 12.8687 11.9937C13.0328 11.8296 13.125 11.6071 13.125 11.375V4.375C13.125 4.14294 13.0328 3.92038 12.8687 3.75628C12.7046 3.59219 12.4821 3.5 12.25 3.5H7L5.50813 2.00813C5.42672 1.92624 5.32992 1.86127 5.2233 1.81697C5.11667 1.77267 5.00234 1.74991 4.88688 1.75Z" })));
|
|
12
|
+
exports.FolderIcon = (0, styled_components_1.default)(Icon).attrs(() => ({
|
|
13
|
+
'data-component-name': 'icons/FolderIcon/FolderIcon',
|
|
14
|
+
})) `
|
|
15
|
+
path {
|
|
16
|
+
fill: ${({ color }) => (0, utils_1.getCssColorVariable)(color)};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
height: ${({ size }) => size || '16px'};
|
|
20
|
+
width: ${({ size }) => size || '16px'};
|
|
21
|
+
`;
|
|
22
|
+
//# sourceMappingURL=FolderIcon.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -123,9 +123,11 @@ export * from './icons/CleanIcon/CleanIcon';
|
|
|
123
123
|
export * from './icons/DeselectIcon/DeselectIcon';
|
|
124
124
|
export * from './icons/FileStorageIcon/FileStorageIcon';
|
|
125
125
|
export * from './icons/FolderAddIcon/FolderAddIcon';
|
|
126
|
+
export * from './icons/FolderIcon/FolderIcon';
|
|
126
127
|
export * from './icons/FolderMoveToIcon/FolderMoveToIcon';
|
|
127
128
|
export * from './icons/SelectIcon/SelectIcon';
|
|
128
129
|
export * from './icons/CloseIcon/CloseIcon';
|
|
130
|
+
export * from './icons/CloseOutlineIcon/CloseOutlineIcon';
|
|
129
131
|
export * from './icons/CloseFilledIcon/CloseFilledIcon';
|
|
130
132
|
export * from './icons/LogoutIcon/LogoutIcon';
|
|
131
133
|
export * from './icons/CheckboxIcon/CheckboxIcon';
|
|
@@ -136,6 +138,7 @@ export * from './icons/DataFormatIcon/DataFormatIcon';
|
|
|
136
138
|
export * from './icons/Spinner/Spinner';
|
|
137
139
|
export * from './icons/CheckmarkIcon/CheckmarkIcon';
|
|
138
140
|
export * from './icons/DownloadIcon/DownloadIcon';
|
|
141
|
+
export * from './icons/DocumentAddIcon/DocumentAddIcon';
|
|
139
142
|
export * from './icons/EmailIcon/EmailIcon';
|
|
140
143
|
export * from './icons/SaveIcon/SaveIcon';
|
|
141
144
|
export * from './icons/CloudUploadIcon/CloudUploadIcon';
|
|
@@ -198,6 +201,7 @@ export * from './icons/SubtractIcon/SubtractIcon';
|
|
|
198
201
|
export * from './icons/PlusCustomIcon/PlusCustomIcon';
|
|
199
202
|
export * from './icons/CharacterIcon/CharacterIcon';
|
|
200
203
|
export * from './icons/FileIcon/FileIcon';
|
|
204
|
+
export * from './icons/ExportIcon/ExportIcon';
|
|
201
205
|
export * from './layouts/RootLayout';
|
|
202
206
|
export * from './layouts/PageLayout';
|
|
203
207
|
export * from './layouts/NotFound';
|
package/lib/index.js
CHANGED
|
@@ -175,9 +175,11 @@ __exportStar(require("./icons/CleanIcon/CleanIcon"), exports);
|
|
|
175
175
|
__exportStar(require("./icons/DeselectIcon/DeselectIcon"), exports);
|
|
176
176
|
__exportStar(require("./icons/FileStorageIcon/FileStorageIcon"), exports);
|
|
177
177
|
__exportStar(require("./icons/FolderAddIcon/FolderAddIcon"), exports);
|
|
178
|
+
__exportStar(require("./icons/FolderIcon/FolderIcon"), exports);
|
|
178
179
|
__exportStar(require("./icons/FolderMoveToIcon/FolderMoveToIcon"), exports);
|
|
179
180
|
__exportStar(require("./icons/SelectIcon/SelectIcon"), exports);
|
|
180
181
|
__exportStar(require("./icons/CloseIcon/CloseIcon"), exports);
|
|
182
|
+
__exportStar(require("./icons/CloseOutlineIcon/CloseOutlineIcon"), exports);
|
|
181
183
|
__exportStar(require("./icons/CloseFilledIcon/CloseFilledIcon"), exports);
|
|
182
184
|
__exportStar(require("./icons/LogoutIcon/LogoutIcon"), exports);
|
|
183
185
|
__exportStar(require("./icons/CheckboxIcon/CheckboxIcon"), exports);
|
|
@@ -188,6 +190,7 @@ __exportStar(require("./icons/DataFormatIcon/DataFormatIcon"), exports);
|
|
|
188
190
|
__exportStar(require("./icons/Spinner/Spinner"), exports);
|
|
189
191
|
__exportStar(require("./icons/CheckmarkIcon/CheckmarkIcon"), exports);
|
|
190
192
|
__exportStar(require("./icons/DownloadIcon/DownloadIcon"), exports);
|
|
193
|
+
__exportStar(require("./icons/DocumentAddIcon/DocumentAddIcon"), exports);
|
|
191
194
|
__exportStar(require("./icons/EmailIcon/EmailIcon"), exports);
|
|
192
195
|
__exportStar(require("./icons/SaveIcon/SaveIcon"), exports);
|
|
193
196
|
__exportStar(require("./icons/CloudUploadIcon/CloudUploadIcon"), exports);
|
|
@@ -250,6 +253,7 @@ __exportStar(require("./icons/SubtractIcon/SubtractIcon"), exports);
|
|
|
250
253
|
__exportStar(require("./icons/PlusCustomIcon/PlusCustomIcon"), exports);
|
|
251
254
|
__exportStar(require("./icons/CharacterIcon/CharacterIcon"), exports);
|
|
252
255
|
__exportStar(require("./icons/FileIcon/FileIcon"), exports);
|
|
256
|
+
__exportStar(require("./icons/ExportIcon/ExportIcon"), exports);
|
|
253
257
|
/* Layouts */
|
|
254
258
|
__exportStar(require("./layouts/RootLayout"), exports);
|
|
255
259
|
__exportStar(require("./layouts/PageLayout"), exports);
|
package/lib/plugin.d.ts
ADDED
package/lib/plugin.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.2",
|
|
4
4
|
"description": "Shared UI components lib",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"theme",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"exports": {
|
|
14
14
|
"./package.json": "./package.json",
|
|
15
15
|
"./config.js": "./lib/config.js",
|
|
16
|
+
"./plugin.js": "./lib/plugin.js",
|
|
16
17
|
"./config": "./lib/config.js",
|
|
17
18
|
".": "./lib/index.js",
|
|
18
19
|
"./src/": "./src/",
|
|
@@ -98,7 +99,7 @@
|
|
|
98
99
|
"timeago.js": "^4.0.2",
|
|
99
100
|
"i18next": "^22.4.12",
|
|
100
101
|
"nprogress": "^0.2.0",
|
|
101
|
-
"@redocly/config": "0.
|
|
102
|
+
"@redocly/config": "0.10.0"
|
|
102
103
|
},
|
|
103
104
|
"scripts": {
|
|
104
105
|
"start": "npm-run-all --parallel storybook storybook:tokens:watch",
|
|
@@ -9,11 +9,11 @@ export type ColorModeSwitcherProps = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export function ColorModeSwitcher({ className }: ColorModeSwitcherProps): JSX.Element | null {
|
|
12
|
-
const { isSwitcherHidden,
|
|
12
|
+
const { isSwitcherHidden, initActiveColorMode, switchColorMode, activeColorMode } =
|
|
13
13
|
useColorSwitcher();
|
|
14
14
|
|
|
15
15
|
useMount(() => {
|
|
16
|
-
|
|
16
|
+
initActiveColorMode();
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
if (isSwitcherHidden) {
|
|
@@ -24,7 +24,7 @@ export function ColorModeSwitcher({ className }: ColorModeSwitcherProps): JSX.El
|
|
|
24
24
|
<Button
|
|
25
25
|
data-component-name="ColorModeSwitcher/ColorModeSwitcher"
|
|
26
26
|
data-testid="color-mode-switcher"
|
|
27
|
-
onClick={() =>
|
|
27
|
+
onClick={() => switchColorMode()}
|
|
28
28
|
extraClass={className}
|
|
29
29
|
variant="secondary"
|
|
30
30
|
size="medium"
|
|
@@ -89,15 +89,14 @@ export function Dropdown({
|
|
|
89
89
|
>
|
|
90
90
|
{dropdownTrigger}
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)}
|
|
92
|
+
<ChildrenWrapper
|
|
93
|
+
placement={placement}
|
|
94
|
+
alignment={alignment}
|
|
95
|
+
isOpen={isOpen}
|
|
96
|
+
onClick={closeOnClick ? handleChildClick : undefined}
|
|
97
|
+
>
|
|
98
|
+
{children}
|
|
99
|
+
</ChildrenWrapper>
|
|
101
100
|
</DropdownWrapper>
|
|
102
101
|
);
|
|
103
102
|
}
|
|
@@ -119,12 +118,13 @@ const DropdownWrapper = styled.div`
|
|
|
119
118
|
text-decoration: none;
|
|
120
119
|
`;
|
|
121
120
|
|
|
122
|
-
const ChildrenWrapper = styled.div<{ placement?: string; alignment?: string }>`
|
|
121
|
+
const ChildrenWrapper = styled.div<{ placement?: string; alignment?: string; isOpen?: boolean }>`
|
|
123
122
|
position: absolute;
|
|
124
123
|
top: ${({ placement }) => (placement === 'top' ? 'auto' : '100%')};
|
|
125
124
|
bottom: ${({ placement }) => (placement === 'top' ? '100%' : 'auto')};
|
|
126
125
|
left: ${({ alignment }) => (alignment === 'start' ? '0' : 'auto')};
|
|
127
126
|
right: ${({ alignment }) => (alignment === 'end' ? '0' : 'auto')};
|
|
127
|
+
display: ${({ isOpen }) => (isOpen ? 'block' : 'none')};
|
|
128
128
|
|
|
129
129
|
z-index: var(--z-index-raised);
|
|
130
130
|
`;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
4
|
import type { ResolvedFilter } from '@redocly/theme/core/types';
|
|
5
|
-
import type {
|
|
5
|
+
import type { RedoclyConfig } from '@redocly/theme/config';
|
|
6
6
|
|
|
7
7
|
import { FilterInput } from '@redocly/theme/components/Filter/FilterInput';
|
|
8
8
|
import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
@@ -13,7 +13,7 @@ export type FilterContentProps = {
|
|
|
13
13
|
setFilterTerm: (value: string) => void;
|
|
14
14
|
filters: ResolvedFilter[];
|
|
15
15
|
filterTerm: string;
|
|
16
|
-
filterValuesCasing?: NonNullable<
|
|
16
|
+
filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export function FilterContent({
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
4
|
import type { ResolvedFilter } from '@redocly/theme/core/types';
|
|
5
|
-
import type {
|
|
5
|
+
import type { RedoclyConfig } from '@redocly/theme/config';
|
|
6
6
|
|
|
7
7
|
import { breakpoints } from '@redocly/theme/core/utils';
|
|
8
8
|
import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
@@ -11,7 +11,7 @@ import { FilterContent } from '@redocly/theme/components/Filter/FilterContent';
|
|
|
11
11
|
export type FilterPopoverProps = {
|
|
12
12
|
onClose: () => void;
|
|
13
13
|
filters: ResolvedFilter[];
|
|
14
|
-
filterValuesCasing?: NonNullable<
|
|
14
|
+
filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
|
|
15
15
|
filterTerm: string;
|
|
16
16
|
setFilterTerm: (term: string) => void;
|
|
17
17
|
};
|
package/src/config.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
ThemeConfig,
|
|
3
2
|
ProductConfig,
|
|
4
3
|
CatalogFilterConfig,
|
|
5
4
|
CatalogConfig,
|
|
@@ -11,12 +10,14 @@ import type {
|
|
|
11
10
|
ScorecardConfig,
|
|
12
11
|
ProductGoogleAnalyticsConfig,
|
|
13
12
|
ProductThemeOverrideConfig,
|
|
14
|
-
ThemeUIConfig,
|
|
15
13
|
ProductUiConfig,
|
|
14
|
+
RedoclyConfig,
|
|
15
|
+
UiAccessibleConfig,
|
|
16
|
+
ThemeConfig,
|
|
17
|
+
ThemeUIConfig,
|
|
16
18
|
} from '@redocly/config';
|
|
17
19
|
|
|
18
20
|
export type {
|
|
19
|
-
ThemeConfig,
|
|
20
21
|
ProductConfig,
|
|
21
22
|
CatalogFilterConfig,
|
|
22
23
|
CatalogConfig,
|
|
@@ -28,6 +29,9 @@ export type {
|
|
|
28
29
|
ScorecardConfig,
|
|
29
30
|
ProductGoogleAnalyticsConfig,
|
|
30
31
|
ProductThemeOverrideConfig,
|
|
31
|
-
ThemeUIConfig,
|
|
32
32
|
ProductUiConfig,
|
|
33
|
+
RedoclyConfig,
|
|
34
|
+
UiAccessibleConfig,
|
|
35
|
+
ThemeConfig,
|
|
36
|
+
ThemeUIConfig,
|
|
33
37
|
};
|
|
@@ -2,14 +2,14 @@ import { createContext } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import type { ThemeHooks } from '@redocly/theme/core/types';
|
|
4
4
|
import type { LinkProps } from '@redocly/theme/components/Link/Link';
|
|
5
|
-
import type {
|
|
5
|
+
import type { UiAccessibleConfig } from '@redocly/theme/config';
|
|
6
6
|
|
|
7
7
|
export interface ThemeDataTransferObject {
|
|
8
8
|
hooks: ThemeHooks;
|
|
9
9
|
components: {
|
|
10
10
|
LinkComponent: (props: React.PropsWithChildren<LinkProps>) => JSX.Element;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
config: UiAccessibleConfig;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export const ThemeDataContext = createContext<ThemeDataTransferObject | null>(null);
|
|
@@ -31,7 +31,7 @@ export const useMobileMenuItems = (menuType: MobileMenuType) => {
|
|
|
31
31
|
const location = useLocation();
|
|
32
32
|
|
|
33
33
|
const currentProduct = useCurrentProduct();
|
|
34
|
-
const hasProductNavbarOverride = currentProduct?.
|
|
34
|
+
const hasProductNavbarOverride = currentProduct?.configOverride?.navbar;
|
|
35
35
|
|
|
36
36
|
const productThemeConfig = useThemeConfig();
|
|
37
37
|
const baseThemeConfig = useThemeConfig(false);
|
|
@@ -16,7 +16,7 @@ export const useMobileMenuLevels = () => {
|
|
|
16
16
|
const productThemeConfig = useThemeConfig();
|
|
17
17
|
const location = useLocation();
|
|
18
18
|
|
|
19
|
-
const hasProductNavbarOverride = currentProduct?.
|
|
19
|
+
const hasProductNavbarOverride = currentProduct?.configOverride?.navbar;
|
|
20
20
|
const productNavItems = (
|
|
21
21
|
hasProductNavbarOverride ? productThemeConfig.navbar?.items || [] : []
|
|
22
22
|
) as ResolvedNavItem[];
|
|
@@ -11,6 +11,13 @@ export const useColorSwitcher = () => {
|
|
|
11
11
|
const defaultColor = modes[0] || 'light';
|
|
12
12
|
const [activeColorMode, setActiveColorMode] = useState(defaultColor);
|
|
13
13
|
|
|
14
|
+
const initActiveColorMode = (): void => {
|
|
15
|
+
const activeMode = Array.from(document.documentElement.classList).find((c) =>
|
|
16
|
+
modes.includes(c),
|
|
17
|
+
);
|
|
18
|
+
setActiveColorMode(activeMode || defaultColor);
|
|
19
|
+
};
|
|
20
|
+
|
|
14
21
|
const switchColorMode = (): string => {
|
|
15
22
|
const activeIndex = modes.indexOf(activeColorMode);
|
|
16
23
|
const mode = activeIndex < modes.length - 1 ? modes[activeIndex + 1] : modes[0];
|
|
@@ -22,12 +29,13 @@ export const useColorSwitcher = () => {
|
|
|
22
29
|
});
|
|
23
30
|
telemetry.send('color_mode_switched', { from: activeColorMode, to: mode });
|
|
24
31
|
|
|
32
|
+
setActiveColorMode(mode);
|
|
25
33
|
return mode;
|
|
26
34
|
};
|
|
27
35
|
|
|
28
36
|
return {
|
|
29
37
|
isSwitcherHidden: colorMode?.hide,
|
|
30
|
-
|
|
38
|
+
initActiveColorMode,
|
|
31
39
|
switchColorMode,
|
|
32
40
|
activeColorMode,
|
|
33
41
|
};
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { UiAccessibleConfig } from '@redocly/theme/config';
|
|
4
4
|
|
|
5
5
|
import { ThemeDataContext } from '@redocly/theme/core/contexts';
|
|
6
6
|
|
|
7
|
+
// TODO: rename and additionally export as alias for backward compatibility
|
|
7
8
|
export function useThemeConfig<T extends Record<string, unknown>>(
|
|
8
9
|
useProductConfig: boolean = true,
|
|
9
|
-
): T & NonNullable<
|
|
10
|
+
): T & NonNullable<UiAccessibleConfig> {
|
|
10
11
|
const context = useContext(ThemeDataContext);
|
|
11
12
|
|
|
12
13
|
if (!context) {
|
|
13
14
|
return {} as T;
|
|
14
15
|
}
|
|
15
|
-
const {
|
|
16
|
+
const { config, hooks } = context;
|
|
16
17
|
const { useCurrentProduct } = hooks;
|
|
17
18
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
18
19
|
const currentProduct = useCurrentProduct();
|
|
19
20
|
|
|
20
|
-
const
|
|
21
|
-
useProductConfig && currentProduct?.
|
|
21
|
+
const mergedConfig =
|
|
22
|
+
useProductConfig && currentProduct?.configOverride
|
|
22
23
|
? {
|
|
23
|
-
...
|
|
24
|
-
...currentProduct.
|
|
24
|
+
...config,
|
|
25
|
+
...currentProduct.configOverride,
|
|
25
26
|
// Do not override analytics config from product
|
|
26
|
-
analytics:
|
|
27
|
+
analytics: config.analytics,
|
|
27
28
|
}
|
|
28
|
-
:
|
|
29
|
+
: config;
|
|
29
30
|
|
|
30
|
-
return
|
|
31
|
+
return mergedConfig as T;
|
|
31
32
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useLocation } from 'react-router-dom';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { UiAccessibleConfig } from '@redocly/theme/config';
|
|
5
5
|
import type { MdHeading, FeedbackProps } from '@redocly/theme/core/types';
|
|
6
6
|
|
|
7
7
|
import { useThemeConfig, useThemeHooks } from '@redocly/theme/core/hooks';
|
|
@@ -13,7 +13,7 @@ import { IS_BROWSER, onDocumentReady, extendDetailsBehaviour } from '@redocly/th
|
|
|
13
13
|
|
|
14
14
|
type MarkdownTemplateProps = {
|
|
15
15
|
pageProps: {
|
|
16
|
-
frontmatter?:
|
|
16
|
+
frontmatter?: UiAccessibleConfig;
|
|
17
17
|
headings?: (MdHeading | null)[];
|
|
18
18
|
editPage?: { to: string };
|
|
19
19
|
lastModified?: string | null;
|
|
@@ -43,7 +43,7 @@ export default function ({ pageProps, children }: React.PropsWithChildren<Markdo
|
|
|
43
43
|
<TableOfContent headings={pageProps.headings} contentWrapper={wrapperElement} />
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
const { type, settings, hide } = (pageProps.frontmatter?.
|
|
46
|
+
const { type, settings, hide } = (pageProps.frontmatter?.feedback as FeedbackProps) || {};
|
|
47
47
|
const feedback = <Feedback type={type} hide={hide} settings={settings} path={pathname} />;
|
|
48
48
|
|
|
49
49
|
const documentationLayoutProps = {
|
package/src/core/types/filter.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ResolvedFilter } from '@redocly/theme/core/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RedoclyConfig } from '@redocly/config';
|
|
3
3
|
|
|
4
4
|
export type FilterProps = {
|
|
5
5
|
filter: ResolvedFilter & { selectedOptions: any };
|
|
6
|
-
filterValuesCasing?: NonNullable<
|
|
6
|
+
filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export type FilterTypes = NonNullable<FilterProps['filter']['type']>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
import { getCssColorVariable } from '@redocly/theme/core/utils';
|
|
7
|
+
|
|
8
|
+
const Icon = (props: IconProps) => (
|
|
9
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="none" {...props}>
|
|
10
|
+
<g>
|
|
11
|
+
<path d="M7 0.875C3.5875 0.875 0.875 3.5875 0.875 7C0.875 10.4125 3.5875 13.125 7 13.125C10.4125 13.125 13.125 10.4125 13.125 7C13.125 3.5875 10.4125 0.875 7 0.875ZM7 12.25C4.1125 12.25 1.75 9.8875 1.75 7C1.75 4.1125 4.1125 1.75 7 1.75C9.8875 1.75 12.25 4.1125 12.25 7C12.25 9.8875 9.8875 12.25 7 12.25Z" />
|
|
12
|
+
<path d="M9.3625 10.0625L7 7.7L4.6375 10.0625L3.9375 9.3625L6.3 7L3.9375 4.6375L4.6375 3.9375L7 6.3L9.3625 3.9375L10.0625 4.6375L7.7 7L10.0625 9.3625L9.3625 10.0625Z" />
|
|
13
|
+
</g>
|
|
14
|
+
</svg>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const CloseOutlineIcon = styled(Icon).attrs(() => ({
|
|
18
|
+
'data-component-name': 'icons/CloseOutlineIcon/CloseOutlineIcon',
|
|
19
|
+
}))<IconProps>`
|
|
20
|
+
path {
|
|
21
|
+
fill: ${({ color }) => getCssColorVariable(color)};
|
|
22
|
+
}
|
|
23
|
+
height: ${({ size }) => size || '16px'};
|
|
24
|
+
width: ${({ size }) => size || '16px'};
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
import { getCssColorVariable } from '@redocly/theme/core/utils';
|
|
7
|
+
|
|
8
|
+
const Icon = (props: IconProps) => (
|
|
9
|
+
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
10
|
+
<path d="M15 11.9999H13V9.99993H12V11.9999H10V12.9999H12V14.9999H13V12.9999H15V11.9999Z" />
|
|
11
|
+
<path d="M8 13.9999H4V1.99993H8V4.99993C8.00077 5.26491 8.10637 5.51882 8.29374 5.70619C8.48111 5.89356 8.73502 5.99916 9 5.99993H12V7.99993H13V4.99993C13.0018 4.93421 12.9893 4.86889 12.9634 4.80847C12.9375 4.74804 12.8988 4.69395 12.85 4.64993L9.35 1.14993C9.30599 1.10109 9.2519 1.06239 9.19147 1.03649C9.13104 1.01059 9.06572 0.99812 9 0.999928H4C3.73502 1.00069 3.48111 1.1063 3.29374 1.29367C3.10637 1.48104 3.00077 1.73495 3 1.99993V13.9999C3.00077 14.2649 3.10637 14.5188 3.29374 14.7062C3.48111 14.8936 3.73502 14.9992 4 14.9999H8V13.9999ZM9 2.19993L11.8 4.99993H9V2.19993Z" />
|
|
12
|
+
</svg>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const DocumentAddIcon = styled(Icon).attrs(() => ({
|
|
16
|
+
'data-component-name': 'icons/DocumentAddIcon/DocumentAddIcon',
|
|
17
|
+
}))<IconProps>`
|
|
18
|
+
path {
|
|
19
|
+
fill: ${({ color }) => getCssColorVariable(color)};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
height: ${({ size }) => size || '16px'};
|
|
23
|
+
width: ${({ size }) => size || '16px'};
|
|
24
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
import { getCssColorVariable } from '@redocly/theme/core/utils';
|
|
7
|
+
|
|
8
|
+
const Icon = (props: IconProps) => (
|
|
9
|
+
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
10
|
+
<path d="M13 12V14H3V12H2V14L2.0038 13.9976C2.00333 14.1288 2.02873 14.2589 2.07854 14.3803C2.12836 14.5017 2.20163 14.6121 2.29414 14.7052C2.38666 14.7983 2.49662 14.8723 2.61774 14.9229C2.73885 14.9734 2.86875 14.9997 3 15H13C13.2652 15 13.5196 14.8946 13.7071 14.7071C13.8946 14.5196 14 14.2652 14 14V12H13Z" />
|
|
11
|
+
<path d="M3 6L3.7055 6.7025L7.5 2.9125V12H8.5V2.9125L12.2955 6.7025L13 6L8 1L3 6Z" />
|
|
12
|
+
</svg>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const ExportIcon = styled(Icon).attrs(() => ({
|
|
16
|
+
'data-component-name': 'icons/ExportIcon/ExportIcon',
|
|
17
|
+
}))<IconProps>`
|
|
18
|
+
path {
|
|
19
|
+
fill: ${({ color }) => getCssColorVariable(color)};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
height: ${({ size }) => size || '16px'};
|
|
23
|
+
width: ${({ size }) => size || '16px'};
|
|
24
|
+
`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
import { getCssColorVariable } from '@redocly/theme/core/utils';
|
|
7
|
+
|
|
8
|
+
const Icon = (props: IconProps) => (
|
|
9
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" fill="none" {...props}>
|
|
10
|
+
<path d="M4.88688 2.625L6.38313 4.11688L6.63688 4.375H12.25V11.375H1.75V2.625H4.88688ZM4.88688 1.75H1.75C1.51794 1.75 1.29538 1.84219 1.13128 2.00628C0.967187 2.17038 0.875 2.39294 0.875 2.625V11.375C0.875 11.6071 0.967187 11.8296 1.13128 11.9937C1.29538 12.1578 1.51794 12.25 1.75 12.25H12.25C12.4821 12.25 12.7046 12.1578 12.8687 11.9937C13.0328 11.8296 13.125 11.6071 13.125 11.375V4.375C13.125 4.14294 13.0328 3.92038 12.8687 3.75628C12.7046 3.59219 12.4821 3.5 12.25 3.5H7L5.50813 2.00813C5.42672 1.92624 5.32992 1.86127 5.2233 1.81697C5.11667 1.77267 5.00234 1.74991 4.88688 1.75Z" />
|
|
11
|
+
</svg>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const FolderIcon = styled(Icon).attrs(() => ({
|
|
15
|
+
'data-component-name': 'icons/FolderIcon/FolderIcon',
|
|
16
|
+
}))<IconProps>`
|
|
17
|
+
path {
|
|
18
|
+
fill: ${({ color }) => getCssColorVariable(color)};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
height: ${({ size }) => size || '16px'};
|
|
22
|
+
width: ${({ size }) => size || '16px'};
|
|
23
|
+
`;
|
package/src/index.ts
CHANGED
|
@@ -147,9 +147,11 @@ export * from '@redocly/theme/icons/CleanIcon/CleanIcon';
|
|
|
147
147
|
export * from '@redocly/theme/icons/DeselectIcon/DeselectIcon';
|
|
148
148
|
export * from '@redocly/theme/icons/FileStorageIcon/FileStorageIcon';
|
|
149
149
|
export * from '@redocly/theme/icons/FolderAddIcon/FolderAddIcon';
|
|
150
|
+
export * from '@redocly/theme/icons/FolderIcon/FolderIcon';
|
|
150
151
|
export * from '@redocly/theme/icons/FolderMoveToIcon/FolderMoveToIcon';
|
|
151
152
|
export * from '@redocly/theme/icons/SelectIcon/SelectIcon';
|
|
152
153
|
export * from '@redocly/theme/icons/CloseIcon/CloseIcon';
|
|
154
|
+
export * from '@redocly/theme/icons/CloseOutlineIcon/CloseOutlineIcon';
|
|
153
155
|
export * from '@redocly/theme/icons/CloseFilledIcon/CloseFilledIcon';
|
|
154
156
|
export * from '@redocly/theme/icons/LogoutIcon/LogoutIcon';
|
|
155
157
|
export * from '@redocly/theme/icons/CheckboxIcon/CheckboxIcon';
|
|
@@ -160,6 +162,7 @@ export * from '@redocly/theme/icons/DataFormatIcon/DataFormatIcon';
|
|
|
160
162
|
export * from '@redocly/theme/icons/Spinner/Spinner';
|
|
161
163
|
export * from '@redocly/theme/icons/CheckmarkIcon/CheckmarkIcon';
|
|
162
164
|
export * from '@redocly/theme/icons/DownloadIcon/DownloadIcon';
|
|
165
|
+
export * from '@redocly/theme/icons/DocumentAddIcon/DocumentAddIcon';
|
|
163
166
|
export * from '@redocly/theme/icons/EmailIcon/EmailIcon';
|
|
164
167
|
export * from '@redocly/theme/icons/SaveIcon/SaveIcon';
|
|
165
168
|
export * from '@redocly/theme/icons/CloudUploadIcon/CloudUploadIcon';
|
|
@@ -222,6 +225,7 @@ export * from '@redocly/theme/icons/SubtractIcon/SubtractIcon';
|
|
|
222
225
|
export * from '@redocly/theme/icons/PlusCustomIcon/PlusCustomIcon';
|
|
223
226
|
export * from '@redocly/theme/icons/CharacterIcon/CharacterIcon';
|
|
224
227
|
export * from '@redocly/theme/icons/FileIcon/FileIcon';
|
|
228
|
+
export * from '@redocly/theme/icons/ExportIcon/ExportIcon';
|
|
225
229
|
/* Layouts */
|
|
226
230
|
export * from '@redocly/theme/layouts/RootLayout';
|
|
227
231
|
export * from '@redocly/theme/layouts/PageLayout';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import markdoc from '@markdoc/markdoc';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { RedoclyConfig } from '@redocly/theme/config';
|
|
4
4
|
import type { Config } from '@markdoc/markdoc';
|
|
5
5
|
import type { MarkdocSchemaWrapper } from '@redocly/theme/markdoc/tags/types';
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ export const partial: MarkdocSchemaWrapper = {
|
|
|
14
14
|
...markdoc.tags.partial.attributes,
|
|
15
15
|
file: { type: RelativePath },
|
|
16
16
|
},
|
|
17
|
-
validate(node, config: Config & { themeConfig:
|
|
17
|
+
validate(node, config: Config & { themeConfig: RedoclyConfig['markdown'] }) {
|
|
18
18
|
const folders = (config.themeConfig?.partialsFolders || []).map(addTrailingSlash);
|
|
19
19
|
if (!folders.length) {
|
|
20
20
|
return [
|
package/src/plugin.ts
ADDED