@redocly/theme 0.25.1 → 0.25.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/Catalog/Catalog.js +1 -4
- package/lib/components/CopyButton/CopyButton.js +2 -7
- package/lib/components/EditPageButton/EditPageButton.js +1 -4
- package/lib/components/Feedback/Comment.js +4 -10
- package/lib/components/Feedback/Mood.js +6 -13
- package/lib/components/Feedback/Rating.js +2 -6
- package/lib/components/Feedback/Reasons.js +4 -9
- package/lib/components/Feedback/Sentiment.js +4 -10
- package/lib/components/Feedback/Thumbs.js +2 -8
- package/lib/components/Feedback/useReportDialog.js +3 -8
- package/lib/components/Filter/Filter.js +1 -5
- package/lib/components/Filter/FilterContent.js +2 -6
- package/lib/components/Filter/FilterPopover.js +2 -6
- package/lib/components/Footer/FooterCopyright.js +2 -5
- package/lib/components/LastUpdated/LastUpdated.js +1 -1
- package/lib/components/Menu/hooks/use-mobile-menu-items.js +1 -4
- package/lib/components/Menu/hooks/use-mobile-menu-levels.js +2 -6
- package/lib/components/Menu/utils.d.ts +2 -1
- package/lib/components/Profile/LoginLink.js +2 -5
- package/lib/components/Profile/MobileUserProfile.js +1 -4
- package/lib/components/Profile/UserProfile.js +3 -7
- package/lib/components/Search/CancelSearch.js +1 -4
- package/lib/components/Search/RecentSearches.js +1 -4
- package/lib/components/Search/SearchDialog.js +4 -10
- package/lib/components/Search/SearchTrigger.js +1 -4
- package/lib/components/Search/SuggestedPages.js +1 -4
- package/lib/components/Sidebar/DrilldownMenu.js +2 -5
- package/lib/components/Sidebar/VersionPicker.js +2 -6
- package/lib/components/TableOfContent/TableOfContent.js +1 -4
- package/lib/layouts/Forbidden.js +2 -6
- package/lib/layouts/NotFound.js +2 -6
- package/lib/layouts/OIDCForbidden.js +1 -4
- package/lib/mocks/hooks/index.d.ts +3 -2
- package/lib/mocks/hooks/index.js +3 -4
- package/package.json +2 -2
- package/src/components/Catalog/Catalog.tsx +1 -4
- package/src/components/CopyButton/CopyButton.tsx +3 -8
- package/src/components/EditPageButton/EditPageButton.tsx +2 -5
- package/src/components/Feedback/Comment.tsx +14 -14
- package/src/components/Feedback/Mood.tsx +14 -15
- package/src/components/Feedback/Rating.tsx +4 -8
- package/src/components/Feedback/Reasons.tsx +6 -11
- package/src/components/Feedback/Sentiment.tsx +6 -12
- package/src/components/Feedback/Thumbs.tsx +2 -9
- package/src/components/Feedback/useReportDialog.ts +3 -8
- package/src/components/Filter/Filter.tsx +3 -5
- package/src/components/Filter/FilterContent.tsx +2 -6
- package/src/components/Filter/FilterPopover.tsx +2 -6
- package/src/components/Footer/FooterCopyright.tsx +2 -5
- package/src/components/LastUpdated/LastUpdated.tsx +1 -1
- package/src/components/Menu/hooks/use-mobile-menu-items.ts +1 -5
- package/src/components/Menu/hooks/use-mobile-menu-levels.ts +2 -7
- package/src/components/Menu/utils.ts +2 -1
- package/src/components/Profile/LoginLink.tsx +2 -5
- package/src/components/Profile/MobileUserProfile.tsx +1 -4
- package/src/components/Profile/UserProfile.tsx +5 -8
- package/src/components/Search/CancelSearch.tsx +2 -5
- package/src/components/Search/RecentSearches.tsx +2 -5
- package/src/components/Search/SearchDialog.tsx +8 -15
- package/src/components/Search/SearchTrigger.tsx +3 -5
- package/src/components/Search/SuggestedPages.tsx +2 -6
- package/src/components/Sidebar/DrilldownMenu.tsx +2 -5
- package/src/components/Sidebar/VersionPicker.tsx +3 -7
- package/src/components/TableOfContent/TableOfContent.tsx +2 -5
- package/src/layouts/Forbidden.tsx +4 -13
- package/src/layouts/NotFound.tsx +4 -13
- package/src/layouts/OIDCForbidden.tsx +2 -6
- package/src/mocks/hooks/index.ts +7 -6
|
@@ -36,13 +36,10 @@ const hooks_1 = require("../../mocks/hooks");
|
|
|
36
36
|
function SuggestedPages({ className }) {
|
|
37
37
|
const pages = (0, search_1.useSuggestedPages)();
|
|
38
38
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
39
|
-
const translationKeys = {
|
|
40
|
-
title: 'theme.search.suggested',
|
|
41
|
-
};
|
|
42
39
|
if (!pages.length)
|
|
43
40
|
return null;
|
|
44
41
|
return (React.createElement(Wrapper, { "data-component-name": "Search/SuggestedPages", className: className },
|
|
45
|
-
React.createElement(Title, { "data-translation-key":
|
|
42
|
+
React.createElement(Title, { "data-translation-key": "theme.search.suggested" }, translate('theme.search.suggested', 'Suggested pages')),
|
|
46
43
|
React.createElement(SuggestedItems, null, pages.map((page) => page.link && (React.createElement(Item, { key: page.label },
|
|
47
44
|
React.createElement(PageLink, Object.assign({ to: page.link }, page),
|
|
48
45
|
React.createElement(Group, null,
|
|
@@ -35,16 +35,13 @@ const hooks_1 = require("../../mocks/hooks");
|
|
|
35
35
|
const Menu_1 = require("../../components/Menu");
|
|
36
36
|
function DrilldownMenu({ item, back, prevActiveItem, children, className, }) {
|
|
37
37
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
38
|
-
const translationKeys = {
|
|
39
|
-
backLabel: 'theme.sidebar.menu.backLabel',
|
|
40
|
-
};
|
|
41
38
|
const label = item.label === (prevActiveItem === null || prevActiveItem === void 0 ? void 0 : prevActiveItem.label) || !(prevActiveItem === null || prevActiveItem === void 0 ? void 0 : prevActiveItem.label)
|
|
42
|
-
? translate(
|
|
39
|
+
? translate('theme.sidebar.menu.backLabel', 'Back')
|
|
43
40
|
: prevActiveItem === null || prevActiveItem === void 0 ? void 0 : prevActiveItem.label;
|
|
44
41
|
return (react_1.default.createElement(MenuContainer, { "data-component-name": "Sidebar/DrilldownMenu", className: className },
|
|
45
42
|
react_1.default.createElement(MenuContent, null,
|
|
46
43
|
react_1.default.createElement(MenuWrapper, null,
|
|
47
|
-
react_1.default.createElement(BackButton_1.BackButton, { back: back, "data-translation-key":
|
|
44
|
+
react_1.default.createElement(BackButton_1.BackButton, { back: back, "data-translation-key": "theme.sidebar.menu.backLabel" }, label),
|
|
48
45
|
react_1.default.createElement(Menu_1.MenuLinkItem, { item: item },
|
|
49
46
|
react_1.default.createElement(DrilldownMenuItem_1.DrilldownMenuItem, { item: item }))),
|
|
50
47
|
children)));
|
|
@@ -37,10 +37,6 @@ function VersionPicker(props) {
|
|
|
37
37
|
const themeConfig = (0, hooks_1.useThemeConfig)();
|
|
38
38
|
const { versionPicker } = themeConfig;
|
|
39
39
|
const { translate } = (0, hooks_2.useTranslate)();
|
|
40
|
-
const translationKeys = {
|
|
41
|
-
label: 'theme.versionPicker.label',
|
|
42
|
-
unversioned: 'theme.versionPicker.unversioned',
|
|
43
|
-
};
|
|
44
40
|
const { versions = [], onChange } = props;
|
|
45
41
|
const options = versions.map((version) => {
|
|
46
42
|
return {
|
|
@@ -56,8 +52,8 @@ function VersionPicker(props) {
|
|
|
56
52
|
if (!options.length && !(versionPicker === null || versionPicker === void 0 ? void 0 : versionPicker.showForUnversioned))
|
|
57
53
|
return null;
|
|
58
54
|
return (React.createElement(VersionsPickerWrapper, null,
|
|
59
|
-
React.createElement(VersionPickerLabel, { "data-translation-key":
|
|
60
|
-
React.createElement(exports.VersionPickerSelect, { placeholder: translate(
|
|
55
|
+
React.createElement(VersionPickerLabel, { "data-translation-key": "theme.versionPicker.label" }, translate('theme.versionPicker.label', 'Version:')),
|
|
56
|
+
React.createElement(exports.VersionPickerSelect, { placeholder: translate('theme.versionPicker.unversioned', 'All versions'), disabled: !options.length, options: options, value: value, onChange: onChange })));
|
|
61
57
|
}
|
|
62
58
|
exports.VersionPicker = VersionPicker;
|
|
63
59
|
const VersionPickerLabel = styled_components_1.default.label `
|
|
@@ -44,16 +44,13 @@ function TableOfContent(props) {
|
|
|
44
44
|
const leastDepth = (0, utils_1.getLeastDepth)(displayedHeadings);
|
|
45
45
|
const activeHeadingId = (0, useActiveHeading_1.useActiveHeading)(contentWrapper, (0, utils_1.getDisplayedHeadingsIds)(displayedHeadings));
|
|
46
46
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
47
|
-
const translationKeys = {
|
|
48
|
-
header: 'theme.toc.header',
|
|
49
|
-
};
|
|
50
47
|
if (toc === null || toc === void 0 ? void 0 : toc.hide) {
|
|
51
48
|
return null;
|
|
52
49
|
}
|
|
53
50
|
return (React.createElement(React.Fragment, null,
|
|
54
51
|
React.createElement(TableOfContentMenu, { "data-component-name": "TableOfContent/TableOfContent", className: className },
|
|
55
52
|
React.createElement(TableOfContentItems, { ref: sidebar },
|
|
56
|
-
displayedHeadings.length ? (React.createElement(TocHeader, { "data-translation-key":
|
|
53
|
+
displayedHeadings.length ? (React.createElement(TocHeader, { "data-translation-key": "theme.toc.header" }, translate('theme.toc.header', toc.header || 'On this page'))) : null,
|
|
57
54
|
displayedHeadings.map((heading, idx) => {
|
|
58
55
|
if (!heading) {
|
|
59
56
|
return null;
|
package/lib/layouts/Forbidden.js
CHANGED
|
@@ -10,14 +10,10 @@ const Button_1 = require("../components/Button");
|
|
|
10
10
|
const hooks_1 = require("../mocks/hooks");
|
|
11
11
|
function Forbidden() {
|
|
12
12
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
13
|
-
const translationKeys = {
|
|
14
|
-
title: 'theme.page.forbidden.title',
|
|
15
|
-
homeButton: 'theme.page.homeButton',
|
|
16
|
-
};
|
|
17
13
|
return (react_1.default.createElement(Wrapper, { "data-component-name": "Pages/Forbidden" },
|
|
18
14
|
react_1.default.createElement(Header, null, "403"),
|
|
19
|
-
react_1.default.createElement(Description, { "data-translation-key":
|
|
20
|
-
react_1.default.createElement(HomeButton, { color: "primary", size: "large", to: "/", "data-translation-key":
|
|
15
|
+
react_1.default.createElement(Description, { "data-translation-key": "theme.page.forbidden.title" }, translate('theme.page.forbidden.title', 'Access forbidden')),
|
|
16
|
+
react_1.default.createElement(HomeButton, { color: "primary", size: "large", to: "/", "data-translation-key": "theme.page.homeButton" }, translate('theme.page.homeButton', 'Open Homepage'))));
|
|
21
17
|
}
|
|
22
18
|
exports.Forbidden = Forbidden;
|
|
23
19
|
const Wrapper = styled_components_1.default.div `
|
package/lib/layouts/NotFound.js
CHANGED
|
@@ -10,14 +10,10 @@ const Button_1 = require("../components/Button");
|
|
|
10
10
|
const hooks_1 = require("../mocks/hooks");
|
|
11
11
|
function NotFound() {
|
|
12
12
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
13
|
-
const translationKeys = {
|
|
14
|
-
title: 'theme.page.notFound.title',
|
|
15
|
-
homeButton: 'theme.page.homeButton',
|
|
16
|
-
};
|
|
17
13
|
return (react_1.default.createElement(Wrapper, { "data-component-name": "Pages/NotFound" },
|
|
18
14
|
react_1.default.createElement(Header, null, "404"),
|
|
19
|
-
react_1.default.createElement(Description, { "data-translation-key":
|
|
20
|
-
react_1.default.createElement(HomeButton, { color: "primary", size: "large", to: "/", "data-translation-key":
|
|
15
|
+
react_1.default.createElement(Description, { "data-translation-key": "theme.page.notFound.title" }, translate('theme.page.notFound.title', "It looks like you're lost")),
|
|
16
|
+
react_1.default.createElement(HomeButton, { color: "primary", size: "large", to: "/", "data-translation-key": "theme.page.homeButton" }, translate('theme.page.homeButton', 'Open Homepage'))));
|
|
21
17
|
}
|
|
22
18
|
exports.NotFound = NotFound;
|
|
23
19
|
const Wrapper = styled_components_1.default.div `
|
|
@@ -35,9 +35,6 @@ function OIDCForbidden() {
|
|
|
35
35
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
36
36
|
const [searchParams, setSearchParams] = (0, react_router_dom_1.useSearchParams)();
|
|
37
37
|
const [errorDescription, setErrorDescription] = (0, react_1.useState)('');
|
|
38
|
-
const translationKeys = {
|
|
39
|
-
title: 'theme.page.forbidden.title',
|
|
40
|
-
};
|
|
41
38
|
// use whatever you want here
|
|
42
39
|
const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
|
|
43
40
|
const renderText = (text) => text.split(' ').map((part) => URL_REGEX.test(part) ? (react_1.default.createElement(ErrorDescriptionLink, { key: part, href: part },
|
|
@@ -51,7 +48,7 @@ function OIDCForbidden() {
|
|
|
51
48
|
}, [searchParams, setSearchParams]);
|
|
52
49
|
return (react_1.default.createElement(Wrapper, { "data-component-name": "Pages/OIDCForbidden" },
|
|
53
50
|
react_1.default.createElement(Header, null, "403"),
|
|
54
|
-
react_1.default.createElement(Description, { "data-translation-key":
|
|
51
|
+
react_1.default.createElement(Description, { "data-translation-key": "theme.page.forbidden.title" }, translate('theme.page.forbidden.title', 'Access forbidden')),
|
|
55
52
|
errorDescription && react_1.default.createElement(ErrorDescription, null, renderText(errorDescription))));
|
|
56
53
|
}
|
|
57
54
|
exports.OIDCForbidden = OIDCForbidden;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { TFunction } from '@redocly/portal-types';
|
|
1
2
|
import type { CatalogConfig, ProductUiConfig, ThemeUIConfig } from '../../config';
|
|
2
|
-
import type { ResolvedNavItem,
|
|
3
|
+
import type { ResolvedNavItem, Version } from '../../types/portal';
|
|
3
4
|
import type { FilteredCatalog } from '../../types/portal/src/shared/types/catalog';
|
|
4
5
|
interface PageLink {
|
|
5
6
|
label: string;
|
|
@@ -13,7 +14,7 @@ export declare function useSidebarSiblingsData(): {
|
|
|
13
14
|
};
|
|
14
15
|
export declare function usePageSharedData<T = unknown>(_id: string): T;
|
|
15
16
|
export declare function useCatalog(_items: ResolvedNavItem[], _config: CatalogConfig): FilteredCatalog;
|
|
16
|
-
export declare
|
|
17
|
+
export declare const useTranslate: () => {
|
|
17
18
|
translate: TFunction;
|
|
18
19
|
};
|
|
19
20
|
export declare function useI18n(): {
|
package/lib/mocks/hooks/index.js
CHANGED
|
@@ -68,10 +68,9 @@ function useCatalog(_items, _config) {
|
|
|
68
68
|
throw new Error('Mock not implemented yet.');
|
|
69
69
|
}
|
|
70
70
|
exports.useCatalog = useCatalog;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
71
|
+
const useTranslate = () => ({
|
|
72
|
+
translate: (value, options) => (typeof options === 'string' ? options : options === null || options === void 0 ? void 0 : options.defaultValue) || value || '',
|
|
73
|
+
});
|
|
75
74
|
exports.useTranslate = useTranslate;
|
|
76
75
|
function useI18n() {
|
|
77
76
|
const changeLanguage = (...args) => args.value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.2",
|
|
4
4
|
"description": "Shared UI components lib",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"theme",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
82
82
|
"typescript": "^4.8.4",
|
|
83
83
|
"webpack": "^5.72.0",
|
|
84
|
-
"@redocly/portal-types": "1.1.
|
|
84
|
+
"@redocly/portal-types": "1.1.1"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@redocly/ajv": "^8.11.0",
|
|
@@ -26,9 +26,6 @@ export default function Catalog(props: {
|
|
|
26
26
|
|
|
27
27
|
const { filterTerm, setFilterTerm, groups, filters } = useCatalog(items, catalogConfig);
|
|
28
28
|
const [isAddingFilter, setIsAddingFilter] = React.useState(false);
|
|
29
|
-
const translationKeys = {
|
|
30
|
-
addFilter: 'theme.catalog.filters.select.addFilter',
|
|
31
|
-
};
|
|
32
29
|
const { translate } = useTranslate();
|
|
33
30
|
|
|
34
31
|
useModalScrollLock(isAddingFilter);
|
|
@@ -44,7 +41,7 @@ export default function Catalog(props: {
|
|
|
44
41
|
icon={<PlusIcon />}
|
|
45
42
|
onClick={() => setIsAddingFilter(true)}
|
|
46
43
|
>
|
|
47
|
-
{translate(
|
|
44
|
+
{translate('theme.catalog.filters.select.addFilter', 'Add filter')}
|
|
48
45
|
</Button>
|
|
49
46
|
<FilterTags filters={filters} />
|
|
50
47
|
</FilterTagsWrapper>
|
|
@@ -34,11 +34,6 @@ function CopyButtonComponent({
|
|
|
34
34
|
}: CopyButtonProps): JSX.Element {
|
|
35
35
|
const tooltip = useControl();
|
|
36
36
|
const { translate } = useTranslate();
|
|
37
|
-
const translationKeys = {
|
|
38
|
-
buttonText: 'theme.codeSnippet.copy.buttonText',
|
|
39
|
-
tooltipText: 'theme.codeSnippet.copy.tooltipText',
|
|
40
|
-
toasterText: 'theme.codeSnippet.copy.toasterText',
|
|
41
|
-
};
|
|
42
37
|
|
|
43
38
|
const showTooltip = (duration: number = 1500): void => {
|
|
44
39
|
tooltip.handleOpen();
|
|
@@ -59,7 +54,7 @@ function CopyButtonComponent({
|
|
|
59
54
|
return (
|
|
60
55
|
<Tooltip
|
|
61
56
|
className="copy-button"
|
|
62
|
-
tip={translate(
|
|
57
|
+
tip={translate('theme.codeSnippet.copy.buttonText', toasterText || 'Copied!')}
|
|
63
58
|
isOpen={tooltip.isOpened}
|
|
64
59
|
placement={toasterPlacement}
|
|
65
60
|
>
|
|
@@ -67,13 +62,13 @@ function CopyButtonComponent({
|
|
|
67
62
|
onClick={() => copy(toasterDuration)}
|
|
68
63
|
data-cy={dataTestId}
|
|
69
64
|
asIcon={type === 'icon'}
|
|
70
|
-
title={translate(
|
|
65
|
+
title={translate('theme.codeSnippet.copy.tooltipText', tooltipText || 'Copy to clipboard')}
|
|
71
66
|
data-testid={dataTestId}
|
|
72
67
|
>
|
|
73
68
|
{type === 'icon' ? (
|
|
74
69
|
<CopyIcon />
|
|
75
70
|
) : (
|
|
76
|
-
translate(
|
|
71
|
+
translate('theme.codeSnippet.copy.toasterText', buttonText || 'Copy')
|
|
77
72
|
)}
|
|
78
73
|
</CodeBlockControlButton>
|
|
79
74
|
</Tooltip>
|
|
@@ -12,9 +12,6 @@ export interface EditPageButtonProps {
|
|
|
12
12
|
|
|
13
13
|
export const EditPageButton = ({ to }: EditPageButtonProps): JSX.Element => {
|
|
14
14
|
const { translate } = useTranslate();
|
|
15
|
-
const translationKeys = {
|
|
16
|
-
text: 'theme.markdown.editPage.text',
|
|
17
|
-
};
|
|
18
15
|
|
|
19
16
|
return (
|
|
20
17
|
<EditButton
|
|
@@ -23,8 +20,8 @@ export const EditPageButton = ({ to }: EditPageButtonProps): JSX.Element => {
|
|
|
23
20
|
onClick={() => telemetry.send('edit_page_link_clicked', {})}
|
|
24
21
|
>
|
|
25
22
|
<ButtonIcon />
|
|
26
|
-
<ButtonText data-translation-key=
|
|
27
|
-
{translate(
|
|
23
|
+
<ButtonText data-translation-key="theme.markdown.editPage.text">
|
|
24
|
+
{translate('theme.markdown.editPage.text', 'Edit')}
|
|
28
25
|
</ButtonText>
|
|
29
26
|
</EditButton>
|
|
30
27
|
);
|
|
@@ -10,12 +10,6 @@ export const Comment = ({ settings, onSubmit, onCancel, className }: CommentProp
|
|
|
10
10
|
const [text, setText] = React.useState('');
|
|
11
11
|
const [submitValue, setSubmitValue] = React.useState('');
|
|
12
12
|
const { translate } = useTranslate();
|
|
13
|
-
const translationKeys = {
|
|
14
|
-
submitText: 'theme.feedback.settings.comment.submitText',
|
|
15
|
-
label: 'theme.feedback.settings.comment.label',
|
|
16
|
-
send: 'theme.feedback.settings.comment.send',
|
|
17
|
-
cancel: 'theme.feedback.settings.comment.cancel',
|
|
18
|
-
};
|
|
19
13
|
|
|
20
14
|
const send = () => {
|
|
21
15
|
if (!text) return;
|
|
@@ -29,9 +23,9 @@ export const Comment = ({ settings, onSubmit, onCancel, className }: CommentProp
|
|
|
29
23
|
if (submitValue) {
|
|
30
24
|
return (
|
|
31
25
|
<Wrapper className={className}>
|
|
32
|
-
<Label data-translation-key=
|
|
26
|
+
<Label data-translation-key="theme.feedback.settings.comment.submitText">
|
|
33
27
|
{translate(
|
|
34
|
-
|
|
28
|
+
'theme.feedback.settings.comment.submitText',
|
|
35
29
|
submitText || 'Thank you for helping improve our documentation!',
|
|
36
30
|
)}
|
|
37
31
|
</Label>
|
|
@@ -41,17 +35,23 @@ export const Comment = ({ settings, onSubmit, onCancel, className }: CommentProp
|
|
|
41
35
|
|
|
42
36
|
return (
|
|
43
37
|
<Wrapper data-component-name="Feedback/Comment" className={className}>
|
|
44
|
-
<Label data-translation-key=
|
|
45
|
-
{translate(
|
|
38
|
+
<Label data-translation-key="theme.feedback.settings.comment.label">
|
|
39
|
+
{translate(
|
|
40
|
+
'theme.feedback.settings.comment.label',
|
|
41
|
+
label || 'Please share your feedback with us.',
|
|
42
|
+
)}
|
|
46
43
|
</Label>
|
|
47
44
|
<TextArea rows={3} onChange={handleTextAreaChange} />
|
|
48
45
|
<ButtonsContainer>
|
|
49
|
-
<SendButton data-translation-key=
|
|
50
|
-
{translate(
|
|
46
|
+
<SendButton data-translation-key="theme.feedback.settings.comment.send" onClick={send}>
|
|
47
|
+
{translate('theme.feedback.settings.comment.send', 'Send')}
|
|
51
48
|
</SendButton>
|
|
52
49
|
{onCancel && (
|
|
53
|
-
<CancelButton
|
|
54
|
-
|
|
50
|
+
<CancelButton
|
|
51
|
+
data-translation-key="theme.feedback.settings.comment.cancel"
|
|
52
|
+
onClick={onCancel}
|
|
53
|
+
>
|
|
54
|
+
{translate('theme.feedback.settings.comment.cancel', 'Cancel')}
|
|
55
55
|
</CancelButton>
|
|
56
56
|
)}
|
|
57
57
|
</ButtonsContainer>
|
|
@@ -19,13 +19,6 @@ export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
19
19
|
const [comment, setComment] = React.useState('');
|
|
20
20
|
const [reasons, setReasons] = React.useState([] as ReasonsProps['settings']['items']);
|
|
21
21
|
const { translate } = useTranslate();
|
|
22
|
-
const translationKeys = {
|
|
23
|
-
submitText: 'theme.feedback.settings.submitText',
|
|
24
|
-
label: 'theme.feedback.settings.label',
|
|
25
|
-
satisfiedLabel: 'theme.feedback.settings.comment.satisfiedLabel',
|
|
26
|
-
neutralLabel: 'theme.feedback.settings.comment.neutralLabel',
|
|
27
|
-
dissatisfiedLabel: 'theme.feedback.settings.comment.dissatisfiedLabel',
|
|
28
|
-
};
|
|
29
22
|
|
|
30
23
|
if (score && reasonsSettings?.enable && !reasons.length) {
|
|
31
24
|
const { label: reasonsLabel, items, multi } = reasonsSettings;
|
|
@@ -43,21 +36,24 @@ export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
43
36
|
switch (score) {
|
|
44
37
|
case MOOD_STATES.SATISFIED:
|
|
45
38
|
return translate(
|
|
46
|
-
|
|
39
|
+
'theme.feedback.settings.comment.satisfiedLabel',
|
|
47
40
|
commentSettings.satisfiedLabel || 'What was most helpful?',
|
|
48
41
|
);
|
|
49
42
|
case MOOD_STATES.NEUTRAL:
|
|
50
43
|
return translate(
|
|
51
|
-
|
|
44
|
+
'theme.feedback.settings.comment.neutralLabel',
|
|
52
45
|
commentSettings.neutralLabel || 'What can we improve?',
|
|
53
46
|
);
|
|
54
47
|
case MOOD_STATES.DISSATISFIED:
|
|
55
48
|
return translate(
|
|
56
|
-
|
|
49
|
+
'theme.feedback.settings.comment.dissatisfiedLabel',
|
|
57
50
|
commentSettings.dissatisfiedLabel || 'What can we improve?',
|
|
58
51
|
);
|
|
59
52
|
default:
|
|
60
|
-
return translate(
|
|
53
|
+
return translate(
|
|
54
|
+
'theme.feedback.settings.comment.satisfiedLabel',
|
|
55
|
+
'What can we improve?',
|
|
56
|
+
);
|
|
61
57
|
}
|
|
62
58
|
};
|
|
63
59
|
return (
|
|
@@ -81,8 +77,11 @@ export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
81
77
|
|
|
82
78
|
return (
|
|
83
79
|
<Wrapper>
|
|
84
|
-
<Label data-translation-key=
|
|
85
|
-
{translate(
|
|
80
|
+
<Label data-translation-key="theme.feedback.settings.submitText">
|
|
81
|
+
{translate(
|
|
82
|
+
'theme.feedback.settings.submitText',
|
|
83
|
+
submitText || 'Thank you for your feedback!',
|
|
84
|
+
)}
|
|
86
85
|
</Label>
|
|
87
86
|
</Wrapper>
|
|
88
87
|
);
|
|
@@ -90,8 +89,8 @@ export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
90
89
|
|
|
91
90
|
return (
|
|
92
91
|
<Wrapper data-component-name="Feedback/Mood" className={className}>
|
|
93
|
-
<Label data-translation-key=
|
|
94
|
-
{translate(
|
|
92
|
+
<Label data-translation-key="theme.feedback.settings.label">
|
|
93
|
+
{translate('theme.feedback.settings.label', label || 'Was this page helpful?')}
|
|
95
94
|
</Label>
|
|
96
95
|
<Vote
|
|
97
96
|
onClick={() => {
|
|
@@ -23,10 +23,6 @@ export const Rating = ({ settings, onSubmit, className }: RatingProps): JSX.Elem
|
|
|
23
23
|
const [comment, setComment] = React.useState('');
|
|
24
24
|
const [reasons, setReasons] = React.useState([] as ReasonsProps['settings']['items']);
|
|
25
25
|
const { translate } = useTranslate();
|
|
26
|
-
const translationKeys = {
|
|
27
|
-
submitText: 'theme.feedback.settings.submitText',
|
|
28
|
-
label: 'theme.feedback.settings.label',
|
|
29
|
-
};
|
|
30
26
|
const maxRating = max || 5;
|
|
31
27
|
|
|
32
28
|
if (score && reasonsSettings?.enable && !reasons.length) {
|
|
@@ -62,9 +58,9 @@ export const Rating = ({ settings, onSubmit, className }: RatingProps): JSX.Elem
|
|
|
62
58
|
|
|
63
59
|
return (
|
|
64
60
|
<Wrapper>
|
|
65
|
-
<Label data-translation-key=
|
|
61
|
+
<Label data-translation-key="theme.feedback.settings.submitText">
|
|
66
62
|
{translate(
|
|
67
|
-
|
|
63
|
+
'theme.feedback.settings.submitText',
|
|
68
64
|
submitText || 'Thank you for helping improve our documentation!',
|
|
69
65
|
)}
|
|
70
66
|
</Label>
|
|
@@ -74,8 +70,8 @@ export const Rating = ({ settings, onSubmit, className }: RatingProps): JSX.Elem
|
|
|
74
70
|
|
|
75
71
|
return (
|
|
76
72
|
<Wrapper data-component-name="Feedback/Rating" className={className}>
|
|
77
|
-
<Label data-translation-key=
|
|
78
|
-
{translate(
|
|
73
|
+
<Label data-translation-key="theme.feedback.settings.label">
|
|
74
|
+
{translate('theme.feedback.settings.label', label || 'How helpful was this page?')}
|
|
79
75
|
</Label>
|
|
80
76
|
<Stars max={maxRating} onSubmit={setScore} />
|
|
81
77
|
</Wrapper>
|
|
@@ -9,11 +9,6 @@ export const Reasons = ({ settings, onSubmit, className }: ReasonsProps): JSX.El
|
|
|
9
9
|
const { label, multi, buttonText, items = [] } = settings;
|
|
10
10
|
const [checkedState, setCheckedState] = React.useState(new Array(items.length).fill(false));
|
|
11
11
|
const { translate } = useTranslate();
|
|
12
|
-
const translationKeys = {
|
|
13
|
-
label: 'theme.feedback.settings.reasons.label',
|
|
14
|
-
items: 'theme.feedback.settings.reasons.items',
|
|
15
|
-
send: 'theme.feedback.settings.reasons.send',
|
|
16
|
-
};
|
|
17
12
|
|
|
18
13
|
if (!items.length) {
|
|
19
14
|
return <></>;
|
|
@@ -36,12 +31,12 @@ export const Reasons = ({ settings, onSubmit, className }: ReasonsProps): JSX.El
|
|
|
36
31
|
return (
|
|
37
32
|
<Wrapper
|
|
38
33
|
data-component-name="Feedback/Reasons"
|
|
39
|
-
data-translation-key=
|
|
34
|
+
data-translation-key="theme.feedback.settings.reasons.label"
|
|
40
35
|
className={className}
|
|
41
36
|
>
|
|
42
37
|
<Label>
|
|
43
38
|
{translate(
|
|
44
|
-
|
|
39
|
+
'theme.feedback.settings.reasons.label',
|
|
45
40
|
label || 'Which statement describes your thoughts about this page?',
|
|
46
41
|
)}
|
|
47
42
|
</Label>
|
|
@@ -55,16 +50,16 @@ export const Reasons = ({ settings, onSubmit, className }: ReasonsProps): JSX.El
|
|
|
55
50
|
onChange={() => handleOptionChange(idx)}
|
|
56
51
|
/>
|
|
57
52
|
<label
|
|
58
|
-
data-translation-key={
|
|
53
|
+
data-translation-key={`theme.feedback.settings.reasons.items.${idx + 1}`}
|
|
59
54
|
id={reason}
|
|
60
55
|
onClick={() => handleOptionChange(idx)}
|
|
61
56
|
>
|
|
62
|
-
{translate(
|
|
57
|
+
{translate(`theme.feedback.settings.reasons.items.${idx + 1}`, reason)}
|
|
63
58
|
</label>
|
|
64
59
|
</OptionWrapper>
|
|
65
60
|
))}
|
|
66
|
-
<SendButton data-translation-key=
|
|
67
|
-
{translate(
|
|
61
|
+
<SendButton data-translation-key="theme.feedback.settings.reasons.send" onClick={submitForm}>
|
|
62
|
+
{translate('theme.feedback.settings.reasons.send', buttonText || 'Send')}
|
|
68
63
|
</SendButton>
|
|
69
64
|
</Wrapper>
|
|
70
65
|
);
|
|
@@ -13,12 +13,6 @@ export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
13
13
|
const [comment, setComment] = React.useState('');
|
|
14
14
|
const [reasons, setReasons] = React.useState([] as ReasonsProps['settings']['items']);
|
|
15
15
|
const { translate } = useTranslate();
|
|
16
|
-
const translationKeys = {
|
|
17
|
-
submitText: 'theme.feedback.settings.submitText',
|
|
18
|
-
label: 'theme.feedback.settings.label',
|
|
19
|
-
likeLabel: 'theme.feedback.settings.comment.likeLabel',
|
|
20
|
-
dislikeLabel: 'theme.feedback.settings.comment.dislikeLabel',
|
|
21
|
-
};
|
|
22
16
|
|
|
23
17
|
if (score && reasonsSettings?.enable && !reasons.length) {
|
|
24
18
|
const { label: reasonsLabel, items, multi } = reasonsSettings;
|
|
@@ -35,11 +29,11 @@ export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
35
29
|
const commentLabel =
|
|
36
30
|
score === 1
|
|
37
31
|
? translate(
|
|
38
|
-
|
|
32
|
+
'theme.feedback.settings.comment.likeLabel',
|
|
39
33
|
commentSettings.likeLabel || 'What was most helpful?',
|
|
40
34
|
)
|
|
41
35
|
: translate(
|
|
42
|
-
|
|
36
|
+
'theme.feedback.settings.comment.dislikeLabel',
|
|
43
37
|
commentSettings.dislikeLabel || 'What can we improve?',
|
|
44
38
|
);
|
|
45
39
|
return (
|
|
@@ -58,9 +52,9 @@ export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
58
52
|
}
|
|
59
53
|
return (
|
|
60
54
|
<Wrapper>
|
|
61
|
-
<Label data-translation-key=
|
|
55
|
+
<Label data-translation-key="theme.feedback.settings.submitText">
|
|
62
56
|
{translate(
|
|
63
|
-
|
|
57
|
+
'theme.feedback.settings.submitText',
|
|
64
58
|
submitText || 'Thank you for helping improve our documentation!',
|
|
65
59
|
)}
|
|
66
60
|
</Label>
|
|
@@ -70,8 +64,8 @@ export const Sentiment = ({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
70
64
|
|
|
71
65
|
return (
|
|
72
66
|
<Wrapper data-component-name="Feedback/Sentiment" className={className}>
|
|
73
|
-
<Label data-translation-key=
|
|
74
|
-
{translate(
|
|
67
|
+
<Label data-translation-key="theme.feedback.settings.label">
|
|
68
|
+
{translate('theme.feedback.settings.label', label || 'Was this page helpful?')}
|
|
75
69
|
</Label>
|
|
76
70
|
<Vote
|
|
77
71
|
onClick={() => {
|
|
@@ -5,10 +5,6 @@ import { useTranslate } from '@portal/hooks';
|
|
|
5
5
|
|
|
6
6
|
export const ThumbUp = ({ text }: { text?: string }) => {
|
|
7
7
|
const { translate } = useTranslate();
|
|
8
|
-
const translationKeys = {
|
|
9
|
-
thumbUp: 'theme.feedback.sentiment.thumbUp',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
8
|
return (
|
|
13
9
|
<Wrapper style={{ alignItems: 'normal' }}>
|
|
14
10
|
<Icon>
|
|
@@ -50,16 +46,13 @@ export const ThumbUp = ({ text }: { text?: string }) => {
|
|
|
50
46
|
</g>
|
|
51
47
|
</svg>
|
|
52
48
|
</Icon>
|
|
53
|
-
<span>{translate(
|
|
49
|
+
<span>{translate('theme.feedback.sentiment.thumbUp', text || 'Yes')}</span>
|
|
54
50
|
</Wrapper>
|
|
55
51
|
);
|
|
56
52
|
};
|
|
57
53
|
|
|
58
54
|
export const ThumbDown = ({ text }: { text?: string }) => {
|
|
59
55
|
const { translate } = useTranslate();
|
|
60
|
-
const translationKeys = {
|
|
61
|
-
thumbDown: 'theme.feedback.sentiment.thumbDown',
|
|
62
|
-
};
|
|
63
56
|
return (
|
|
64
57
|
<Wrapper style={{ alignItems: 'end' }}>
|
|
65
58
|
<Icon>
|
|
@@ -100,7 +93,7 @@ export const ThumbDown = ({ text }: { text?: string }) => {
|
|
|
100
93
|
</g>
|
|
101
94
|
</svg>
|
|
102
95
|
</Icon>
|
|
103
|
-
<span>{translate(
|
|
96
|
+
<span>{translate('theme.feedback.sentiment.thumbDown', text || 'No')}</span>
|
|
104
97
|
</Wrapper>
|
|
105
98
|
);
|
|
106
99
|
};
|
|
@@ -22,11 +22,6 @@ export function useReportDialog(): Record<string, ReportComponentsProps> {
|
|
|
22
22
|
const isReportButtonShown = report?.hide === false; // TODO: report temporary disabled by default
|
|
23
23
|
const { translate } = useTranslate();
|
|
24
24
|
const { submitFeedback } = useSubmitFeedback();
|
|
25
|
-
const translationKeys = {
|
|
26
|
-
buttonText: 'theme.codeSnippet.report.buttonText',
|
|
27
|
-
tooltipText: 'theme.codeSnippet.report.tooltipText',
|
|
28
|
-
label: 'theme.codeSnippet.report.label',
|
|
29
|
-
};
|
|
30
25
|
|
|
31
26
|
const showReportDialog = () => {
|
|
32
27
|
setIsReportDialogShown(true);
|
|
@@ -36,13 +31,13 @@ export function useReportDialog(): Record<string, ReportComponentsProps> {
|
|
|
36
31
|
};
|
|
37
32
|
const reportButtonProps: ReportButtonProps = {
|
|
38
33
|
onClick: showReportDialog,
|
|
39
|
-
buttonText: translate(
|
|
40
|
-
tooltip: translate(
|
|
34
|
+
buttonText: translate('theme.codeSnippet.report.buttonText', 'Report'),
|
|
35
|
+
tooltip: translate('theme.codeSnippet.report.tooltipText', 'Report a problem'),
|
|
41
36
|
visible: isReportButtonShown,
|
|
42
37
|
};
|
|
43
38
|
const reportDialogProps: Partial<ReportDialogProps> = {
|
|
44
39
|
settings: {
|
|
45
|
-
label: translate(
|
|
40
|
+
label: translate('theme.codeSnippet.report.label', 'What is wrong with this code?'),
|
|
46
41
|
},
|
|
47
42
|
onSubmit: hideReportDialog,
|
|
48
43
|
onCancel: hideReportDialog,
|
|
@@ -16,10 +16,6 @@ export function Filter({
|
|
|
16
16
|
filterValuesCasing?: NonNullable<ThemeConfig['catalog']>[string]['filterValuesCasing'];
|
|
17
17
|
}) {
|
|
18
18
|
const { translate } = useTranslate();
|
|
19
|
-
const translationKeys = {
|
|
20
|
-
selectAll: 'theme.catalog.filters.select.all',
|
|
21
|
-
clear: 'theme.catalog.filters.clear',
|
|
22
|
-
};
|
|
23
19
|
|
|
24
20
|
if (!filter.parentUsed) return null;
|
|
25
21
|
|
|
@@ -34,7 +30,9 @@ export function Filter({
|
|
|
34
30
|
value: '',
|
|
35
31
|
element: (
|
|
36
32
|
<FilterOption key="all" onClick={() => filter.selectOption('')}>
|
|
37
|
-
<FilterOptionLabel>
|
|
33
|
+
<FilterOptionLabel>
|
|
34
|
+
{translate('theme.catalog.filters.select.all', 'All')}
|
|
35
|
+
</FilterOptionLabel>
|
|
38
36
|
<FilterOptionCount>{defaultOptionCount}</FilterOptionCount>
|
|
39
37
|
</FilterOption>
|
|
40
38
|
),
|
|
@@ -26,10 +26,6 @@ export function FilterContent({
|
|
|
26
26
|
filterValuesCasing,
|
|
27
27
|
}: FilterContentProps) {
|
|
28
28
|
const { translate } = useTranslate();
|
|
29
|
-
const translationKeys = {
|
|
30
|
-
placeholder: 'theme.catalog.filters.placeholder',
|
|
31
|
-
clearAll: 'theme.catalog.filters.clearAll',
|
|
32
|
-
};
|
|
33
29
|
|
|
34
30
|
const hasActiveFilters = filters.some((filter) => {
|
|
35
31
|
if (filterTerm) return true;
|
|
@@ -49,7 +45,7 @@ export function FilterContent({
|
|
|
49
45
|
<FilterContentWrapper isMobile={isMobile}>
|
|
50
46
|
<FilterControls>
|
|
51
47
|
<StyledInput
|
|
52
|
-
placeholder={translate(
|
|
48
|
+
placeholder={translate('theme.catalog.filters.placeholder', 'Type to filter...')}
|
|
53
49
|
value={filterTerm}
|
|
54
50
|
onChange={(e) => setFilterTerm(e.target.value)}
|
|
55
51
|
/>
|
|
@@ -66,7 +62,7 @@ export function FilterContent({
|
|
|
66
62
|
{hasActiveFilters && (
|
|
67
63
|
<ActionsContainer>
|
|
68
64
|
<ClearAllButton size="default" variant="outlined" onClick={handleClearAll}>
|
|
69
|
-
{translate(
|
|
65
|
+
{translate('theme.catalog.filters.clearAll', 'Clear all filters')}
|
|
70
66
|
</ClearAllButton>
|
|
71
67
|
</ActionsContainer>
|
|
72
68
|
)}
|