Merge branch 'sticky_header' into staging_environment

This commit is contained in:
csawatzky 2025-06-09 14:56:35 -06:00
commit 34fac72a07
8 changed files with 24 additions and 11 deletions

View file

@ -22,6 +22,7 @@ html, body, #root {
height: 100%; height: 100%;
margin: 0; margin: 0;
padding: 0; padding: 0;
overflow-y: hidden;
} }
/* styles.css or a CSS module */ /* styles.css or a CSS module */

View file

@ -5,6 +5,7 @@ import { useEffect, useRef, useState } from "react";
import React from "react"; import React from "react";
import { useMobile } from "hooks"; import { useMobile } from "hooks";
import classNames from "classnames"; import classNames from "classnames";
import { getThemeType } from "theme";
const useStyles = makeStyles((theme: Theme) => { const useStyles = makeStyles((theme: Theme) => {
//const isMobile = useMobile() //const isMobile = useMobile()
@ -56,6 +57,12 @@ const useStyles = makeStyles((theme: Theme) => {
backgroundColor: "rgba(150, 150, 150, 0.15)", backgroundColor: "rgba(150, 150, 150, 0.15)",
} }
}, },
stickyHeader: {
position: "sticky",
backgroundColor: getThemeType() === "light" ? "rgb(245, 245, 245)" : "rgb(40, 40, 40)",
top: 0,
zIndex: 300 //giving a really high z-index to make sure nothing is in front of it
}
})}, })},
); );
@ -101,6 +108,7 @@ interface Props<T> {
endTitleElement?: string | JSX.Element | (() => string | JSX.Element); endTitleElement?: string | JSX.Element | (() => string | JSX.Element);
loadMore?: () => void; loadMore?: () => void;
resizeable?: boolean; resizeable?: boolean;
stickyHeader?: boolean
} }
export default function ResponsiveTable<T extends Object>(props: Props<T>) { export default function ResponsiveTable<T extends Object>(props: Props<T>) {
@ -136,6 +144,7 @@ export default function ResponsiveTable<T extends Object>(props: Props<T>) {
setOrder, setOrder,
loadMore, loadMore,
// resizeable, // resizeable,
stickyHeader
} = props } = props
const classes = useStyles(); const classes = useStyles();
const columns = typeof(props.columns) === "function" ? props.columns() : props.columns const columns = typeof(props.columns) === "function" ? props.columns() : props.columns
@ -486,9 +495,9 @@ export default function ResponsiveTable<T extends Object>(props: Props<T>) {
} }
return ( return (
<TableContainer className={classes.tableContainer} component={Paper}> <Box className={classes.tableContainer} component={Paper}>
<Table> <Table>
<TableHead> <TableHead className={stickyHeader ? classes.stickyHeader : undefined}>
<TableRow sx={ !title && !setSearchText ? { display: "none" } : undefined}> <TableRow sx={ !title && !setSearchText ? { display: "none" } : undefined}>
<TableCell colSpan={10000} sx={{ border: "none" }}> <TableCell colSpan={10000} sx={{ border: "none" }}>
<Grid2 container justifyContent="space-between"> <Grid2 container justifyContent="space-between">
@ -702,6 +711,6 @@ export default function ResponsiveTable<T extends Object>(props: Props<T>) {
</Typography> </Typography>
</MenuItem> </MenuItem>
</Menu> </Menu>
</TableContainer> </Box>
) )
} }

View file

@ -6,7 +6,7 @@ export default function AviationMap() {
const location = useLocation(); const location = useLocation();
return ( return (
<PageContainer padding={-1}> <PageContainer>
{location.state !== undefined && {location.state !== undefined &&
location.state !== null && location.state !== null &&
location.state.long !== undefined && location.state.long !== undefined &&

View file

@ -1477,5 +1477,5 @@ export default function Bins(props: Props) {
); );
}; };
return !props.insert ? <PageContainer padding={-1}>{page()}</PageContainer> : page(); return !props.insert ? <PageContainer>{page()}</PageContainer> : page();
} }

View file

@ -6,7 +6,7 @@ export default function ConstructionSiteMap() {
const location = useLocation(); const location = useLocation();
return ( return (
<PageContainer padding={-1}> <PageContainer>
{location.state !== undefined && {location.state !== undefined &&
location.state !== null && location.state !== null &&
location.state.long !== undefined && location.state.long !== undefined &&

View file

@ -718,7 +718,7 @@ export default function Devices() {
) )
return( return(
<PageContainer padding={isMobile ? 0 : 2}> <PageContainer spacing={2}>
<Box <Box
sx={{ sx={{
borderRadius: 1, borderRadius: 1,
@ -749,6 +749,7 @@ export default function Devices() {
<ResponsiveTable<Device> <ResponsiveTable<Device>
title={<SmartBreadcrumb prependPaths={getGroup() && ["groups", getGroup().id().toString()]} groupName={getGroup() && getGroup().name()} paddingBottom={1}/>} title={<SmartBreadcrumb prependPaths={getGroup() && ["groups", getGroup().id().toString()]} groupName={getGroup() && getGroup().name()} paddingBottom={1}/>}
subtitle={subtitle} subtitle={subtitle}
stickyHeader
rows={devices} rows={devices}
renderGutter={ isMobile ? gutter : undefined } renderGutter={ isMobile ? gutter : undefined }
columns={columns} columns={columns}

View file

@ -5,7 +5,7 @@ import { useLocation } from "react-router";
export default function FieldMap() { export default function FieldMap() {
const location = useLocation(); const location = useLocation();
return ( return (
<PageContainer padding={-1}> <PageContainer>
{location.state !== undefined && {location.state !== undefined &&
location.state !== null && location.state !== null &&
location.state.long !== undefined && location.state.long !== undefined &&

View file

@ -39,7 +39,7 @@ interface Props extends PropsWithChildren{
fullViewport?: boolean; fullViewport?: boolean;
isCenterCenter?: boolean; isCenterCenter?: boolean;
sx?: SxProps<Theme>; sx?: SxProps<Theme>;
padding?: number; spacing?: number;
} }
export const PageContainer: React.FunctionComponent<Props> = (props: Props) => { export const PageContainer: React.FunctionComponent<Props> = (props: Props) => {
@ -48,7 +48,7 @@ export const PageContainer: React.FunctionComponent<Props> = (props: Props) => {
const { children, fullViewport, isCenterCenter, sx } = props; const { children, fullViewport, isCenterCenter, sx } = props;
// let fullViewport = false // let fullViewport = false
// let isCenterCenter = false // let isCenterCenter = false
const padding = props.padding ? props.padding : isMobile ? 1 : 2; const spacing = props.spacing;
return ( return (
<Container <Container
className={classNames( className={classNames(
@ -57,7 +57,9 @@ export const PageContainer: React.FunctionComponent<Props> = (props: Props) => {
)} )}
sx={{ sx={{
...sx, // Spread existing sx ...sx, // Spread existing sx
...(padding !== undefined && { padding }), // Conditionally add padding paddingX: spacing,
marginTop: spacing
// ...(padding !== undefined && { padding }), // Conditionally add padding
}} }}
disableGutters disableGutters
maxWidth={false} maxWidth={false}