Skip to content

Commit

Permalink
Merge branch 'develop' into remove-makeStyles-from-code
Browse files Browse the repository at this point in the history
  • Loading branch information
cphelefu authored May 28, 2024
2 parents 1a89351 + cd2cb44 commit 62ae1d4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 42 deletions.
1 change: 0 additions & 1 deletion packages/geoview-core/src/core/components/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export * from './focus-trap-element';
export * from './responsive-grid';
export * from './layer-list';
export * from './layer-title';
export * from './layout';
export * from './use-footer-panel-height';
export * from './use-lightbox';
33 changes: 0 additions & 33 deletions packages/geoview-core/src/core/components/common/layer-title.tsx

This file was deleted.

26 changes: 22 additions & 4 deletions packages/geoview-core/src/core/components/common/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useCallback, ReactNode, useRef, useMemo } from 'react';
import { useTheme } from '@mui/material/styles';
import { logger } from '@/core/utils/logger';
import { LayerList, LayerListEntry } from './layer-list';
import { ResponsiveGridLayout, ResponsiveGridLayoutExposedMethods } from './responsive-grid-layout';
import { LayerTitle } from './layer-title';
import { Tooltip, Typography } from '@/ui';

interface LayoutProps {
children?: ReactNode;
Expand All @@ -26,6 +27,7 @@ export function Layout({
onGuideIsOpen,
}: LayoutProps): JSX.Element {
const responsiveLayoutRef = useRef<ResponsiveGridLayoutExposedMethods>(null);
const theme = useTheme();

/**
* Handles clicks to layers in left panel. Sets selected layer.
Expand Down Expand Up @@ -65,10 +67,26 @@ export function Layout({
* @returns JSX.Element
*/
const renderLayerTitle = useCallback((): JSX.Element => {
// clamping code copied from https://tailwindcss.com/docs/line-clamp
const sxClasses = {
fontSize: theme.palette.geoViewFontSize.lg,
textAlign: fullWidth ? 'center' : 'left',
width: fullWidth ? '100%' : 'auto',
fontWeight: '600',
marginTop: '12px',
overflow: 'hidden',
display: '-webkit-box',
'-webkit-box-orient': 'vertical',
'-webkit-line-clamp': '2',
...(!fullWidth && { [theme.breakpoints.up('md')]: { display: 'none' } }),
};

return (
<LayerTitle hideTitle fullWidth={fullWidth}>
{memoLayerTitle}
</LayerTitle>
<Tooltip title={memoLayerTitle} placement="top" arrow>
<Typography sx={sxClasses} component="div">
{memoLayerTitle}
</Typography>
</Tooltip>
);
}, [fullWidth, memoLayerTitle]);

Check warning on line 91 in packages/geoview-core/src/core/components/common/layout.tsx

View workflow job for this annotation

GitHub Actions / Build demo files / build-geoview

React Hook useCallback has missing dependencies: 'theme.breakpoints' and 'theme.palette.geoViewFontSize.lg'. Either include them or remove the dependency array

Check warning on line 91 in packages/geoview-core/src/core/components/common/layout.tsx

View workflow job for this annotation

GitHub Actions / Build demo files / build-geoview

React Hook useCallback has missing dependencies: 'theme.breakpoints' and 'theme.palette.geoViewFontSize.lg'. Either include them or remove the dependency array

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import { Theme } from '@mui/material/styles';
// ? I doubt we want to define an explicit type for style properties?
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const getSxClasses = (theme: Theme): any => ({
rightButtonsContainer: {
display: 'flex',
flexDirection: 'row',
gap: '0.6rem',
backgroundColor: theme.palette.geoViewColor.primary.lighten(0.5, 0.4),
borderTopLeftRadius: '1.8rem',
borderTopRightRadius: '0.5rem',
padding: ' 0.5rem 0.5rem 0.5rem 2rem',
borderTop: `0.2rem solid ${theme.palette.geoViewColor.primary.lighten(0.2, 0.4)}`,
borderLeft: `0.2rem solid ${theme.palette.geoViewColor.primary.lighten(0.2, 0.4)}`,
},
rightGridContent: {
border: `2px solid ${theme.palette.geoViewColor.primary.main}`,
borderRadius: '5px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const ResponsiveGridLayout = forwardRef(
variant="contained"
className="style2"
startIcon={isEnlarged ? <ArrowForwardIcon /> : <ArrowBackIcon />}
sx={{ height: '40px', borderRadius: '1.5rem', [theme.breakpoints.down('md')]: { display: 'none' } }}
sx={{ height: '40px', borderRadius: '1.5rem', boxShadow: 'none', [theme.breakpoints.down('md')]: { display: 'none' } }}
onClick={() => handleIsEnlarge(!isEnlarged)}
tooltip={isEnlarged ? t('dataTable.reduceBtn')! : t('dataTable.enlargeBtn')!}
tooltipPlacement="top"
Expand Down Expand Up @@ -261,7 +261,7 @@ const ResponsiveGridLayout = forwardRef(

return (
<Box ref={ref}>
<ResponsiveGrid.Root sx={{ pt: 8, pb: 8 }} ref={panelTitleRef}>
<ResponsiveGrid.Root sx={{ pt: 8, pb: 0 }} ref={panelTitleRef}>
{!fullWidth && (
<ResponsiveGrid.Left
isRightPanelVisible={isRightPanelVisible}
Expand All @@ -284,14 +284,16 @@ const ResponsiveGridLayout = forwardRef(
<Box
sx={{
display: 'flex',
alignItems: 'center',
alignItems: fullWidth ? 'end' : 'center',
flexDirection: fullWidth ? 'column' : 'row',
gap: fullWidth ? '10px' : '0',
[theme.breakpoints.up('md')]: { justifyContent: fullWidth ? 'space-between' : 'right' },
[theme.breakpoints.down('md')]: { justifyContent: 'space-between' },
}}
>
{rightTop ?? <Box />}

<Box sx={{ display: 'flex', flexDirection: 'row', gap: '0.6rem' }}>
<Box sx={sxClasses.rightButtonsContainer}>
{!fullWidth && !hideEnlargeBtn && renderEnlargeButton()}
{!!guideContentIds?.length && renderGuideButton()}
{!isMapFullScreen && renderFullScreenButton()}
Expand Down

0 comments on commit 62ae1d4

Please sign in to comment.