Skip to content

Commit 23a2201

Browse files
committed
Get rid of useWindowSize #256
1 parent 367c4b3 commit 23a2201

File tree

3 files changed

+4
-43
lines changed

3 files changed

+4
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This changelog covers all three packages, as they are (for now) updated as a who
99
- Add scoped search, funded by NGI NLnet Discovery #245
1010
- Make web app installable #30
1111
- Add cookie based authentication #241
12+
- Get rid of `useWindowSize` #256
1213

1314
## v0.32.1
1415

data-browser/src/components/SideBar/index.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import styled from 'styled-components';
22
import * as React from 'react';
33
import { useHover } from '../../helpers/useHover';
44
import { useSettings } from '../../helpers/AppSettings';
5-
import { useWindowSize } from '../../helpers/useWindowSize';
65
import { SideBarDrive } from './SideBarDrive';
76
import { DragAreaBase, useResizable } from '../../hooks/useResizable';
87
import { useCombineRefs } from '../../hooks/useCombineRefs';
98
import { NavBarSpacer } from '../NavBarSpacer';
109
import { AppMenu } from './AppMenu';
1110
import { About } from './About';
11+
import { useMediaQuery } from '../../hooks/useMediaQuery';
1212

1313
/** Amount of pixels where the sidebar automatically shows */
1414
export const SIDEBAR_TOGGLE_WIDTH = 600;
@@ -18,18 +18,15 @@ const SideBarDriveMemo = React.memo(SideBarDrive);
1818
export function SideBar(): JSX.Element {
1919
const { drive, sideBarLocked, setSideBarLocked } = useSettings();
2020
const [ref, hoveringOverSideBar] = useHover<HTMLElement>(sideBarLocked);
21-
const windowSize = useWindowSize();
21+
// Check if the window is small enough to hide the sidebar
22+
const isWideScreen = useMediaQuery(`(min-width: ${SIDEBAR_TOGGLE_WIDTH}px)`);
2223

2324
const { size, targetRef, dragAreaRef, isDragging } = useResizable(
2425
300,
2526
200,
2627
2000,
2728
);
2829

29-
const isWideScreen = windowSize.width
30-
? windowSize.width > SIDEBAR_TOGGLE_WIDTH
31-
: false;
32-
3330
const mountRefs = useCombineRefs([ref, targetRef]);
3431

3532
/**

data-browser/src/helpers/useWindowSize.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)