@redocly/theme 0.40.1 → 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.
Files changed (31) hide show
  1. package/lib/components/ColorModeSwitcher/ColorModeSwitcher.js +3 -3
  2. package/lib/components/Filter/FilterContent.d.ts +2 -2
  3. package/lib/components/Filter/FilterPopover.d.ts +2 -2
  4. package/lib/config.d.ts +2 -2
  5. package/lib/core/contexts/ThemeDataContext.d.ts +2 -2
  6. package/lib/core/hooks/menu/use-mobile-menu-items.js +1 -1
  7. package/lib/core/hooks/menu/use-mobile-menu-levels.js +1 -1
  8. package/lib/core/hooks/search/use-suggested-pages.d.ts +1 -1
  9. package/lib/core/hooks/use-color-switcher.d.ts +1 -2
  10. package/lib/core/hooks/use-color-switcher.js +6 -1
  11. package/lib/core/hooks/use-theme-config.d.ts +2 -2
  12. package/lib/core/hooks/use-theme-config.js +6 -5
  13. package/lib/core/templates/Markdown.d.ts +2 -4
  14. package/lib/core/templates/Markdown.js +2 -2
  15. package/lib/core/types/filter.d.ts +2 -2
  16. package/lib/plugin.d.ts +3 -0
  17. package/lib/plugin.js +7 -0
  18. package/package.json +3 -2
  19. package/src/components/ColorModeSwitcher/ColorModeSwitcher.tsx +3 -3
  20. package/src/components/Filter/FilterContent.tsx +2 -2
  21. package/src/components/Filter/FilterPopover.tsx +2 -2
  22. package/src/config.ts +8 -4
  23. package/src/core/contexts/ThemeDataContext.tsx +2 -2
  24. package/src/core/hooks/menu/use-mobile-menu-items.ts +1 -1
  25. package/src/core/hooks/menu/use-mobile-menu-levels.ts +1 -1
  26. package/src/core/hooks/use-color-switcher.ts +9 -1
  27. package/src/core/hooks/use-theme-config.ts +11 -10
  28. package/src/core/templates/Markdown.tsx +3 -3
  29. package/src/core/types/filter.ts +2 -2
  30. package/src/markdoc/tags/partial.ts +2 -2
  31. 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, setActiveColorMode, switchColorMode, activeColorMode } = (0, hooks_1.useColorSwitcher)();
12
+ const { isSwitcherHidden, initActiveColorMode, switchColorMode, activeColorMode } = (0, hooks_1.useColorSwitcher)();
13
13
  (0, hooks_1.useMount)(() => {
14
- setActiveColorMode(document.documentElement.className);
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: () => setActiveColorMode(switchColorMode()), extraClass: className, variant: "secondary", size: "medium", icon: react_1.default.createElement(ColorModeIcon_1.ColorModeIcon, { mode: activeColorMode }) }));
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
@@ -1,9 +1,9 @@
1
1
  import type { ResolvedFilter } from '../../core/types';
2
- import type { ThemeConfig } from '../../config';
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<ThemeConfig['catalog']>[string]['filterValuesCasing'];
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 { ThemeConfig } from '../../config';
2
+ import type { RedoclyConfig } from '../../config';
3
3
  export type FilterPopoverProps = {
4
4
  onClose: () => void;
5
5
  filters: ResolvedFilter[];
6
- filterValuesCasing?: NonNullable<ThemeConfig['catalog']>[string]['filterValuesCasing'];
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 { ThemeConfig, ProductConfig, CatalogFilterConfig, CatalogConfig, AmplitudeAnalyticsConfig, GoogleAnalyticsConfig, SegmentAnalyticsConfig, RudderstackAnalyticsConfig, GtmAnalyticsConfig, ScorecardConfig, ProductGoogleAnalyticsConfig, ProductThemeOverrideConfig, ThemeUIConfig, ProductUiConfig } from '@redocly/config';
2
- export type { ThemeConfig, ProductConfig, CatalogFilterConfig, CatalogConfig, AmplitudeAnalyticsConfig, GoogleAnalyticsConfig, SegmentAnalyticsConfig, RudderstackAnalyticsConfig, GtmAnalyticsConfig, ScorecardConfig, ProductGoogleAnalyticsConfig, ProductThemeOverrideConfig, ThemeUIConfig, ProductUiConfig, };
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 { ThemeUIConfig } from '../../config';
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
- themeConfig: ThemeUIConfig;
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.themeOverride) === null || _a === void 0 ? void 0 : _a.navbar;
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.themeOverride) === null || _a === void 0 ? void 0 : _a.navbar;
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 = [
@@ -3,4 +3,4 @@ export declare const useSuggestedPages: () => {
3
3
  label?: string | undefined;
4
4
  labelTranslationKey?: string | undefined;
5
5
  page: string;
6
- }[] & any[];
6
+ }[];
@@ -1,7 +1,6 @@
1
- /// <reference types="react" />
2
1
  export declare const useColorSwitcher: () => {
3
2
  isSwitcherHidden: boolean | undefined;
4
- setActiveColorMode: import("react").Dispatch<import("react").SetStateAction<string>>;
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
- setActiveColorMode,
32
+ initActiveColorMode,
28
33
  switchColorMode,
29
34
  activeColorMode,
30
35
  };
@@ -1,2 +1,2 @@
1
- import type { ThemeUIConfig } from '../../config';
2
- export declare function useThemeConfig<T extends Record<string, unknown>>(useProductConfig?: boolean): T & NonNullable<ThemeUIConfig>;
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 { themeConfig, hooks } = context;
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 mergedTheme = useProductConfig && (currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.themeOverride)
16
- ? Object.assign(Object.assign(Object.assign({}, themeConfig), currentProduct.themeOverride), {
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: themeConfig.analytics }) : themeConfig;
19
- return mergedTheme;
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 { ThemeUIConfig } from '../../config';
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, _b;
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 } = ((_b = (_a = pageProps.frontmatter) === null || _a === void 0 ? void 0 : _a.theme) === null || _b === void 0 ? void 0 : _b.feedback) || {};
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 { ThemeConfig } from '../../config';
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<ThemeConfig['catalog']>[string]['filterValuesCasing'];
7
+ filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
8
8
  };
9
9
  export type FilterTypes = NonNullable<FilterProps['filter']['type']>;
@@ -0,0 +1,3 @@
1
+ export default function plugin(): {
2
+ id: string;
3
+ };
package/lib/plugin.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function plugin() {
4
+ return { id: 'default-theme' };
5
+ }
6
+ exports.default = plugin;
7
+ //# sourceMappingURL=plugin.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.40.1",
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.9.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, setActiveColorMode, switchColorMode, activeColorMode } =
12
+ const { isSwitcherHidden, initActiveColorMode, switchColorMode, activeColorMode } =
13
13
  useColorSwitcher();
14
14
 
15
15
  useMount(() => {
16
- setActiveColorMode(document.documentElement.className);
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={() => setActiveColorMode(switchColorMode())}
27
+ onClick={() => switchColorMode()}
28
28
  extraClass={className}
29
29
  variant="secondary"
30
30
  size="medium"
@@ -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 { ThemeConfig } from '@redocly/theme/config';
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<ThemeConfig['catalog']>[string]['filterValuesCasing'];
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 { ThemeConfig } from '@redocly/theme/config';
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<ThemeConfig['catalog']>[string]['filterValuesCasing'];
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 { ThemeUIConfig } from '@redocly/theme/config';
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
- themeConfig: ThemeUIConfig;
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?.themeOverride?.navbar;
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?.themeOverride?.navbar;
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
- setActiveColorMode,
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 { ThemeUIConfig } from '@redocly/theme/config';
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<ThemeUIConfig> {
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 { themeConfig, hooks } = context;
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 mergedTheme =
21
- useProductConfig && currentProduct?.themeOverride
21
+ const mergedConfig =
22
+ useProductConfig && currentProduct?.configOverride
22
23
  ? {
23
- ...themeConfig,
24
- ...currentProduct.themeOverride,
24
+ ...config,
25
+ ...currentProduct.configOverride,
25
26
  // Do not override analytics config from product
26
- analytics: themeConfig.analytics,
27
+ analytics: config.analytics,
27
28
  }
28
- : themeConfig;
29
+ : config;
29
30
 
30
- return mergedTheme as T;
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 { ThemeUIConfig } from '@redocly/theme/config';
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?: { theme?: ThemeUIConfig };
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?.theme?.feedback as FeedbackProps) || {};
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 = {
@@ -1,9 +1,9 @@
1
1
  import type { ResolvedFilter } from '@redocly/theme/core/types';
2
- import type { ThemeConfig } from '@redocly/theme/config';
2
+ import type { RedoclyConfig } from '@redocly/config';
3
3
 
4
4
  export type FilterProps = {
5
5
  filter: ResolvedFilter & { selectedOptions: any };
6
- filterValuesCasing?: NonNullable<ThemeConfig['catalog']>[string]['filterValuesCasing'];
6
+ filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
7
7
  };
8
8
 
9
9
  export type FilterTypes = NonNullable<FilterProps['filter']['type']>;
@@ -1,6 +1,6 @@
1
1
  import markdoc from '@markdoc/markdoc';
2
2
 
3
- import type { ThemeConfig } from '@redocly/theme';
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: ThemeConfig['markdown'] }) {
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
@@ -0,0 +1,3 @@
1
+ export default function plugin() {
2
+ return { id: 'default-theme' };
3
+ }