Skip to content

Commit 6a18b5a

Browse files
committed
clean up css & hide is just black rectangle
1 parent a8c4840 commit 6a18b5a

File tree

2 files changed

+30
-81
lines changed

2 files changed

+30
-81
lines changed

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

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,36 @@ function drawRect(rect: Rect, ctx: CanvasRenderingContext2D, scale: number = 1):
6868
const scaledWidth = rect.width * scale;
6969
const scaledHeight = rect.height * scale;
7070

71-
// creates a shadow around
72-
ctx.shadowColor = 'rgba(0, 0, 0, 0.7)';
73-
ctx.shadowBlur = 50; // Amount of blur for the shadow
74-
7571
switch (rect.action) {
76-
case 'highlight':
72+
case 'highlight': {
73+
// creates a shadow around
74+
ctx.shadowColor = 'rgba(0, 0, 0, 0.7)';
75+
ctx.shadowBlur = 50;
76+
7777
// draws a rectangle first so that the shadow is visible before clearing
7878
ctx.fillStyle = 'rgb(0, 0, 0)';
7979
ctx.fillRect(scaledX, scaledY, scaledWidth, scaledHeight);
80-
8180
ctx.clearRect(scaledX, scaledY, scaledWidth, scaledHeight);
8281

82+
// Disable shadow after the action is drawn
83+
ctx.shadowColor = 'transparent';
84+
ctx.shadowBlur = 0;
85+
86+
// draws outline around rectangle in the same colour as the submit button
87+
let strokeColor;
88+
const sentryFeedback = DOCUMENT.getElementById('sentry-feedback');
89+
if (sentryFeedback) {
90+
const computedStyle = getComputedStyle(sentryFeedback);
91+
strokeColor =
92+
computedStyle.getPropertyValue('--button-primary-background') ||
93+
computedStyle.getPropertyValue('--accent-background');
94+
}
95+
ctx.strokeStyle = strokeColor || 'white';
96+
ctx.lineWidth = 2;
97+
ctx.strokeRect(scaledX + 1, scaledY + 1, scaledWidth - 2, scaledHeight - 2);
98+
8399
break;
100+
}
84101
case 'hide':
85102
ctx.fillStyle = 'rgb(0, 0, 0)';
86103
ctx.fillRect(scaledX, scaledY, scaledWidth, scaledHeight);
@@ -89,22 +106,6 @@ function drawRect(rect: Rect, ctx: CanvasRenderingContext2D, scale: number = 1):
89106
default:
90107
break;
91108
}
92-
93-
// Disable shadow after the action is drawn
94-
ctx.shadowColor = 'transparent';
95-
ctx.shadowBlur = 0;
96-
97-
let strokeColor;
98-
const sentryFeedback = DOCUMENT.getElementById('sentry-feedback');
99-
if (sentryFeedback) {
100-
const computedStyle = getComputedStyle(sentryFeedback);
101-
strokeColor =
102-
computedStyle.getPropertyValue('--button-primary-background') ||
103-
computedStyle.getPropertyValue('--accent-background');
104-
}
105-
ctx.strokeStyle = strokeColor || 'white';
106-
ctx.lineWidth = 2;
107-
ctx.strokeRect(scaledX + 1, scaledY + 1, scaledWidth - 2, scaledHeight - 2);
108109
}
109110

110111
function resizeCanvas(canvas: HTMLCanvasElement, imageDimensions: Rect): void {

packages/feedback/src/screenshot/components/ScreenshotInput.css.ts

Lines changed: 7 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function createScreenshotInputStyles(styleNonce?: string): HTMLStyleEleme
1515
flex-grow: 1;
1616
flex-direction: column;
1717
}
18+
1819
.editor__image-container {
1920
justify-items: center;
2021
padding: 15px;
@@ -39,13 +40,6 @@ export function createScreenshotInputStyles(styleNonce?: string): HTMLStyleEleme
3940
);
4041
}
4142
42-
.editor__annotation {
43-
z-index: 1;
44-
}
45-
.editor__annotation--active {
46-
z-index: 2;
47-
}
48-
4943
.editor__canvas-container {
5044
width: 100%;
5145
height: 100%;
@@ -59,71 +53,22 @@ export function createScreenshotInputStyles(styleNonce?: string): HTMLStyleEleme
5953
object-fit: contain;
6054
position: absolute;
6155
}
56+
6257
.editor__canvas-annotate {
6358
z-index: 2;
6459
}
65-
.editor__crop-container {
66-
custor: auto;
67-
position: absolute;
68-
z-index: 2;
69-
}
70-
.editor__crop-container--inactive {
71-
z-index: 1;
72-
}
73-
.editor__crop-container--move {
74-
cursor: move;
75-
}
76-
77-
.editor__crop-btn-group {
78-
padding: 8px;
79-
gap: 8px;
80-
border-radius: var(--menu-border-radius, 6px);
81-
background: var(--button-background, var(--background));
82-
width: 175px;
83-
position: absolute;
84-
display: none;
85-
}
86-
.editor__crop-btn-group--active {
87-
display: flex;
88-
}
89-
90-
.editor__crop-corner {
91-
width: 30px;
92-
height: 30px;
93-
position: absolute;
94-
background: none;
95-
border: 3px solid #ffffff;
96-
}
9760
98-
.editor__crop-corner--top-left {
99-
cursor: nwse-resize;
100-
border-right: none;
101-
border-bottom: none;
102-
}
103-
.editor__crop-corner--top-right {
104-
cursor: nesw-resize;
105-
border-left: none;
106-
border-bottom: none;
107-
}
108-
.editor__crop-corner--bottom-left {
109-
cursor: nesw-resize;
110-
border-right: none;
111-
border-top: none;
112-
}
113-
.editor__crop-corner--bottom-right {
114-
cursor: nwse-resize;
115-
border-left: none;
116-
border-top: none;
117-
}
11861
.editor__tool-container {
11962
padding-top: 8px;
12063
display: flex;
12164
justify-content: center;
12265
}
66+
12367
.editor__tool-bar {
12468
display: flex;
12569
gap: 8px;
12670
}
71+
12772
.editor__tool {
12873
display: flex;
12974
padding: 8px 12px;
@@ -144,9 +89,11 @@ export function createScreenshotInputStyles(styleNonce?: string): HTMLStyleEleme
14489
position: absolute;
14590
z-index: 2;
14691
}
92+
14793
.editor__rect {
14894
position: absolute;
14995
}
96+
15097
.editor__rect button {
15198
opacity: 0;
15299
position: absolute;
@@ -158,6 +105,7 @@ export function createScreenshotInputStyles(styleNonce?: string): HTMLStyleEleme
158105
border: none;
159106
background: none;
160107
}
108+
161109
.editor__rect:hover button {
162110
opacity: 1;
163111
}

0 commit comments

Comments
 (0)