components/ViewHeightSensor: remove view height sensor

This appears to no longer be necessary for correct app height on Android.
This commit is contained in:
David Lechner
2022-12-21 19:44:11 -06:00
committed by David Lechner
parent 27b8b1e428
commit b255a145e3
7 changed files with 19 additions and 52 deletions
-11
View File
@@ -1,11 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 The Pybricks Authors
import { render } from '@testing-library/react';
import React from 'react';
import ViewHeightSensor from './ViewHeightSensor';
it('should set the --pb-vh variable on resize', () => {
render(<ViewHeightSensor />);
// REVISIT: it is not easy to test the resize event since jest-dom doesn't do layout
});
-29
View File
@@ -1,29 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022 The Pybricks Authors
/* This is a hack for correctly sizing to view height on mobile when not running in fullscreen mode. */
import { ResizeSensor } from '@blueprintjs/core';
import React from 'react';
/* https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ */
function ViewHeightSensor(): JSX.Element {
return (
<ResizeSensor
onResize={(e): void => {
document.documentElement.style.setProperty(
'--pb-vh',
`${e[0].contentRect.height}px`,
);
}}
>
<div
id="pb-vh"
style={{ height: '100%', width: '100%', position: 'absolute' }}
/>
</ResizeSensor>
);
}
export default ViewHeightSensor;