Skip to content

Commit 735e2a1

Browse files
committed
feat(feedback): Add more labels so people can configure Highlight and Hide labels
1 parent 3e58e31 commit 735e2a1

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

packages/core/src/types-hoist/feedback/config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ export interface FeedbackTextConfiguration {
176176
* The label for the button that removes a screenshot and hides the image editor
177177
*/
178178
removeScreenshotButtonLabel: string;
179+
180+
/**
181+
* The label for the button that highlights portions ofthe screenshot
182+
*/
183+
highlightToolText: string;
184+
185+
/**
186+
* The label for the button that hides portions of the screenshot
187+
*/
188+
hideToolText: string;
189+
190+
/**
191+
* The label for the button that removed a highlight/hidden section of the screenshot.
192+
*/
193+
removeHighlightText: string;
179194
}
180195

181196
/**

packages/feedback/src/constants/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export const SUCCESS_MESSAGE_TEXT = 'Thank you for your report!';
2222
export const IS_REQUIRED_LABEL = '(required)';
2323
export const ADD_SCREENSHOT_LABEL = 'Add a screenshot';
2424
export const REMOVE_SCREENSHOT_LABEL = 'Remove screenshot';
25+
export const HIGHLIGHT_TOOL_TEXT = 'Highlight';
26+
export const HIDE_TOOL_TEXT = 'Hide';
27+
export const REMOVE_HIGHLIGHT_TEXT = 'Remove';
2528

2629
export const FEEDBACK_WIDGET_SOURCE = 'widget';
2730
export const FEEDBACK_API_SOURCE = 'api';

packages/feedback/src/core/integration.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ import {
1414
EMAIL_LABEL,
1515
EMAIL_PLACEHOLDER,
1616
FORM_TITLE,
17+
HIDE_TOOL_TEXT,
18+
HIGHLIGHT_TOOL_TEXT,
1719
IS_REQUIRED_LABEL,
1820
MESSAGE_LABEL,
1921
MESSAGE_PLACEHOLDER,
2022
NAME_LABEL,
2123
NAME_PLACEHOLDER,
24+
REMOVE_HIGHLIGHT_TEXT,
2225
REMOVE_SCREENSHOT_LABEL,
2326
SUBMIT_BUTTON_LABEL,
2427
SUCCESS_MESSAGE_TEXT,
@@ -110,6 +113,9 @@ export const buildFeedbackIntegration = ({
110113
successMessageText = SUCCESS_MESSAGE_TEXT,
111114
triggerLabel = TRIGGER_LABEL,
112115
triggerAriaLabel = '',
116+
highlightToolText = HIGHLIGHT_TOOL_TEXT,
117+
hideToolText = HIDE_TOOL_TEXT,
118+
removeHighlightText = REMOVE_HIGHLIGHT_TEXT,
113119

114120
// FeedbackCallbacks
115121
onFormOpen,
@@ -152,6 +158,9 @@ export const buildFeedbackIntegration = ({
152158
isRequiredLabel,
153159
addScreenshotButtonLabel,
154160
removeScreenshotButtonLabel,
161+
highlightToolText,
162+
hideToolText,
163+
removeHighlightText,
155164

156165
onFormClose,
157166
onFormOpen,

packages/feedback/src/screenshot/components/ScreenshotEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export function ScreenshotEditorFactory({
310310
}}
311311
>
312312
<button
313-
aria-label="Remove"
313+
aria-label={options.removeHighlightText}
314314
onClick={deleteRect(index)}
315315
onMouseDown={handleStopPropagation}
316316
onMouseUp={handleStopPropagation}
@@ -323,7 +323,7 @@ export function ScreenshotEditorFactory({
323323
</div>
324324
</div>
325325
</div>
326-
<Toolbar action={action} setAction={setAction} />
326+
<Toolbar options={options} action={action} setAction={setAction} />
327327
</div>
328328
);
329329
};

packages/feedback/src/screenshot/components/Toolbar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { h as hType, VNode } from 'preact';
22
import type * as Hooks from 'preact/hooks';
3+
import type { FeedbackInternalOptions } from '@sentry/core';
34

45
interface FactoryParams {
56
h: typeof hType;
@@ -11,9 +12,11 @@ export default function ToolbarFactory({
1112
return function Toolbar({
1213
action,
1314
setAction,
15+
options,
1416
}: {
1517
action: 'highlight' | 'hide' | '';
1618
setAction: Hooks.StateUpdater<'highlight' | 'hide' | ''>;
19+
options: FeedbackInternalOptions;
1720
}): VNode {
1821
return (
1922
<div class="editor__tool-container">
@@ -25,7 +28,7 @@ export default function ToolbarFactory({
2528
setAction(action === 'highlight' ? '' : 'highlight');
2629
}}
2730
>
28-
Highlight
31+
{options.highlightToolText}
2932
</button>
3033
<button
3134
type="button"
@@ -34,7 +37,7 @@ export default function ToolbarFactory({
3437
setAction(action === 'hide' ? '' : 'hide');
3538
}}
3639
>
37-
Hide
40+
{options.hideToolText}
3841
</button>
3942
</div>
4043
</div>

0 commit comments

Comments
 (0)