@redocly/theme 0.40.2 → 0.40.4

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.
@@ -10,21 +10,18 @@ const FooterItem_1 = require("../../components/Footer/FooterItem");
10
10
  const utils_1 = require("../../core/utils");
11
11
  const hooks_1 = require("../../core/hooks");
12
12
  const FooterCopyright_1 = require("../../components/Footer/FooterCopyright");
13
- const FooterLogo_1 = require("../../components/Footer/FooterLogo");
14
13
  const FooterColumn_1 = require("../../components/Footer/FooterColumn");
15
14
  function Footer({ className }) {
16
- const { footer, logo } = (0, hooks_1.useThemeConfig)() || {};
17
- const { items, copyrightText, logo: footerLogo } = footer || {};
18
- if (!items || (0, utils_1.isEmptyArray)(items) || (footer === null || footer === void 0 ? void 0 : footer.hide)) {
15
+ const { footer } = (0, hooks_1.useThemeConfig)() || {};
16
+ const { items = [], copyrightText } = footer || {};
17
+ if (((0, utils_1.isEmptyArray)(items) && !copyrightText) || (footer === null || footer === void 0 ? void 0 : footer.hide)) {
19
18
  return null;
20
19
  }
21
20
  const withColumns = items.some((item) => { var _a; return (((_a = item === null || item === void 0 ? void 0 : item.items) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0; });
22
21
  return (react_1.default.createElement(FooterWrapper, { "data-component-name": "Footer/Footer", className: className, withColumns: withColumns },
23
- react_1.default.createElement(FooterColumnsSection, null,
24
- !(footerLogo === null || footerLogo === void 0 ? void 0 : footerLogo.hide) && logo && react_1.default.createElement(FooterLogo_1.FooterLogo, { config: logo }),
25
- withColumns
26
- ? items.map((column, index) => (react_1.default.createElement(FooterColumn_1.FooterColumn, { key: `${column.label}_${index}`, column: column })))
27
- : items.map((item, index) => (react_1.default.createElement(FooterItem_1.FooterItem, { key: index, item: item })))),
22
+ !!items.length && (react_1.default.createElement(FooterColumnsSection, null, withColumns
23
+ ? items.map((column, index) => (react_1.default.createElement(FooterColumn_1.FooterColumn, { key: `${column.label}_${index}`, column: column })))
24
+ : items.map((item, index) => (react_1.default.createElement(FooterItem_1.FooterItem, { key: index, item: item }))))),
28
25
  react_1.default.createElement(FooterCopyrightWrapper, null, copyrightText && react_1.default.createElement(FooterCopyright_1.FooterCopyright, { copyrightText: copyrightText }))));
29
26
  }
30
27
  exports.Footer = Footer;
@@ -46,8 +46,9 @@ function NavbarItem({ navItem, className }) {
46
46
  if (navItem.type !== 'link' && !navItem.items)
47
47
  return null;
48
48
  const item = navItem;
49
+ const normalizedPath = item.link && item.link !== '/' ? (0, utils_1.removeTrailingSlash)(item.link) : item.link;
49
50
  const isActive = pathname ===
50
- (0, utils_1.withPathPrefix)((0, utils_1.getPathnameForLocale)(item.link, defaultLocale, currentLocale, locales));
51
+ (0, utils_1.withPathPrefix)((0, utils_1.getPathnameForLocale)(normalizedPath, defaultLocale, currentLocale, locales));
51
52
  const itemContent = (react_1.default.createElement(NavbarMenuItem, { as: item.link ? Link_1.Link : undefined, active: isActive, className: className, onClick: () => telemetry.send('navbar_menu_item_clicked', { type: item.type }), external: item.external, target: item.target, to: item.link },
52
53
  react_1.default.createElement(NavbarIcon, { url: item.icon }),
53
54
  react_1.default.createElement(NavbarLabel, { "data-translation-key": item.labelTranslationKey }, translate(item.labelTranslationKey, item.label)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.40.2",
3
+ "version": "0.40.4",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -7,7 +7,6 @@ import { FooterItem } from '@redocly/theme/components/Footer/FooterItem';
7
7
  import { breakpoints, isEmptyArray } from '@redocly/theme/core/utils';
8
8
  import { useThemeConfig } from '@redocly/theme/core/hooks';
9
9
  import { FooterCopyright } from '@redocly/theme/components/Footer/FooterCopyright';
10
- import { FooterLogo } from '@redocly/theme/components/Footer/FooterLogo';
11
10
  import { FooterColumn } from '@redocly/theme/components/Footer/FooterColumn';
12
11
 
13
12
  export type FooterProps = {
@@ -15,10 +14,10 @@ export type FooterProps = {
15
14
  };
16
15
 
17
16
  export function Footer({ className }: FooterProps): JSX.Element | null {
18
- const { footer, logo } = useThemeConfig() || {};
19
- const { items, copyrightText, logo: footerLogo } = footer || {};
17
+ const { footer } = useThemeConfig() || {};
18
+ const { items = [], copyrightText } = footer || {};
20
19
 
21
- if (!items || isEmptyArray(items) || footer?.hide) {
20
+ if ((isEmptyArray(items) && !copyrightText) || footer?.hide) {
22
21
  return null;
23
22
  }
24
23
 
@@ -30,16 +29,17 @@ export function Footer({ className }: FooterProps): JSX.Element | null {
30
29
  className={className}
31
30
  withColumns={withColumns}
32
31
  >
33
- <FooterColumnsSection>
34
- {!footerLogo?.hide && logo && <FooterLogo config={logo} />}
35
- {withColumns
36
- ? (items as ResolvedNavItem[]).map((column, index) => (
37
- <FooterColumn key={`${column.label}_${index}`} column={column} />
38
- ))
39
- : (items as ResolvedNavItem[]).map((item, index) => (
40
- <FooterItem key={index} item={item} />
41
- ))}
42
- </FooterColumnsSection>
32
+ {!!items.length && (
33
+ <FooterColumnsSection>
34
+ {withColumns
35
+ ? (items as ResolvedNavItem[]).map((column, index) => (
36
+ <FooterColumn key={`${column.label}_${index}`} column={column} />
37
+ ))
38
+ : (items as ResolvedNavItem[]).map((item, index) => (
39
+ <FooterItem key={index} item={item} />
40
+ ))}
41
+ </FooterColumnsSection>
42
+ )}
43
43
  <FooterCopyrightWrapper>
44
44
  {copyrightText && <FooterCopyright copyrightText={copyrightText} />}
45
45
  </FooterCopyrightWrapper>
@@ -7,7 +7,11 @@ import type { LinkProps } from '@redocly/theme/components/Link/Link';
7
7
 
8
8
  import { DropdownMenu } from '@redocly/theme/components/Dropdown/DropdownMenu';
9
9
  import { DropdownMenuItem } from '@redocly/theme/components/Dropdown/DropdownMenuItem';
10
- import { getPathnameForLocale, withPathPrefix } from '@redocly/theme/core/utils';
10
+ import {
11
+ getPathnameForLocale,
12
+ withPathPrefix,
13
+ removeTrailingSlash,
14
+ } from '@redocly/theme/core/utils';
11
15
  import { useThemeHooks } from '@redocly/theme/core/hooks';
12
16
  import { LaunchIcon } from '@redocly/theme/icons/LaunchIcon/LaunchIcon';
13
17
  import { Link } from '@redocly/theme/components/Link/Link';
@@ -28,10 +32,12 @@ export function NavbarItem({ navItem, className }: NavbarItemProps): JSX.Element
28
32
  if (navItem.type !== 'link' && !navItem.items) return null;
29
33
 
30
34
  const item = navItem as ResolvedNavLinkItem;
35
+ const normalizedPath =
36
+ item.link && item.link !== '/' ? removeTrailingSlash(item.link) : item.link;
31
37
 
32
38
  const isActive =
33
39
  pathname ===
34
- withPathPrefix(getPathnameForLocale(item.link, defaultLocale, currentLocale, locales));
40
+ withPathPrefix(getPathnameForLocale(normalizedPath, defaultLocale, currentLocale, locales));
35
41
 
36
42
  const itemContent = (
37
43
  <NavbarMenuItem