Skip to content

Commit 1d2602c

Browse files
authored
feat(feedback): Simplify public css configuration for feedback (#11985)
1 parent 255bf96 commit 1d2602c

File tree

10 files changed

+142
-333
lines changed

10 files changed

+142
-333
lines changed

packages/feedback/src/constants/index.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { GLOBAL_OBJ } from '@sentry/utils';
22

3-
export { DEFAULT_THEME } from './theme';
4-
53
// exporting a separate copy of `WINDOW` rather than exporting the one from `@sentry/browser`
64
// prevents the browser package from being bundled in the CDN bundle, and avoids a
75
// circular dependency between the browser and feedback packages
@@ -29,5 +27,3 @@ export const FEEDBACK_WIDGET_SOURCE = 'widget';
2927
export const FEEDBACK_API_SOURCE = 'api';
3028

3129
export const SUCCESS_MESSAGE_TIMEOUT = 5000;
32-
33-
export const CROP_COLOR = '#ffffff';

packages/feedback/src/constants/theme.ts

-58
This file was deleted.

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

+8-7
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export function createActorStyles(): HTMLStyleElement {
2323
line-height: 1.14em;
2424
text-decoration: none;
2525
26-
background-color: var(--trigger-background);
27-
border-radius: var(--trigger-border-radius);
28-
border: var(--border);
29-
box-shadow: var(--box-shadow);
30-
color: var(--foreground);
31-
fill: var(--foreground);
26+
background: var(--actor-background, var(--background));
27+
border-radius: var(--actor-border-radius, 1.7em/50%);
28+
border: var(--actor-border, var(--border));
29+
box-shadow: var(--actor-box-shadow, var(--box-shadow));
30+
color: var(--actor-color, var(--foreground));
31+
fill: var(--actor-color, var(--foreground));
3232
cursor: pointer;
3333
opacity: 1;
3434
transition: transform 0.2s ease-in-out;
@@ -42,7 +42,8 @@ export function createActorStyles(): HTMLStyleElement {
4242
}
4343
4444
.widget__actor:hover {
45-
background-color: var(--trigger-background-hover);
45+
background: var(--actor-hover-background, var(--background));
46+
filter: var(--interactive-filter);
4647
}
4748
4849
.widget__actor svg {

packages/feedback/src/core/createMainStyles.ts

+43-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,50 @@
11
import type { FeedbackInternalOptions } from '@sentry/types';
22
import { DOCUMENT } from '../constants';
33

4-
function getThemedCssVariables(theme: FeedbackInternalOptions['themeLight']): string {
4+
const PURPLE = 'rgba(88, 74, 192, 1)';
5+
6+
interface InternalTheme extends NonNullable<FeedbackInternalOptions['themeLight']> {
7+
border: string;
8+
interactiveFilter: string;
9+
}
10+
11+
const DEFAULT_LIGHT: InternalTheme = {
12+
foreground: '#2b2233',
13+
background: '#ffffff',
14+
accentForeground: 'white',
15+
accentBackground: PURPLE,
16+
successColor: '#268d75',
17+
errorColor: '#df3338',
18+
border: '1.5px solid rgba(41, 35, 47, 0.13)',
19+
boxShadow: '0px 4px 24px 0px rgba(43, 34, 51, 0.12)',
20+
outline: '1px auto var(--accent-background)',
21+
interactiveFilter: 'brightness(95%)',
22+
};
23+
const DEFAULT_DARK: InternalTheme = {
24+
foreground: '#ebe6ef',
25+
background: '#29232f',
26+
accentForeground: 'white',
27+
accentBackground: PURPLE,
28+
successColor: '#2da98c',
29+
errorColor: '#f55459',
30+
border: '1.5px solid rgba(41, 35, 47, 0.5)',
31+
boxShadow: '0px 4px 24px 0px rgba(43, 34, 51, 0.12)',
32+
outline: '1px auto var(--accent-background)',
33+
interactiveFilter: 'brightness(150%)',
34+
};
35+
36+
function getThemedCssVariables(theme: InternalTheme): string {
537
return `
638
--foreground: ${theme.foreground};
7-
--success-foreground: ${theme.successForeground};
8-
--error-foreground: ${theme.errorForeground};
939
--background: ${theme.background};
40+
--accent-foreground: ${theme.accentForeground};
41+
--accent-background: ${theme.accentBackground};
42+
--success-color: ${theme.successColor};
43+
--error-color: ${theme.errorColor};
1044
--border: ${theme.border};
1145
--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};
46+
--outline: ${theme.outline};
47+
--interactive-filter: ${theme.interactiveFilter};
2348
`;
2449
}
2550

@@ -41,15 +66,17 @@ export function createMainStyles({ colorScheme, themeDark, themeLight }: Feedbac
4166
font-family: var(--font-family);
4267
font-size: var(--font-size);
4368
44-
${getThemedCssVariables(colorScheme === 'dark' ? themeDark : themeLight)}
69+
${getThemedCssVariables(
70+
colorScheme === 'dark' ? { ...DEFAULT_DARK, ...themeDark } : { ...DEFAULT_LIGHT, ...themeLight },
71+
)}
4572
}
4673
4774
${
4875
colorScheme === 'system'
4976
? `
5077
@media (prefers-color-scheme: dark) {
5178
:host {
52-
${getThemedCssVariables(themeDark)}
79+
${getThemedCssVariables({ ...DEFAULT_DARK, ...themeDark })}
5380
}
5481
}`
5582
: ''

packages/feedback/src/core/integration.ts

+4-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
ADD_SCREENSHOT_LABEL,
1313
CANCEL_BUTTON_LABEL,
1414
CONFIRM_BUTTON_LABEL,
15-
DEFAULT_THEME,
1615
DOCUMENT,
1716
EMAIL_LABEL,
1817
EMAIL_PLACEHOLDER,
@@ -79,8 +78,8 @@ export const buildFeedbackIntegration = ({
7978

8079
// FeedbackThemeConfiguration
8180
colorScheme = 'system',
82-
themeLight,
83-
themeDark,
81+
themeLight = {},
82+
themeDark = {},
8483

8584
// FeedbackTextConfiguration
8685
addScreenshotButtonLabel = ADD_SCREENSHOT_LABEL,
@@ -118,14 +117,8 @@ export const buildFeedbackIntegration = ({
118117
useSentryUser,
119118

120119
colorScheme,
121-
themeDark: {
122-
...DEFAULT_THEME.dark,
123-
...themeDark,
124-
},
125-
themeLight: {
126-
...DEFAULT_THEME.light,
127-
...themeLight,
128-
},
120+
themeDark,
121+
themeLight,
129122

130123
triggerLabel,
131124
cancelButtonLabel,

0 commit comments

Comments
 (0)