Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-4275 feat: app height set via js #2259

Merged
merged 3 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions webapp/packages/core-app/src/Body.m.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.bodyContent {
composes: theme-background-surface theme-text-on-surface theme-typography from global;
height: 100vh;
display: flex;
padding: 0 !important;
flex-direction: column;
overflow: hidden;
composes: theme-background-surface theme-text-on-surface theme-typography from global;
height: var(--app-height);
display: flex;
padding: 0 !important;
flex-direction: column;
overflow: hidden;
}
16 changes: 16 additions & 0 deletions webapp/packages/core-app/src/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SessionPermissionsResource } from '@cloudbeaver/core-root';
import { ScreenService } from '@cloudbeaver/core-routing';
import { ThemeService } from '@cloudbeaver/core-theming';
import { DNDProvider } from '@cloudbeaver/core-ui';
import { throttle } from '@cloudbeaver/core-utils';
import { useAppVersion } from '@cloudbeaver/core-version';

import style from './Body.m.css';
Expand All @@ -34,6 +35,12 @@ export const Body = observer(function Body() {
// TODO: must be loaded in place where it is used
useResource(Body, ProjectInfoResource, CachedMapAllKey, { silent: true });

// we need it because 100vh cuts the bottom of the page on mobile devices
const handleBodyHeight = throttle(() => {
const doc = document.documentElement;
doc.style.setProperty('--app-height', `${window.innerHeight}px`);
}, 50);

// sync classes from theme with body for popup components and etc
useLayoutEffect(() => {
if (ref.current) {
Expand All @@ -42,6 +49,15 @@ export const Body = observer(function Body() {
document.documentElement.dataset.backendVersion = backendVersion;
});

useLayoutEffect(() => {
handleBodyHeight();
window.addEventListener('resize', handleBodyHeight);

return () => {
window.removeEventListener('resize', handleBodyHeight);
};
}, []);

return (
<DNDProvider>
<Loader suspense>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
&.small {
min-width: 404px;
min-height: 262px;
max-height: max(100vh - 48px, 262px);
max-height: max(var(--app-height) - 48px, 262px);

&.fixedSize {
width: 404px;
Expand All @@ -34,7 +34,7 @@
&.medium {
min-width: 576px;
min-height: 374px;
max-height: max(100vh - 48px, 374px);
max-height: max(var(--app-height) - 48px, 374px);

&.fixedSize {
width: 576px;
Expand All @@ -47,7 +47,7 @@
&.large {
min-width: 720px;
min-height: 468px;
max-height: max(100vh - 48px, 468px);
max-height: max(var(--app-height) - 48px, 468px);

&.fixedSize {
width: 720px;
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/core-blocks/src/DisplayError.m.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
overflow: auto;

&.root {
height: 100vh;
height: var(--app-height);
}
}
.errorInnerBlock {
Expand Down
4 changes: 2 additions & 2 deletions webapp/packages/core-bootstrap/src/renderLayout.m.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.loader {
height: 100vh;
}
height: var(--app-height);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.wrapper {
min-height: 520px !important;
max-height: max(100vh - 48px, 520px) !important;
max-height: max(var(--app-height) - 48px, 520px) !important;
}
.submittingForm {
overflow: auto;
Expand Down
Loading