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

Rework window sizes to resolve squished pages #448

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 web/gui-v2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions web/gui-v2/src/components/AddRemoveColumnDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { Fragment, useEffect, useState } from 'react';
import { css } from '@emotion/react';
import {
Checkbox,
Expand Down Expand Up @@ -145,33 +145,35 @@ const AddRemoveColumnDialog = ({
<div css={styles.columnDialogContents}>
<div css={styles.columnDialogList}>
{
COLUMN_GROUPINGS.map((colGroup) => (
<>
COLUMN_GROUPINGS.map((colGroup, ix) => (
<Fragment key={ix}>
<h3>{colGroup.heading}</h3>
{colGroup.entries &&
colGroup.entries.map((entry) => (
colGroup.entries.map((entry, ix) => (
<ColumnSelectionListEntry
colDef={entry}
columnsInternal={columnsInternal}
key={ix}
setColumnsInternal={setColumnsInternal}
/>
))
}
{colGroup.subgroups &&
colGroup.subgroups.map((subgroup) => (
<>
colGroup.subgroups.map((subgroup, ix) => (
<Fragment key={ix}>
<h4>{subgroup.heading}</h4>
{subgroup.entries.map((entry) => (
{subgroup.entries.map((entry, ix) => (
<ColumnSelectionListEntry
colDef={entry}
columnsInternal={columnsInternal}
key={ix}
setColumnsInternal={setColumnsInternal}
/>
))}
</>
</Fragment>
))
}
</>
</Fragment>
))
}
</div>
Expand Down
12 changes: 10 additions & 2 deletions web/gui-v2/src/util/useWindowSize.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { useEffect, useState } from 'react';

const DEFAULT_WIDTH = 1100;

/**
* Return the current width of the browser viewport.
*
* @returns {number} The current width of the viewport (in px). This width
* updates as the user resizes the viewport.
*/
export const useWindowSize = () => {
const [windowSize, setWindowSize] = useState(800);
const [windowSize, setWindowSize] = useState(() => {
if ( typeof window !== "undefined" ) {
return window.innerWidth;
} else {
return DEFAULT_WIDTH;
}
});

useEffect(() => {
const handleResize = () => setWindowSize(window?.innerWidth ?? 800);
const handleResize = () => setWindowSize(window?.innerWidth ?? DEFAULT_WIDTH);
if ( typeof window !== "undefined" ) {
window.addEventListener("resize", handleResize);
}
Expand Down
Loading