Skip to content

Commit 7755b0d

Browse files
authored
fix(schema-hints): Reduce width of schema hints drawer (#87177)
The drawer was taking up too much room on the page when it was open and was essentially hiding the search bar. It would be nice to see what is being added to the search bar even when the drawer is open. I had to make some additions to the `GlobalDrawer` and `SlideOverPanel` components to pass in css (passing in css provides more flexibility with media queries as opposed to passing in style props). Here's a before and after: | Before | After | |--------|--------| | ![image](https://github.com/user-attachments/assets/eb3d3dae-250b-4049-894e-dc4174404f4a) | ![image](https://github.com/user-attachments/assets/5888dde8-ddfd-491c-96af-422cada3a118) |
1 parent cc2cfa1 commit 7755b0d

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

static/app/components/globalDrawer/components.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ interface DrawerPanelProps {
2828
children: React.ReactNode;
2929
headerContent: React.ReactNode;
3030
onClose: DrawerContentContextType['onClose'];
31+
drawerWidth?: DrawerOptions['drawerWidth'];
3132
transitionProps?: AnimationProps['transition'];
3233
}
3334

3435
export const DrawerPanel = forwardRef(function _DrawerPanel(
35-
{ariaLabel, children, transitionProps, onClose}: DrawerPanelProps,
36+
{ariaLabel, children, transitionProps, onClose, drawerWidth}: DrawerPanelProps,
3637
ref: React.ForwardedRef<HTMLDivElement>
3738
) {
3839
return (
@@ -43,6 +44,7 @@ export const DrawerPanel = forwardRef(function _DrawerPanel(
4344
collapsed={false}
4445
ref={ref}
4546
transitionProps={transitionProps}
47+
panelWidth={drawerWidth}
4648
>
4749
{/*
4850
This provider allows data passed to openDrawer to be accessed by drawer components.

static/app/components/globalDrawer/index.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export interface DrawerOptions {
3232
* If true (default), closes the drawer when anywhere else is clicked
3333
*/
3434
closeOnOutsideClick?: boolean;
35+
/**
36+
* Custom width for the drawer
37+
*/
38+
drawerWidth?: string;
3539
/**
3640
* Custom content for the header of the drawer
3741
*/
@@ -181,6 +185,7 @@ export function GlobalDrawer({children}: any) {
181185
ref={panelRef}
182186
headerContent={currentDrawerConfig?.options?.headerContent ?? null}
183187
transitionProps={currentDrawerConfig?.options?.transitionProps}
188+
drawerWidth={currentDrawerConfig?.options?.drawerWidth}
184189
>
185190
{renderedChild}
186191
</DrawerComponents.DrawerPanel>

static/app/components/slideOverPanel.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type SlideOverPanelProps = {
3030
className?: string;
3131
'data-test-id'?: string;
3232
onOpen?: () => void;
33+
panelWidth?: string;
3334
slidePosition?: 'right' | 'bottom' | 'left';
3435
transitionProps?: AnimationProps['transition'];
3536
};
@@ -46,6 +47,7 @@ function SlideOverPanel(
4647
onOpen,
4748
slidePosition,
4849
transitionProps = {},
50+
panelWidth,
4951
}: SlideOverPanelProps,
5052
ref: ForwardedRef<HTMLDivElement>
5153
) {
@@ -79,6 +81,7 @@ function SlideOverPanel(
7981
aria-label={ariaLabel ?? 'slide out drawer'}
8082
className={className}
8183
data-test-id={testId}
84+
panelWidth={panelWidth}
8285
>
8386
{children}
8487
</_SlideOverPanel>
@@ -90,6 +93,7 @@ const _SlideOverPanel = styled(motion.div, {
9093
['initial', 'animate', 'exit', 'transition'].includes(prop) ||
9194
(prop !== 'collapsed' && isPropValid(prop)),
9295
})<{
96+
panelWidth?: string;
9397
slidePosition?: 'right' | 'bottom' | 'left';
9498
}>`
9599
position: fixed;
@@ -128,7 +132,7 @@ const _SlideOverPanel = styled(motion.div, {
128132
? css`
129133
position: fixed;
130134
131-
width: ${PANEL_WIDTH};
135+
width: ${p.panelWidth ?? PANEL_WIDTH};
132136
height: 100%;
133137
134138
top: 0;
@@ -139,7 +143,7 @@ const _SlideOverPanel = styled(motion.div, {
139143
: css`
140144
position: relative;
141145
142-
width: ${LEFT_SIDE_PANEL_WIDTH};
146+
width: ${p.panelWidth ?? LEFT_SIDE_PANEL_WIDTH};
143147
min-width: 450px;
144148
height: 100%;
145149

static/app/views/explore/components/schemaHintsList.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function SchemaHintsList({
5757
const exploreQuery = useExploreQuery();
5858
const setExploreQuery = useSetExploreQuery();
5959
const location = useLocation();
60+
6061
const {openDrawer, isDrawerOpen} = useDrawer();
6162

6263
const functionTags = useMemo(() => {
@@ -164,6 +165,7 @@ function SchemaHintsList({
164165
),
165166
{
166167
ariaLabel: t('Schema Hints Drawer'),
168+
drawerWidth: '35vw',
167169
shouldCloseOnLocationChange: newLocation => {
168170
return (
169171
location.pathname !== newLocation.pathname ||

0 commit comments

Comments
 (0)