Skip to content

Commit 998e6c4

Browse files
authored
fix(perf): Improve SlideOverPanel layout (#69523)
- remove border - add a nice box shadow - clarify how the positioning is done - prevent unnecessary scrollbars
1 parent fb15c50 commit 998e6c4

File tree

1 file changed

+52
-20
lines changed

1 file changed

+52
-20
lines changed

static/app/views/starfish/components/slideOverPanel.tsx

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import type {ForwardedRef} from 'react';
22
import {forwardRef, useEffect} from 'react';
33
import isPropValid from '@emotion/is-prop-valid';
4+
import {css} from '@emotion/react';
45
import styled from '@emotion/styled';
56
import {motion} from 'framer-motion';
67

8+
import {space} from 'sentry/styles/space';
9+
710
const PANEL_WIDTH = '50vw';
811
const PANEL_HEIGHT = '50vh';
12+
913
const INITIAL_STYLES = {
1014
bottom: {opacity: 0, x: 0, y: 0},
1115
right: {opacity: 0, x: PANEL_WIDTH, y: 0},
1216
};
17+
1318
const FINAL_STYLES = {
1419
bottom: {opacity: 0, x: 0, y: PANEL_HEIGHT},
1520
right: {opacity: 0, x: PANEL_WIDTH},
@@ -35,6 +40,7 @@ function SlideOverPanel(
3540
}, [collapsed, onOpen]);
3641
const initial = slidePosition ? INITIAL_STYLES[slidePosition] : INITIAL_STYLES.right;
3742
const final = slidePosition ? FINAL_STYLES[slidePosition] : FINAL_STYLES.right;
43+
3844
return (
3945
<_SlideOverPanel
4046
ref={ref}
@@ -61,30 +67,56 @@ const _SlideOverPanel = styled(motion.div, {
6167
collapsed: boolean;
6268
slidePosition?: 'right' | 'bottom';
6369
}>`
64-
${p =>
65-
p.slidePosition === 'bottom'
66-
? `
67-
width: 100%;
68-
height: ${PANEL_HEIGHT};
69-
position: sticky;
70-
border-top: 1px solid ${p.theme.border};
71-
`
72-
: `
73-
width: ${PANEL_WIDTH};
74-
height: 100%;
75-
position: fixed;
76-
top: 0;
77-
border-left: 1px solid ${p.theme.border};
78-
`}
79-
bottom: 0;
70+
position: fixed;
71+
72+
top: ${space(2)};
8073
right: 0;
74+
bottom: ${space(2)};
75+
left: ${space(2)};
76+
77+
overflow: auto;
78+
79+
z-index: ${p => p.theme.zIndex.modal + 1};
80+
81+
box-shadow: ${p => p.theme.dropShadowHeavy};
8182
background: ${p => p.theme.background};
8283
color: ${p => p.theme.textColor};
84+
8385
text-align: left;
84-
z-index: ${p => p.theme.zIndex.sidebar - 1};
86+
87+
@media (min-width: ${p => p.theme.breakpoints.small}) {
88+
${p =>
89+
p.slidePosition === 'bottom'
90+
? css`
91+
position: sticky;
92+
93+
width: 100%;
94+
height: ${PANEL_HEIGHT};
95+
96+
right: 0;
97+
bottom: 0;
98+
left: 0;
99+
`
100+
: css`
101+
position: fixed;
102+
103+
width: ${PANEL_WIDTH};
104+
height: 100%;
105+
106+
top: 0;
107+
right: 0;
108+
bottom: 0;
109+
left: auto;
110+
`}
111+
}
112+
85113
${p =>
86114
p.collapsed
87-
? 'overflow: hidden;'
88-
: `overflow-x: hidden;
89-
overflow-y: scroll;`}
115+
? css`
116+
overflow: hidden;
117+
`
118+
: css`
119+
overflow-x: hidden;
120+
overflow-y: auto;
121+
`}
90122
`;

0 commit comments

Comments
 (0)