Skip to content

Commit 6c3abe2

Browse files
authored
fix(feedback): Improve CSS theme variable names and layout (#11964)
This updates the CSS theme, variable names and also how the css works. The widget is better able to handle cases like: - short desktop window (scrolls form) - phone in portrait (full width if the screen is 600px or less) - phone in landscape (scrolls form) - when screenshots are in use, stick to screen edges I also made it, I think, easier to position the button (aka trigger, aka actor) around the screen. You can override in css `--page-margin: 16px` to dictate the distance from the edge, and override `--inset: auto 0 0 auto;` to position the button in the different corners of the screen. For example, you can put the trigger button on the edge of the screen with something like: ```css #sentry-feedback { --actor-inset: auto 0 calc(50% - var(--header-height)) auto; } ``` Docs are updated in getsentry/sentry-docs#9961 to reflect the changed config/variable names too. Some samples of different situations: | Desc | Img | | --- | --- | | Normal | ![normal](https://github.com/getsentry/sentry-javascript/assets/187460/9223cf1f-9b4b-4bdc-b35a-65ccded71540) | Short Window | ![short window](https://github.com/getsentry/sentry-javascript/assets/187460/5749a07a-ccb6-4c3c-909e-712cf5172f11) | Screenshot editor | ![screenshot](https://github.com/getsentry/sentry-javascript/assets/187460/3a3bbbd0-c982-4d23-b0cf-d6f96ad2a7d1) | Mobile landscape | ![mobile landscape](https://github.com/getsentry/sentry-javascript/assets/187460/aee7ca1f-c6a1-4555-9b07-0ff75aad93e2) | Mobile portrait | ![mobile portrait](https://github.com/getsentry/sentry-javascript/assets/187460/c7c08261-8343-4498-9084-5432c6f1c60e) | Override Color | ![colors override](https://github.com/getsentry/sentry-javascript/assets/187460/99d2ae92-58a0-49f0-982c-95b3e312a694)
1 parent 9f19754 commit 6c3abe2

File tree

9 files changed

+236
-208
lines changed

9 files changed

+236
-208
lines changed
Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,58 @@
1-
const LIGHT_BACKGROUND = '#ffffff';
21
const INHERIT = 'inherit';
3-
const SUBMIT_COLOR = 'rgba(108, 95, 199, 1)';
2+
const PURPLE = 'rgba(88, 74, 192, 1)';
3+
const PURPLE_HOVER = 'rgba(108, 95, 199, 1)';
44

55
export const LIGHT_THEME = {
6-
fontFamily: "system-ui, 'Helvetica Neue', Arial, sans-serif",
7-
fontSize: '14px',
8-
96
foreground: '#2b2233',
10-
background: LIGHT_BACKGROUND,
11-
success: '#268d75',
12-
error: '#df3338',
13-
14-
zIndex: 100000,
7+
successForeground: '#268d75',
8+
errorForeground: '#df3338',
9+
background: '#ffffff',
1510
border: '1.5px solid rgba(41, 35, 47, 0.13)',
1611
boxShadow: '0px 4px 24px 0px rgba(43, 34, 51, 0.12)',
1712

18-
backgroundHover: '#f6f6f7',
19-
borderRadius: '25px',
20-
21-
formBorderRadius: '20px',
22-
formContentBorderRadius: '6px',
23-
24-
submitForeground: LIGHT_BACKGROUND,
25-
submitBackground: 'rgba(88, 74, 192, 1)',
26-
submitForegroundHover: LIGHT_BACKGROUND,
27-
submitBackgroundHover: SUBMIT_COLOR,
28-
submitBorder: SUBMIT_COLOR,
13+
inputForeground: INHERIT,
14+
inputBackground: INHERIT,
15+
inputBackgroundHover: INHERIT,
16+
inputBackgroundFocus: INHERIT,
17+
inputBorder: 'var(--border)',
18+
inputBorderRadius: '6px',
19+
inputOutlineFocus: PURPLE_HOVER,
20+
21+
buttonForeground: INHERIT,
22+
buttonForegroundHover: INHERIT,
23+
buttonBackground: 'var(--background)',
24+
buttonBackgroundHover: '#f6f6f7',
25+
buttonBorder: 'var(--border)',
26+
buttonOutlineFocus: 'var(--input-outline-focus)',
27+
28+
submitForeground: '#ffffff',
29+
submitForegroundHover: '#ffffff',
30+
submitBackground: PURPLE,
31+
submitBackgroundHover: PURPLE_HOVER,
32+
submitBorder: PURPLE_HOVER,
33+
submitBorderRadius: 'var(--button-border-radius)',
2934
submitOutlineFocus: '#29232f',
3035

31-
cancelForeground: 'var(--foreground)',
32-
cancelBackground: 'transparent',
33-
cancelForegroundHover: 'var(--foreground)',
34-
cancelBackgroundHover: 'var(--background-hover)',
35-
cancelBorder: 'var(--border)',
36-
cancelOutlineFocus: 'var(--input-outline-focus)',
36+
triggerBackground: 'var(--background)',
37+
triggerBackgroundHover: 'var(--button-background-hover)',
38+
triggerBorderRadius: '1.7em/50%',
3739

38-
inputBackground: INHERIT,
39-
inputForeground: INHERIT,
40-
inputBorder: 'var(--border)',
41-
inputOutlineFocus: SUBMIT_COLOR,
40+
dialogBackground: 'var(--background)',
41+
dialogBorderRadius: '20px',
4242
};
4343

4444
export const DEFAULT_THEME = {
4545
light: LIGHT_THEME,
4646
dark: {
4747
...LIGHT_THEME,
4848

49-
background: '#29232f',
50-
backgroundHover: '#352f3b',
5149
foreground: '#ebe6ef',
52-
border: '1.5px solid rgba(235, 230, 239, 0.15)',
50+
successForeground: '#2da98c',
51+
errorForeground: '#f55459',
52+
background: '#29232f',
53+
border: '1.5px solid rgba(235, 230, 239, 0.5)',
54+
boxShadow: '0px 4px 24px 0px rgba(43, 34, 51, 0.12)',
5355

54-
success: '#2da98c',
55-
error: '#f55459',
56+
buttonBackgroundHover: '#352f3b',
5657
},
5758
};

packages/feedback/src/core/components/Actor.css.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function createActorStyles(): HTMLStyleElement {
99
.widget__actor {
1010
position: fixed;
1111
z-index: var(--z-index);
12-
margin: 0;
12+
margin: var(--page-margin);
1313
inset: var(--actor-inset);
1414
1515
display: flex;
@@ -20,14 +20,15 @@ export function createActorStyles(): HTMLStyleElement {
2020
font-family: inherit;
2121
font-size: var(--font-size);
2222
font-weight: 600;
23-
line-height: 16px;
23+
line-height: 1.14em;
2424
text-decoration: none;
2525
26-
background-color: var(--background);
27-
border-radius: var(--border-radius);
26+
background-color: var(--trigger-background);
27+
border-radius: var(--trigger-border-radius);
2828
border: var(--border);
2929
box-shadow: var(--box-shadow);
3030
color: var(--foreground);
31+
fill: var(--foreground);
3132
cursor: pointer;
3233
opacity: 1;
3334
transition: transform 0.2s ease-in-out;
@@ -41,12 +42,12 @@ export function createActorStyles(): HTMLStyleElement {
4142
}
4243
4344
.widget__actor:hover {
44-
background-color: var(--background-hover);
45+
background-color: var(--trigger-background-hover);
4546
}
4647
4748
.widget__actor svg {
48-
width: 16px;
49-
height: 16px;
49+
width: 1.14em;
50+
height: 1.14em;
5051
}
5152
5253
@media (max-width: 600px) {

packages/feedback/src/core/createMainStyles.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,23 @@ import { DOCUMENT } from '../constants';
33

44
function getThemedCssVariables(theme: FeedbackInternalOptions['themeLight']): string {
55
return `
6-
--background: ${theme.background};
7-
--background-hover: ${theme.backgroundHover};
86
--foreground: ${theme.foreground};
9-
--error: ${theme.error};
10-
--success: ${theme.success};
7+
--success-foreground: ${theme.successForeground};
8+
--error-foreground: ${theme.errorForeground};
9+
--background: ${theme.background};
1110
--border: ${theme.border};
12-
--border-radius: ${theme.borderRadius};
1311
--box-shadow: ${theme.boxShadow};
12+
13+
--button-foreground: ${theme.buttonForeground};
14+
--button-foreground-hover: ${theme.buttonForegroundHover};
15+
--button-background: ${theme.buttonBackground};
16+
--button-background-hover: ${theme.buttonBackgroundHover};
17+
--button-border: ${theme.buttonBorder};
18+
--button-outline-focus: ${theme.buttonOutlineFocus};
19+
20+
--trigger-background: ${theme.triggerBackground};
21+
--trigger-background-hover: ${theme.triggerBackgroundHover};
22+
--trigger-border-radius: ${theme.triggerBorderRadius};
1423
`;
1524
}
1625

@@ -21,25 +30,16 @@ export function createMainStyles({ colorScheme, themeDark, themeLight }: Feedbac
2130
const style = DOCUMENT.createElement('style');
2231
style.textContent = `
2332
:host {
24-
--z-index: ${themeLight.zIndex};
25-
--font-family: ${themeLight.fontFamily};
26-
--font-size: ${themeLight.fontSize};
27-
28-
font-family: var(--font-family);
29-
font-size: var(--font-size);
33+
--font-family: system-ui, 'Helvetica Neue', Arial, sans-serif;
34+
--font-size: 14px;
35+
--z-index: 100000;
3036
3137
--page-margin: 16px;
32-
--actor-inset: auto var(--page-margin) var(--page-margin) auto;
38+
--inset: auto 0 0 auto;
39+
--actor-inset: var(--inset);
3340
34-
.brand-link path {
35-
fill: ${colorScheme === 'dark' ? '#fff' : '#362d59'};
36-
}
37-
@media (prefers-color-scheme: dark)
38-
{
39-
path: {
40-
fill: '#fff';
41-
}
42-
}
41+
font-family: var(--font-family);
42+
font-size: var(--font-size);
4343
4444
${getThemedCssVariables(colorScheme === 'dark' ? themeDark : themeLight)}
4545
}

0 commit comments

Comments
 (0)