@redocly/theme 0.11.4 → 0.12.0

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 (116) hide show
  1. package/lib/I18n/LanguagePicker.d.ts +4 -0
  2. package/lib/I18n/LanguagePicker.js +111 -0
  3. package/lib/I18n/index.d.ts +1 -0
  4. package/lib/I18n/index.js +6 -0
  5. package/lib/components/Cards/Card.js +3 -1
  6. package/lib/components/Catalog/Catalog.js +14 -9
  7. package/lib/components/Catalog/CatalogCard.js +6 -1
  8. package/lib/components/Catalog/useCatalog.js +4 -1
  9. package/lib/components/CodeSample/CodeSample.js +11 -3
  10. package/lib/components/Feedback/Comment.js +12 -4
  11. package/lib/components/Feedback/Rating.js +8 -2
  12. package/lib/components/Feedback/Reasons.js +11 -4
  13. package/lib/components/Feedback/Sentiment.js +12 -4
  14. package/lib/components/Feedback/Thumbs.js +31 -18
  15. package/lib/components/Feedback/useReportDialog.js +8 -2
  16. package/lib/components/Filter/Filter.js +15 -8
  17. package/lib/components/Footer/FooterColumn.js +4 -2
  18. package/lib/components/Footer/FooterCopyright.d.ts +1 -2
  19. package/lib/components/Footer/FooterCopyright.js +6 -1
  20. package/lib/components/LastUpdated/LastUpdated.js +8 -4
  21. package/lib/components/Markdown/MarkdownLayout.js +6 -1
  22. package/lib/components/Markdown/MarkdownWrapper.js +4 -0
  23. package/lib/components/Menu/MenuGroup.js +3 -1
  24. package/lib/components/Menu/MenuItem.js +3 -1
  25. package/lib/components/Navbar/MobileNavbarItem.js +6 -2
  26. package/lib/components/Navbar/Navbar.d.ts +1 -0
  27. package/lib/components/Navbar/Navbar.js +6 -1
  28. package/lib/components/Navbar/NavbarDropdown.js +3 -1
  29. package/lib/components/Navbar/NavbarItem.js +9 -4
  30. package/lib/components/PageNavigation/NextButton.js +7 -2
  31. package/lib/components/PageNavigation/PreviousButton.js +10 -2
  32. package/lib/components/Profile/LoginLink.js +6 -1
  33. package/lib/components/Profile/UserProfileMenu.js +10 -4
  34. package/lib/components/Search/Autocomplete.d.ts +3 -3
  35. package/lib/components/Search/Autocomplete.js +21 -11
  36. package/lib/components/Search/ClearIcon.js +1 -1
  37. package/lib/components/Search/Search.js +6 -4
  38. package/lib/components/Separator/Separator.js +3 -1
  39. package/lib/components/Sidebar/DrilldownMenu.js +6 -1
  40. package/lib/components/Sidebar/DrilldownMenuItem.js +4 -2
  41. package/lib/components/Sidebar/types.d.ts +2 -0
  42. package/lib/components/TableOfContent/TableOfContent.js +6 -1
  43. package/lib/globalStyle.js +7 -0
  44. package/lib/icons/SpinnerIcon/SpinnerIcon.d.ts +8 -0
  45. package/lib/icons/SpinnerIcon/SpinnerIcon.js +32 -0
  46. package/lib/icons/SpinnerIcon/index.d.ts +1 -0
  47. package/lib/icons/SpinnerIcon/index.js +6 -0
  48. package/lib/icons/index.d.ts +1 -0
  49. package/lib/icons/index.js +1 -0
  50. package/lib/index.d.ts +1 -0
  51. package/lib/index.js +1 -0
  52. package/lib/layouts/Forbidden.js +8 -2
  53. package/lib/layouts/NotFound.js +8 -2
  54. package/lib/mocks/hooks/index.d.ts +15 -1
  55. package/lib/mocks/hooks/index.js +19 -1
  56. package/lib/mocks/search.d.ts +1 -0
  57. package/lib/mocks/search.js +1 -0
  58. package/lib/mocks/utils.d.ts +5 -0
  59. package/lib/mocks/utils.js +9 -1
  60. package/lib/types/portal/index.d.ts +1 -0
  61. package/lib/types/portal/index.js +1 -0
  62. package/lib/types/portal/src/shared/types/catalog.d.ts +4 -0
  63. package/lib/types/portal/src/shared/types/nav.d.ts +7 -0
  64. package/package.json +1 -1
  65. package/src/I18n/LanguagePicker.tsx +113 -0
  66. package/src/I18n/index.ts +1 -0
  67. package/src/components/Cards/Card.tsx +5 -1
  68. package/src/components/Catalog/Catalog.tsx +23 -6
  69. package/src/components/Catalog/CatalogCard.tsx +8 -1
  70. package/src/components/Catalog/useCatalog.ts +4 -2
  71. package/src/components/CodeSample/CodeSample.tsx +22 -4
  72. package/src/components/Feedback/Comment.tsx +25 -4
  73. package/src/components/Feedback/Rating.tsx +15 -2
  74. package/src/components/Feedback/Reasons.tsx +23 -5
  75. package/src/components/Feedback/Sentiment.tsx +25 -4
  76. package/src/components/Feedback/Thumbs.tsx +61 -46
  77. package/src/components/Feedback/useReportDialog.ts +11 -2
  78. package/src/components/Filter/Filter.tsx +17 -9
  79. package/src/components/Footer/CustomFooter.tsx +1 -1
  80. package/src/components/Footer/FooterColumn.tsx +5 -3
  81. package/src/components/Footer/FooterCopyright.tsx +12 -3
  82. package/src/components/LastUpdated/LastUpdated.tsx +10 -2
  83. package/src/components/Markdown/MarkdownLayout.tsx +11 -1
  84. package/src/components/Markdown/MarkdownWrapper.tsx +4 -0
  85. package/src/components/Menu/MenuGroup.tsx +4 -1
  86. package/src/components/Menu/MenuItem.tsx +3 -1
  87. package/src/components/Navbar/MobileNavbarItem.tsx +7 -1
  88. package/src/components/Navbar/Navbar.tsx +8 -0
  89. package/src/components/Navbar/NavbarDropdown.tsx +3 -1
  90. package/src/components/Navbar/NavbarItem.tsx +9 -3
  91. package/src/components/PageNavigation/NextButton.tsx +8 -2
  92. package/src/components/PageNavigation/PreviousButton.tsx +11 -2
  93. package/src/components/Profile/LoginLink.tsx +11 -1
  94. package/src/components/Profile/UserProfileMenu.tsx +13 -3
  95. package/src/components/Search/Autocomplete.tsx +31 -17
  96. package/src/components/Search/ClearIcon.tsx +1 -1
  97. package/src/components/Search/Search.tsx +8 -7
  98. package/src/components/Separator/Separator.tsx +4 -1
  99. package/src/components/Sidebar/DrilldownMenu.tsx +8 -1
  100. package/src/components/Sidebar/DrilldownMenuItem.tsx +7 -2
  101. package/src/components/Sidebar/types.ts +2 -0
  102. package/src/components/TableOfContent/TableOfContent.tsx +11 -1
  103. package/src/globalStyle.ts +7 -0
  104. package/src/icons/SpinnerIcon/SpinnerIcon.tsx +42 -0
  105. package/src/icons/SpinnerIcon/index.ts +1 -0
  106. package/src/icons/index.ts +1 -0
  107. package/src/index.ts +1 -0
  108. package/src/layouts/Forbidden.tsx +18 -3
  109. package/src/layouts/NotFound.tsx +17 -3
  110. package/src/mocks/hooks/index.ts +20 -1
  111. package/src/mocks/search.ts +2 -0
  112. package/src/mocks/utils.ts +13 -0
  113. package/src/types/portal/index.ts +1 -0
  114. package/src/types/portal/src/shared/types/catalog.ts +4 -0
  115. package/src/types/portal/src/shared/types/i18n.d.ts +3 -0
  116. package/src/types/portal/src/shared/types/nav.ts +7 -0
@@ -2,14 +2,28 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import { Button } from '@theme/components/Button';
5
+ import { useTranslate } from '@portal/hooks';
5
6
 
6
7
  export function NotFound(): JSX.Element {
8
+ const { translate } = useTranslate();
9
+ const translationKeys = {
10
+ title: 'theme.page.notFound.title',
11
+ homeButton: 'theme.page.homeButton',
12
+ };
13
+
7
14
  return (
8
15
  <Wrapper data-component-name="Pages/NotFound">
9
16
  <Header>404</Header>
10
- <Description>It looks like you&apos;re lost</Description>
11
- <HomeButton color="primary" size="large" to="/">
12
- Open Homepage
17
+ <Description data-translation-key={translationKeys.title}>
18
+ {translate(translationKeys.title, `It looks like you're lost`)}
19
+ </Description>
20
+ <HomeButton
21
+ color="primary"
22
+ size="large"
23
+ to="/"
24
+ data-translation-key={translationKeys.homeButton}
25
+ >
26
+ {translate(translationKeys.homeButton, 'Open Homepage')}
13
27
  </HomeButton>
14
28
  </Wrapper>
15
29
  );
@@ -1,5 +1,5 @@
1
1
  import type { ThemeUIConfig } from '@theme/config';
2
- import type { ResolvedNavItem } from '@theme/types/portal';
2
+ import type { ResolvedNavItem, TFunction } from '@theme/types/portal';
3
3
  import type { CatalogConfig, FilteredCatalog } from '@theme/types/portal/src/shared/types/catalog';
4
4
  interface PageLink {
5
5
  label: string;
@@ -75,4 +75,23 @@ export function useCatalog(_items: ResolvedNavItem[], _config: CatalogConfig): F
75
75
  throw new Error('Mock not implemented yet.');
76
76
  }
77
77
 
78
+ export function useTranslate() {
79
+ const translate: TFunction = (value?: string, options?: { defaultValue: string } | string) =>
80
+ (typeof options === 'string' ? options : options?.defaultValue) || value || '';
81
+ return { translate };
82
+ }
83
+
84
+ export function useI18n() {
85
+ const changeLanguage = (...args: any) => args.value as string;
86
+ return { changeLanguage };
87
+ }
88
+
78
89
  export { useGlobalData } from '../useGlobalData';
90
+
91
+ export function useI18nConfig() {
92
+ return {
93
+ currentLocale: 'en',
94
+ defaultLocale: 'en',
95
+ locales: [{ code: 'en', name: 'en' }],
96
+ };
97
+ }
@@ -22,12 +22,14 @@ export function useFuseSearch(): {
22
22
  query: string;
23
23
  setQuery: (val: string) => void;
24
24
  items: SearchDocument[];
25
+ isLoading: boolean;
25
26
  } {
26
27
  const [query, setQuery] = useState('');
27
28
 
28
29
  return {
29
30
  query,
30
31
  setQuery,
32
+ isLoading: false,
31
33
  items: [
32
34
  {
33
35
  id: '1',
@@ -2,8 +2,21 @@ export function withPathPrefix(link: string): string {
2
2
  return link;
3
3
  }
4
4
 
5
+ export function withoutPathPrefix(link: string): string {
6
+ return link;
7
+ }
8
+
5
9
  export function timeAgo(lastModified: string | Date): string {
6
10
  // should return format(lastModified) in portal
7
11
  const d = new Date(lastModified);
8
12
  return `${d.getDate()}-${d.getMonth() + 1}-${d.getFullYear()}`;
9
13
  }
14
+
15
+ export function getPathnameForLocale(
16
+ pathname: string,
17
+ _defaultLocale: string,
18
+ _newLocale: string,
19
+ _allLocales: { code: string; name: string }[],
20
+ ) {
21
+ return `${pathname}`;
22
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './src/shared/types/nav';
2
+ export * from './src/shared/types/i18n';
2
3
  export type { MdHeading } from './src/shared/types/markdown';
@@ -10,9 +10,11 @@ export type FilteredCatalog = {
10
10
  export type Filter = {
11
11
  type?: 'select' | 'checkboxes';
12
12
  title: string;
13
+ titleTranslationKey?: string;
13
14
  property: string;
14
15
  parentFilter?: string;
15
16
  missingCategoryName?: string;
17
+ missingCategoryNameTranslationKey?: string;
16
18
  options?: string[];
17
19
  };
18
20
 
@@ -24,7 +26,9 @@ export type CatalogConfig = {
24
26
  requiredPermission?: string;
25
27
  separateVersions?: boolean;
26
28
  title?: string;
29
+ titleTranslationKey?: string;
27
30
  description?: string;
31
+ descriptionTranslationKey?: string;
28
32
  };
29
33
 
30
34
  export type ResolvedFilter = Omit<Filter, 'options'> & {
@@ -0,0 +1,3 @@
1
+ export declare interface TFunction {
2
+ (value?: string, options?: string | TOptions): string;
3
+ }
@@ -6,6 +6,7 @@ export type ResolvedNavLinkItem = {
6
6
  metadata?: Record<string, unknown>;
7
7
  link: string;
8
8
  label: string;
9
+ labelTranslationKey?: string;
9
10
  items?: ResolvedNavItem[];
10
11
  sidebar?: ResolvedNavItem[]; // for API catalog it contains the corresponding sidebar first item
11
12
  external?: boolean;
@@ -27,6 +28,7 @@ export type ResolvedNavGroupItem = {
27
28
  metadata?: Record<string, unknown>;
28
29
  link?: string;
29
30
  label?: string;
31
+ labelTranslationKey?: string;
30
32
  items?: ResolvedNavItem[];
31
33
  sidebar?: ResolvedNavItem[]; // for API catalog it contains the corresponding sidebar first item
32
34
  external?: boolean;
@@ -52,6 +54,7 @@ export type ResolvedNavItem =
52
54
  type: 'separator';
53
55
  metadata?: Record<string, unknown>;
54
56
  label?: string;
57
+ labelTranslationKey?: string;
55
58
  routeSlug?: never;
56
59
 
57
60
  version?: string;
@@ -74,6 +77,7 @@ export type ResolvedNavItem =
74
77
  routeSlug?: never;
75
78
 
76
79
  label: string;
80
+ labelTranslationKey?: string;
77
81
  link?: undefined;
78
82
  items?: ResolvedNavItem[]; // for typescript
79
83
  sidebar?: ResolvedNavItem[]; // for typescript
@@ -120,10 +124,13 @@ export type NavItem = {
120
124
  page?: string;
121
125
  directory?: string;
122
126
  group?: string;
127
+ groupTranslationKey?: string;
123
128
  label?: string;
129
+ labelTranslationKey?: string;
124
130
  href?: never;
125
131
  items?: NavItem[];
126
132
  separator?: string;
133
+ separatorTranslationKey?: string;
127
134
  separatorLine?: boolean;
128
135
  version?: string;
129
136
  menuStyle?: MenuStyle;