mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
24 lines
687 B
TypeScript
24 lines
687 B
TypeScript
/* 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" className="h-100 w-100 p-absolute" />
|
|
</ResizeSensor>
|
|
);
|
|
}
|
|
|
|
export default ViewHeightSensor;
|