mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-13 10:04:15 +00:00
This style is not about looks, so hard-code it instead of using style sheets.
30 lines
836 B
TypeScript
30 lines
836 B
TypeScript
// 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;
|