Skip to content

Commit

Permalink
reducing commits
Browse files Browse the repository at this point in the history
  • Loading branch information
cphelefu committed Nov 17, 2023
1 parent 497dd85 commit 9f50046
Show file tree
Hide file tree
Showing 14 changed files with 191 additions and 107 deletions.
14 changes: 10 additions & 4 deletions packages/geoview-core/src/core/components/common/layer-title.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import { Typography } from '@/ui';
import { useTheme } from '@mui/material';
import { Typography } from '@/ui';

interface LayerTitleProp {
children: React.ReactNode;
hideTitle?: boolean | undefined;

Check warning on line 6 in packages/geoview-core/src/core/components/common/layer-title.tsx

View workflow job for this annotation

GitHub Actions / Build demo files / build-geoview

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

/**
* Create Layer Title.
* @param {string} children the name of the layer.
* @param {boolean} hideTitle hide the layer title for desktop view.
* @returns JSX.Element
*/
export function LayerTitle({ children }: LayerTitleProp) {
export function LayerTitle({ children, hideTitle = false }: LayerTitleProp) {
const theme = useTheme();

return (
<Typography
sx={{ font: theme.footerPanel.layerTitleFont, marginTop: '12px', [theme.breakpoints.up('md')]: { display: 'none' } }}
component="span"
sx={{
font: theme.footerPanel.layerTitleFont,
marginTop: '12px',
[theme.breakpoints.up('md')]: { display: hideTitle ? 'none' : 'block' },
}}
component="div"
>
{children}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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
isEnlargeDataTable: boolean;
}

/**
Expand All @@ -29,15 +30,18 @@ function ResponsiveGridRoot({ children, ...rest }: ResponsiveGridProps) {
* Create Left Panel for responsive grid.
* @param {ReactNode} children child elements to be rendered
* @param {boolean} isLayersPanelVisible panel visibility
* @param {boolean} isEnlargeDataTable panel is enlarge
* @returns JSX.Element
*/
function ResponsiveGridLeftPanel({ children, isLayersPanelVisible = false, ...rest }: ResponsiveGridPanelProps) {
function ResponsiveGridLeftPanel({ children, isLayersPanelVisible = false, isEnlargeDataTable, ...rest }: ResponsiveGridPanelProps) {
const theme = useTheme();

return (
<Grid
item
xs={isLayersPanelVisible ? 12 : 0}
md={!isEnlargeDataTable ? 4 : 2}
lg={!isEnlargeDataTable ? 4 : 1.25}
sx={{
[theme.breakpoints.down('md')]: { display: isLayersPanelVisible ? 'block' : 'none' },
}}
Expand All @@ -52,14 +56,24 @@ function ResponsiveGridLeftPanel({ children, isLayersPanelVisible = false, ...re
* Create Right Panel for responsive grid.
* @param {ReactNode} children child elements to be rendered
* @param {boolean} isLayersPanelVisible panel visibility
* @param {boolean} isEnlargeDataTable panel is enlarge
* @param {object} sxProps Optional sx props
* @returns JSX.Element
*/
function ResponsiveGridRightPanel({ children, isLayersPanelVisible = false, sxProps = {}, ...rest }: ResponsiveGridPanelProps) {
function ResponsiveGridRightPanel({
children,
isLayersPanelVisible = false,
sxProps = {},
isEnlargeDataTable,
...rest
}: ResponsiveGridPanelProps) {
const theme = useTheme();
return (
<Grid
item
xs={!isLayersPanelVisible ? 12 : 0}
md={!isEnlargeDataTable ? 8 : 10}
lg={!isEnlargeDataTable ? 8 : 10.75}
sx={{
position: 'relative',
[theme.breakpoints.up('md')]: { paddingLeft: '1rem' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
import { useTheme } from '@mui/material/styles';
import { Projection } from 'ol/proj';
import { useTranslation } from 'react-i18next';
import { Box, Typography, CircularProgress, FilterAltIcon } from '@/ui';
import { Box, CircularProgress, FilterAltIcon } from '@/ui';
import MapDataTable, { MapDataTableData as MapDataTableDataProps } from './map-data-table';
import { getSxClasses } from './data-table-style';
import { GroupLayers } from './data-table-api';
Expand Down Expand Up @@ -125,12 +125,10 @@ export function Datapanel({ layerData, mapId, projectionConfig, language }: Data
return (
<Box sx={sxClasses.dataPanel}>
<ResponsiveGrid.Root spacing={2} sx={sxClasses.gridContainer}>
<ResponsiveGrid.Left md={4} isLayersPanelVisible={isLayersPanelVisible}>
<Typography component="p" sx={sxClasses.headline}>
{t('dataTable.leftPanelHeading')}
</Typography>
<ResponsiveGrid.Left isLayersPanelVisible={isLayersPanelVisible} isEnlargeDataTable={isEnlargeDataTable}>
<LayerTitle>{t('dataTable.leftPanelHeading')}</LayerTitle>
</ResponsiveGrid.Left>
<ResponsiveGrid.Right md={8} isLayersPanelVisible={isLayersPanelVisible}>
<ResponsiveGrid.Right isLayersPanelVisible={isLayersPanelVisible} isEnlargeDataTable={isEnlargeDataTable}>
<Box
sx={{
display: 'flex',
Expand All @@ -139,7 +137,7 @@ export function Datapanel({ layerData, mapId, projectionConfig, language }: Data
[theme.breakpoints.down('md')]: { justifyContent: 'space-between' },
}}
>
{!isLoading && <LayerTitle>{layerData![selectedLayerIndex]?.layerName![language] ?? ''}</LayerTitle>}
{!isLoading && <LayerTitle hideTitle>{layerData![selectedLayerIndex]?.layerName![language] ?? ''}</LayerTitle>}

<Box>
<EnlargeButton isEnlargeDataTable={isEnlargeDataTable} setIsEnlargeDataTable={setIsEnlargeDataTable} />
Expand All @@ -149,16 +147,11 @@ export function Datapanel({ layerData, mapId, projectionConfig, language }: Data
</ResponsiveGrid.Right>
</ResponsiveGrid.Root>
<ResponsiveGrid.Root sx={{ marginTop: '0.75rem' }}>
<ResponsiveGrid.Left
isLayersPanelVisible={isLayersPanelVisible}
md={!isEnlargeDataTable ? 4 : 2}
lg={!isEnlargeDataTable ? 4 : 1.25}
>
<ResponsiveGrid.Left isLayersPanelVisible={isLayersPanelVisible} isEnlargeDataTable={isEnlargeDataTable}>
{renderList()}
</ResponsiveGrid.Left>
<ResponsiveGrid.Right
md={!isEnlargeDataTable ? 8 : 10}
lg={!isEnlargeDataTable ? 8 : 10.75}
isEnlargeDataTable={isEnlargeDataTable}
isLayersPanelVisible={isLayersPanelVisible}
sxProps={{ minHeight: '250px' }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Theme } from '@mui/material';

export const getSxClasses = (theme: Theme) => ({
headline: { fontSize: '1.125rem', fontWeight: 'bold' },
dataPanel: { backgroundColor: '#F1F2F5', padding: '1.5rem' },
dataPanel: { backgroundColor: '#F1F2F5', padding: '1rem 0' },
gridContainer: { paddingLeft: '1rem', paddingRight: '1rem' },
iconImage: {
padding: 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,18 @@ export function Detailspanel({ mapId }: DetailsPanelProps): JSX.Element {
<Box sx={sxClasses.detailsContainer}>
{!layerDataInfo && (
<ResponsiveGrid.Root>
<ResponsiveGrid.Left xs={12} isLayersPanelVisible={isLayersPanelVisible}>
<ResponsiveGrid.Left isLayersPanelVisible={isLayersPanelVisible} isEnlargeDataTable={isEnlargeDataTable}>
<Typography component="p">{t('details.selectVisbleLayer')}</Typography>
</ResponsiveGrid.Left>
</ResponsiveGrid.Root>
)}
{layerDataInfo && (
<>
<ResponsiveGrid.Root>
<ResponsiveGrid.Left md={4} isLayersPanelVisible={isLayersPanelVisible}>
<Typography component="div" sx={sxClasses.panelHeaders}>
{t('details.availableLayers')}
</Typography>
<ResponsiveGrid.Left isEnlargeDataTable={isEnlargeDataTable} isLayersPanelVisible={isLayersPanelVisible}>
<LayerTitle>{t('details.availableLayers')}</LayerTitle>
</ResponsiveGrid.Left>
<ResponsiveGrid.Right isLayersPanelVisible={isLayersPanelVisible} md={8}>
<ResponsiveGrid.Right isEnlargeDataTable={isEnlargeDataTable} isLayersPanelVisible={isLayersPanelVisible}>
<Box
sx={{
display: 'flex',
Expand All @@ -207,7 +205,7 @@ export function Detailspanel({ mapId }: DetailsPanelProps): JSX.Element {
[theme.breakpoints.down('md')]: { justifyContent: 'space-between' },
}}
>
<LayerTitle>{layerDataInfo.layerName}</LayerTitle>
<LayerTitle hideTitle>{layerDataInfo.layerName}</LayerTitle>

<Box>
<EnlargeButton isEnlargeDataTable={isEnlargeDataTable} setIsEnlargeDataTable={setIsEnlargeDataTable} />
Expand All @@ -217,18 +215,10 @@ export function Detailspanel({ mapId }: DetailsPanelProps): JSX.Element {
</ResponsiveGrid.Right>
</ResponsiveGrid.Root>
<ResponsiveGrid.Root sx={{ marginTop: '1rem' }}>
<ResponsiveGrid.Left
isLayersPanelVisible={isLayersPanelVisible}
md={!isEnlargeDataTable ? 4 : 2}
lg={!isEnlargeDataTable ? 4 : 1.25}
>
<ResponsiveGrid.Left isEnlargeDataTable={isEnlargeDataTable} isLayersPanelVisible={isLayersPanelVisible}>
{renderLayerList()}
</ResponsiveGrid.Left>
<ResponsiveGrid.Right
md={!isEnlargeDataTable ? 8 : 10}
lg={!isEnlargeDataTable ? 8 : 10.75}
isLayersPanelVisible={isLayersPanelVisible}
>
<ResponsiveGrid.Right isEnlargeDataTable={isEnlargeDataTable} isLayersPanelVisible={isLayersPanelVisible}>
<Box sx={sxClasses.rightPanleContainer}>
<Grid container sx={sxClasses.rightPanelBtnHolder}>
<Grid item xs={6}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const getSxClasses = (theme: Theme) => ({
detailsContainer: {
background: theme.footerPanel.contentBg,
boxShadow: theme.footerPanel.contentShadow,
padding: '1.5rem',
padding: '1rem 0',
},
footerTopPanleSecondary: {
font: theme.footerPanel.chooseLayerFont,
Expand Down
35 changes: 23 additions & 12 deletions packages/geoview-core/src/core/components/layers/layers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,37 @@ export function Layers(props: LegendItemsDetailsProps): JSX.Element {
</Item>
);
}
else if(displayState === 'remove') {
return (<Paper sx={{padding: "20px"}}>
if (displayState === 'remove') {
return (
<Paper sx={{ padding: '20px' }}>
<h3>Removing layers</h3>
<Box sx={{display: "flex", flexDirection: "row", alignItems: "center" }}>
<Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
<IconButton>
<DeleteIcon style={{ fill: '#a9a9a9' }} />
</IconButton>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Ipsum perspiciatis doloribus veritatis iste? Quae alias praesentium, delectus reprehenderit itaque voluptatibus!</p>
<p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Ipsum perspiciatis doloribus veritatis iste? Quae alias praesentium,
delectus reprehenderit itaque voluptatibus!
</p>
</Box>
</Paper>)
</Paper>
);
}
else if(displayState === 'order') {
return (<Paper sx={{padding: "20px"}}>
if (displayState === 'order') {
return (
<Paper sx={{ padding: '20px' }}>
<h3>Re-ordering layers</h3>
<Box sx={{display: "flex", flexDirection: "row", alignItems: "center" }}>
<IconButton><HandleIcon style={{ fill: '#a9a9a9' }} /></IconButton>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Praesentium animi, perferendis nemo quas sequi totam minima ad labore.</p>
<Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
<IconButton>
<HandleIcon style={{ fill: '#a9a9a9' }} />
</IconButton>
<p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Praesentium animi, perferendis nemo quas sequi totam minima ad
labore.
</p>
</Box>
</Paper>);
</Paper>
);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { useEffect, useState } from 'react';
import { Box, CircularProgressBase, DeleteOutlineIcon, IconButton, UndoIcon } from '@/ui';
import { TypeLegendLayer } from '../types';
import { useLayerStoreActions } from '@/core/stores/store-interface-and-intial-values/layer-state';

interface DeleteUndoButtonProps {
layer: TypeLegendLayer;
}

interface UndoButtonProps {
progressValue: number;
onUndo: () => void;
}

function UndoButtonWithProgress(props: UndoButtonProps): JSX.Element {
const { progressValue, onUndo } = props;
return (
<Box sx={{ position: 'relative', display: 'inline-flex' }} onClick={onUndo}>
<CircularProgressBase variant="determinate" size={40} value={progressValue} />
<Box
style={{
top: 0,
left: 0,
bottom: 0,
right: 0,
position: 'absolute',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<IconButton>
<UndoIcon />
</IconButton>
</Box>
</Box>
);
}

export function DeleteUndoButton(props: DeleteUndoButtonProps): JSX.Element {
const { layer } = props;

const [progress, setProgress] = useState(10);
const [inUndoState, setInUndoState] = useState(false);

// get store actions
const { deleteLayer } = useLayerStoreActions();

const handleDeleteClick = () => {
setInUndoState(true);
};

const handleUndoClick = () => {
setInUndoState(false);
};

useEffect(() => {
if (progress === 100) {
deleteLayer(layer.layerPath);
setInUndoState(false);
}
return undefined;
}, [progress]);

Check warning on line 63 in packages/geoview-core/src/core/components/layers/left-panel/delete-undo-button.tsx

View workflow job for this annotation

GitHub Actions / Build demo files / build-geoview

React Hook useEffect has missing dependencies: 'deleteLayer' and 'layer.layerPath'. Either include them or remove the dependency array

useEffect(() => {
if (inUndoState) {
const timer = setInterval(() => {
setProgress((prevProgress) => (prevProgress >= 100 ? 0 : prevProgress + 10));
}, 800);
return () => {
clearInterval(timer);
};
}
setProgress(0);
return undefined;
}, [inUndoState]);

if (!inUndoState) {
return (
<IconButton onClick={handleDeleteClick}>
<DeleteOutlineIcon style={{ fill: '#c51e3a' }} />
</IconButton>
);
}
return <UndoButtonWithProgress progressValue={progress} onUndo={handleUndoClick} />;
}
Loading

0 comments on commit 9f50046

Please sign in to comment.