Skip to content

Commit 78804ae

Browse files
authored
feat(feedback): Iterate on css for better scrolling & resizing when browser is small (#11893)
1 parent 2c161f6 commit 78804ae

File tree

17 files changed

+244
-256
lines changed

17 files changed

+244
-256
lines changed

packages/feedback/src/constants/theme.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,39 @@ export const LIGHT_THEME = {
66
fontFamily: "system-ui, 'Helvetica Neue', Arial, sans-serif",
77
fontSize: '14px',
88

9-
background: LIGHT_BACKGROUND,
10-
backgroundHover: '#f6f6f7',
119
foreground: '#2b2233',
10+
background: LIGHT_BACKGROUND,
11+
success: '#268d75',
12+
error: '#df3338',
13+
14+
zIndex: 100000,
1215
border: '1.5px solid rgba(41, 35, 47, 0.13)',
13-
borderRadius: '25px',
1416
boxShadow: '0px 4px 24px 0px rgba(43, 34, 51, 0.12)',
1517

16-
success: '#268d75',
17-
error: '#df3338',
18+
backgroundHover: '#f6f6f7',
19+
borderRadius: '25px',
1820

21+
formBorderRadius: '20px',
22+
formContentBorderRadius: '6px',
23+
24+
submitForeground: LIGHT_BACKGROUND,
1925
submitBackground: 'rgba(88, 74, 192, 1)',
26+
submitForegroundHover: LIGHT_BACKGROUND,
2027
submitBackgroundHover: SUBMIT_COLOR,
2128
submitBorder: SUBMIT_COLOR,
2229
submitOutlineFocus: '#29232f',
23-
submitForeground: LIGHT_BACKGROUND,
24-
submitForegroundHover: LIGHT_BACKGROUND,
2530

31+
cancelForeground: 'var(--foreground)',
2632
cancelBackground: 'transparent',
33+
cancelForegroundHover: 'var(--foreground)',
2734
cancelBackgroundHover: 'var(--background-hover)',
2835
cancelBorder: 'var(--border)',
2936
cancelOutlineFocus: 'var(--input-outline-focus)',
30-
cancelForeground: 'var(--foreground)',
31-
cancelForegroundHover: 'var(--foreground)',
3237

3338
inputBackground: INHERIT,
3439
inputForeground: INHERIT,
3540
inputBorder: 'var(--border)',
3641
inputOutlineFocus: SUBMIT_COLOR,
37-
38-
formBorderRadius: '20px',
39-
formContentBorderRadius: '6px',
4042
};
4143

4244
export const DEFAULT_THEME = {

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

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,36 @@ export function createActorStyles(): HTMLStyleElement {
88
style.textContent = `
99
.widget__actor {
1010
position: fixed;
11-
left: var(--left);
12-
right: var(--right);
13-
bottom: var(--bottom);
14-
top: var(--top);
1511
z-index: var(--z-index);
16-
17-
line-height: 16px;
12+
margin: 0;
13+
inset: var(--actor-inset);
1814
1915
display: flex;
2016
align-items: center;
2117
gap: 8px;
18+
padding: 16px;
2219
23-
24-
border-radius: var(--border-radius);
25-
cursor: pointer;
2620
font-family: inherit;
2721
font-size: var(--font-size);
2822
font-weight: 600;
29-
padding: 16px;
23+
line-height: 16px;
3024
text-decoration: none;
31-
z-index: 9000;
3225
33-
color: var(--foreground);
3426
background-color: var(--background);
27+
border-radius: var(--border-radius);
3528
border: var(--border);
3629
box-shadow: var(--box-shadow);
30+
color: var(--foreground);
31+
cursor: pointer;
3732
opacity: 1;
38-
transition: opacity 0.1s ease-in-out;
33+
transition: transform 0.2s ease-in-out;
34+
transform: translate(0, 0) scale(1);
35+
}
36+
.widget__actor[aria-hidden="true"] {
37+
opacity: 0;
38+
pointer-events: none;
39+
visibility: hidden;
40+
transform: translate(0, 16px) scale(0.98);
3941
}
4042
4143
.widget__actor:hover {
@@ -47,24 +49,11 @@ export function createActorStyles(): HTMLStyleElement {
4749
height: 16px;
4850
}
4951
50-
.widget__actor--hidden {
51-
opacity: 0;
52-
pointer-events: none;
53-
visibility: hidden;
54-
}
55-
56-
.widget__actor__text {
57-
}
58-
5952
@media (max-width: 600px) {
60-
.widget__actor__text {
53+
.widget__actor span {
6154
display: none;
6255
}
6356
}
64-
65-
.feedback-icon path {
66-
fill: var(--foreground);
67-
}
6857
`;
6958

7059
return style;

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export interface ActorComponent {
1313
appendToDom: () => void;
1414

1515
removeFromDom: () => void;
16+
17+
show: () => void;
18+
19+
hide: () => void;
1620
}
1721

1822
/**
@@ -27,7 +31,6 @@ export function Actor({ buttonLabel, shadow }: ActorProps): ActorComponent {
2731
el.appendChild(FeedbackIcon());
2832
if (buttonLabel) {
2933
const label = DOCUMENT.createElement('span');
30-
label.className = 'widget__actor__text';
3134
label.appendChild(DOCUMENT.createTextNode(buttonLabel));
3235
el.appendChild(label);
3336
}
@@ -44,5 +47,11 @@ export function Actor({ buttonLabel, shadow }: ActorProps): ActorComponent {
4447
shadow.removeChild(el);
4548
shadow.removeChild(style);
4649
},
50+
show(): void {
51+
el.ariaHidden = 'false';
52+
},
53+
hide(): void {
54+
el.ariaHidden = 'true';
55+
},
4756
};
4857
}

packages/feedback/src/core/components/FeedbackIcon.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ export function FeedbackIcon(): SVGElement {
1111
const createElementNS = <K extends keyof SVGElementTagNameMap>(tagName: K): SVGElementTagNameMap[K] =>
1212
WINDOW.document.createElementNS(XMLNS, tagName);
1313
const svg = setAttributesNS(createElementNS('svg'), {
14-
class: 'feedback-icon',
1514
width: `${SIZE}`,
1615
height: `${SIZE}`,
1716
viewBox: `0 0 ${SIZE} ${SIZE}`,
18-
fill: 'none',
17+
fill: 'var(--foreground)',
1918
});
2019

2120
const g = setAttributesNS(createElementNS('g'), {

packages/feedback/src/core/createMainStyles.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,29 @@ export function createMainStyles(
4646
const style = DOCUMENT.createElement('style');
4747
style.textContent = `
4848
:host {
49-
--bottom: 1rem;
50-
--right: 1rem;
51-
--top: auto;
52-
--left: auto;
53-
--z-index: 100000;
49+
--z-index: ${themes.themeLight.zIndex};
5450
--font-family: ${themes.themeLight.fontFamily};
5551
--font-size: ${themes.themeLight.fontSize};
5652
5753
font-family: var(--font-family);
5854
font-size: var(--font-size);
5955
56+
--page-margin: 16px;
57+
--actor-inset: auto var(--page-margin) var(--page-margin) auto;
58+
59+
--dialog-inset: auto var(--page-margin) var(--page-margin) auto;
60+
--dialog-padding: 24px;
61+
62+
.brand-link path {
63+
fill: ${colorScheme === 'dark' ? '#fff' : '#362d59'};
64+
}
65+
@media (prefers-color-scheme: dark)
66+
{
67+
path: {
68+
fill: '#fff';
69+
}
70+
}
71+
6072
${getThemedCssVariables(colorScheme === 'dark' ? themes.themeDark : themes.themeLight)}
6173
}
6274

packages/feedback/src/core/integration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ export const buildFeedbackIntegration = ({
254254
const mergedOptions = mergeOptions(_options, {
255255
...optionOverrides,
256256
onFormOpen() {
257-
actor.removeFromDom();
257+
actor.hide();
258258
},
259259
onFormClose() {
260-
actor.appendToDom();
260+
actor.show();
261261
},
262262
onFormSubmitted() {
263-
actor.appendToDom();
263+
actor.show();
264264
},
265265
});
266266
_attachTo(actor.el, mergedOptions);

0 commit comments

Comments
 (0)