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

feat(datatable): common enlarge and close btn #1494 #1500

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d71591d
fix(datatable): common enlarge and close btn #1494
kaminderpal Nov 14, 2023
11f6f82
fix(datatable): common enlarge and close btn #1494
kaminderpal Nov 14, 2023
3ba759b
fix(datatable): common list for data table #1494
kaminderpal Nov 15, 2023
6ea2ad2
Merge branch 'develop' of https://github.com/Canadian-Geospatial-Plat…
kaminderpal Nov 15, 2023
3b41a59
fix(details): layer list of details component #1494
kaminderpal Nov 15, 2023
a49556c
fix(details): layer list of details component #1494
kaminderpal Nov 15, 2023
890530c
fix(time-slider): update layer list for time slider #1494
kaminderpal Nov 15, 2023
072ec05
fix(time-slider): add layer name in right panel mobile device #1494
kaminderpal Nov 15, 2023
a8805fe
fix(time-slider): fix height of layer list #1494
kaminderpal Nov 15, 2023
6629bc8
Merge branch 'develop' of https://github.com/Canadian-Geospatial-Plat…
kaminderpal Nov 15, 2023
3704866
fix(time-slider): fix height of layer list #1494
kaminderpal Nov 15, 2023
8d4fde0
fix(time-slider): fix height of layer list #1494
kaminderpal Nov 15, 2023
0646a81
fix(time-slider): remove margin from iconstack #1494
kaminderpal Nov 16, 2023
a50f521
fix(time-slider): remove margin from iconstack #1494
kaminderpal Nov 16, 2023
2fcaaff
fix(time-slider): update left and right panel width #1494
kaminderpal Nov 16, 2023
cd992c6
fix(time-slider): update left and right panel width #1494
kaminderpal Nov 16, 2023
5698db5
Merge branch 'develop' of https://github.com/Canadian-Geospatial-Plat…
kaminderpal Nov 16, 2023
e12fc04
fix(time-slider): fix responsive grid default param #1494
kaminderpal Nov 16, 2023
7421588
fix(time-slider): fix layer title #1494
kaminderpal Nov 16, 2023
176f032
fix(time-slider): fix layer title #1494
kaminderpal Nov 16, 2023
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
1 change: 1 addition & 0 deletions packages/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"react/jsx-props-no-spreading": "off",
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"react/require-default-props": "warn",
"no-restricted-imports": [
"error",
{
Expand Down
42 changes: 42 additions & 0 deletions packages/geoview-core/src/core/components/common/close-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { SetStateAction, Dispatch } from 'react';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { Button } from '@/ui';
import { getSxClasses } from './enlarge-button-style';

interface CloseButtonProps {
isLayersPanelVisible: boolean;
setIsLayersPanelVisible: Dispatch<SetStateAction<boolean>>;
}

/**
* Create close button
* @param {boolean} isLayersPanelVisible show/hide the list in left panel
* @param {function} setIsLayersPanelVisible dispatch function to update isLayersPanelVisible
* @returns JSX.element
*/
export function CloseButton({ isLayersPanelVisible, setIsLayersPanelVisible }: CloseButtonProps) {
const { t } = useTranslation<string>();

const theme = useTheme();
const sxClasses = getSxClasses(theme);

return (
<Button
type="text"
size="small"
sx={{
...sxClasses.enlargeBtn,
marginLeft: '1rem',
[theme.breakpoints.up('md')]: { display: 'none' },
[theme.breakpoints.between('sm', 'md')]: { display: !isLayersPanelVisible ? 'block' : 'none' },
[theme.breakpoints.down('md')]: { display: !isLayersPanelVisible ? 'block' : 'none' },
}}
onClick={() => setIsLayersPanelVisible(true)}
tooltip={t('dataTable.close') ?? ''}
tooltipPlacement="top"
>
{t('dataTable.close')}
</Button>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Theme } from '@mui/material';

export const getSxClasses = (theme: Theme) => ({
enlargeBtn: {
width: '7rem !important',
height: '2.5rem !important',
borderRadius: '1.5rem',
boxShadow: '0px 3px 6px #00000029',
marginTop: '0.25rem',
background: '#F4F5FF !important',
'>div': {
color: `${theme.palette.primary.main} !important`,
},
'& svg': {
marginRight: '0.25rem',
},
':hover': {
backgroundColor: `${theme.palette.primary.main} !important`,
'> div': {
color: `${theme.palette.common.white} !important`,
},
'& svg': {
color: `${theme.palette.common.white} !important`,
},
},
[theme.breakpoints.down('md')]: { display: 'none' },
},
enlargeBtnIcon: {
color: theme.palette.primary.main,
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Dispatch } from 'react';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { ArrowBackIcon, ArrowForwardIcon, Button } from '@/ui';
import { getSxClasses } from './enlarge-button-style';

interface EnlargeButtonProps {
isEnlargeDataTable: boolean;
setIsEnlargeDataTable: Dispatch<boolean>;
}

/**
* Create enlarge button
* @param {boolean} isEnlargeDataTable
* @param {function} setIsEnlargeDataTable
* @returns JSX.element
*/
export function EnlargeButton({ isEnlargeDataTable, setIsEnlargeDataTable }: EnlargeButtonProps) {
const { t } = useTranslation<string>();

const theme = useTheme();
const sxClasses = getSxClasses(theme);

return (
<Button
type="text"
size="small"
sx={sxClasses.enlargeBtn}
onClick={() => setIsEnlargeDataTable(!isEnlargeDataTable)}
tooltip={isEnlargeDataTable ? t('dataTable.reduceBtn')! : t('dataTable.enlargeBtn')!}
tooltipPlacement="top"
>
{isEnlargeDataTable ? <ArrowForwardIcon sx={sxClasses.enlargeBtnIcon} /> : <ArrowBackIcon sx={sxClasses.enlargeBtnIcon} />}
{isEnlargeDataTable ? t('dataTable.reduceBtn') : t('dataTable.enlargeBtn')}
</Button>
);
}
5 changes: 5 additions & 0 deletions packages/geoview-core/src/core/components/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './close-button';
export * from './enlarge-button';
export * from './responsive-grid';
export * from './layer-list';
export * from './layer-title';
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Theme } from '@mui/material';

export const getSxClasses = (theme: Theme) => ({
list: {
color: 'text.primary',
width: '100%',
[theme.breakpoints.up('md')]: {
paddingRight: '1rem',
},
[theme.breakpoints.up('xl')]: {
paddingRight: '2rem',
},
'& .MuiListItemText-primary': {
font: theme.footerPanel.layerTitleFont,
},

'& .MuiListItem-root': {
height: '100%',
'& .MuiListItemButton-root': {
padding: '0 0 0 16px',
height: '100%',
},
},
'& .MuiListItemButton-root': {
minHeight: '73px',
},
'& .MuiListItemIcon-root': {
minWidth: '2rem',
},
'& .MuiListItemText-root': {
'>span': {
fontSize: '1rem',
},
'> p': {
fontSize: '0.875rem',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
},
},
},
listPrimaryText: {
minWidth: '0',
marginTop: '0.5rem',
marginBottom: '0.5rem',
marginLeft: '10px',
flex: '1 1 auto',
display: 'flex',
flexDirection: 'column',
'& p': {
fontSize: '1rem',
font: '600 18px / 24px Roboto, Helvetica, Arial, sans-serif;',
fontWeight: 400,
lineHeight: 1.5,
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
},
'>div': {
display: 'flex',
alignItems: 'center',
marginTop: '4px',
'>p': {
fontSize: '0.875rem !important',
color: theme.palette.text.secondary,
},
' svg': {
width: '0.75em',
height: '0.75em',
},
},
},
paper: { marginBottom: '1rem' },
borderWithIndex: `2px solid ${theme.palette.primary.main}`,
borderNone: 'none',
headline: { fontSize: '1.125rem', fontWeight: 'bold' },
});
89 changes: 89 additions & 0 deletions packages/geoview-core/src/core/components/common/layer-list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { ReactNode } from 'react';
import { useTheme } from '@mui/material/styles';
import { Box, ChevronRightIcon, IconButton, List, ListItem, ListItemButton, ListItemIcon, Paper, Tooltip, Typography } from '@/ui';
import { getSxClasses } from './layer-list-style';
import { IconStack } from '@/app';

export interface LayerListEntry {
layerName: string;
layerPath: string;
layerFeatures?: ReactNode | undefined;
mapFilteredIcon?: ReactNode | undefined;
tooltip?: ReactNode | undefined;
}

interface LayerListProps {
isEnlargeDataTable: boolean;
layerList: LayerListEntry[];
selectedLayerIndex: number;
handleListItemClick: (layer: LayerListEntry, index: number) => void;
}

/**
* Create a list of layers
* @param {LayerListEntry} layerList Array of layer list entries.
* @param {boolean} isEnlargeDataTable Boolean value if right panel is enlarged or not.
* @param {number} selectedLayerIndex Current index of list item selected.
* @param {Function} handleListItemClick Callback function excecuted when list item is clicked.
* @returns
*/
export function LayerList({ layerList, isEnlargeDataTable, selectedLayerIndex, handleListItemClick }: LayerListProps) {
const theme = useTheme();
const sxClasses = getSxClasses(theme);

return (
<List sx={sxClasses.list}>
{layerList.map((layer, index) => (
<Paper
sx={{ ...sxClasses.paper, border: selectedLayerIndex === index ? sxClasses.borderWithIndex : sxClasses.borderNone }}
key={layer.layerPath}
>
<Tooltip title={layer.tooltip} placement="top" arrow>
<Box>
<ListItem disablePadding>
<ListItemButton selected={selectedLayerIndex === index} onClick={() => handleListItemClick(layer, index)}>
<ListItemIcon>
<IconStack layerPath={layer.layerPath} />
</ListItemIcon>
<Box sx={sxClasses.listPrimaryText}>
<Typography component="p">{layer.layerName}</Typography>
{!!layer?.layerFeatures && (
<Box sx={{ display: 'flex', alignContent: 'center' }}>
<Typography component="p" variant="subtitle1" noWrap>
{layer.layerFeatures}
</Typography>

{!!layer.mapFilteredIcon && layer.mapFilteredIcon}
</Box>
)}
</Box>
<Box
sx={{
padding: isEnlargeDataTable ? '0.25rem' : '1rem',
paddingRight: isEnlargeDataTable ? '0.25rem' : '1rem',
[theme.breakpoints.down('xl')]: {
display: isEnlargeDataTable ? 'none !important' : 'block',
},
[theme.breakpoints.down('sm')]: {
display: 'none',
},
}}
>
<IconButton
disabled
edge="end"
size="small"
sx={{ color: `${theme.palette.primary.main} !important`, background: `${theme.palette.grey.A100} !important` }}
>
<ChevronRightIcon />
</IconButton>
</Box>
</ListItemButton>
</ListItem>
</Box>
</Tooltip>
</Paper>
))}
</List>
);
}
24 changes: 24 additions & 0 deletions packages/geoview-core/src/core/components/common/layer-title.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Typography } from '@/ui';
import { useTheme } from '@mui/material';

interface LayerTitleProp {
children: React.ReactNode;
}

/**
* Create Layer Title.
* @param {string} children the name of the layer.
* @returns JSX.Element
*/
export function LayerTitle({ children }: LayerTitleProp) {
const theme = useTheme();

return (
<Typography
sx={{ font: theme.footerPanel.layerTitleFont, marginTop: '12px', [theme.breakpoints.up('md')]: { display: 'none' } }}
component="span"
>
{children}
</Typography>
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ReactNode } from 'react';
import { GridProps } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import { Grid } from '@/ui';
import { Grid, GridProps, SxProps } from '@/ui';

interface ResponsiveGridProps extends GridProps {
children: ReactNode;
Expand All @@ -10,6 +9,7 @@
interface ResponsiveGridPanelProps extends GridProps {
children: ReactNode;
isLayersPanelVisible: boolean;
sxProps?: SxProps | undefined;

Check warning on line 12 in packages/geoview-core/src/core/components/common/responsive-grid.tsx

View workflow job for this annotation

GitHub Actions / Build demo files / build-geoview

propType "sxProps" is not required, but has no corresponding defaultProps declaration

Check warning on line 12 in packages/geoview-core/src/core/components/common/responsive-grid.tsx

View workflow job for this annotation

GitHub Actions / Build demo files / build-geoview

propType "sxProps" is not required, but has no corresponding defaultProps declaration
}

/**
Expand Down Expand Up @@ -37,6 +37,7 @@
return (
<Grid
item
xs={isLayersPanelVisible ? 12 : 0}
sx={{
[theme.breakpoints.down('md')]: { display: isLayersPanelVisible ? 'block' : 'none' },
}}
Expand All @@ -53,15 +54,17 @@
* @param {boolean} isLayersPanelVisible panel visibility
* @returns JSX.Element
*/
function ResponsiveGridRightPanel({ children, isLayersPanelVisible = false, ...rest }: ResponsiveGridPanelProps) {
function ResponsiveGridRightPanel({ children, isLayersPanelVisible = false, sxProps = {}, ...rest }: ResponsiveGridPanelProps) {
const theme = useTheme();
return (
<Grid
item
xs={!isLayersPanelVisible ? 12 : 0}
sx={{
position: 'relative',
[theme.breakpoints.up('md')]: { paddingLeft: '1rem' },
[theme.breakpoints.down('md')]: { display: !isLayersPanelVisible ? 'block' : 'none', minHeight: '250px' },
[theme.breakpoints.down('md')]: { display: !isLayersPanelVisible ? 'block' : 'none' },
...sxProps,
}}
{...rest}
>
Expand Down
Loading
Loading