diff --git a/packages/.eslintrc b/packages/.eslintrc index 6f45fd9dd1d..58741c355ff 100644 --- a/packages/.eslintrc +++ b/packages/.eslintrc @@ -74,6 +74,7 @@ { "endOfLine": "auto" } - ] + ], + "require-await": 1 // warning } } diff --git a/packages/geoview-basemap-panel/src/basemap-panel-style.ts b/packages/geoview-basemap-panel/src/basemap-panel-style.ts new file mode 100644 index 00000000000..8d4e13646b4 --- /dev/null +++ b/packages/geoview-basemap-panel/src/basemap-panel-style.ts @@ -0,0 +1,81 @@ +/* @ts-expect-error there is no mui style in this package */ +export const getSxClasses = (theme) => ({ + basemapCard: { + '& .MuiCard-root': { + backgroundColor: theme.palette.grey.A700, + color: theme.palette.primary.light, + display: 'flex', + flexDirection: 'column', + backgroundClip: 'padding-box', + border: '1px solid rgba(255,255,255,0.25)', + borderRadius: '6px', + boxShadow: 'none', + marginBottom: '16px', + transition: 'all 0.3s ease-in-out', + '&:last-child': { + marginBottom: '0px', + }, + }, + '& .MuiCardHeader-root': { + backgroundColor: `${theme.palette.grey.A700} !important`, + color: theme.basemapPanel.header, + fontSize: 14, + fontWeight: 400, + margin: 0, + padding: '0 12px', + height: 60, + width: '100%', + order: 2, + }, + '& .MuiCardContent-root': { + order: 1, + height: 190, + position: 'relative', + padding: 0, + '&:last-child': { + padding: 0, + }, + '& .basemapCardThumbnail': { + position: 'absolute', + height: '100%', + width: '100%', + objectFit: 'cover', + top: 0, + left: 0, + }, + '& .basemapCardThumbnailOverlay': { + display: 'block', + height: '100%', + width: '100%', + position: 'absolute', + backgroundColor: theme.basemapPanel.overlayDefault, + transition: 'all 0.3s ease-in-out', + }, + }, + '&:hover': { + cursor: 'pointer', + borderColor: theme.basemapPanel.borderHover, + '& .MuiCardContent-root': { + '& .basemapCardThumbnailOverlay': { + backgroundColor: theme.basemapPanel.overlayHover, + }, + }, + }, + '&.active': { + borderColor: theme.basemapPanel.borderActive, + '& .MuiCardContent-root': { + '& .basemapCardThumbnailOverlay': { + backgroundColor: theme.basemapPanel.overlayActive, + }, + }, + '&:hover': { + borderColor: 'rgba(255,255,255,0.75)', + '& .MuiCardContent-root': { + '& .basemapCardThumbnailOverlay': { + backgroundColor: 'rgba(0,0,0,0)', + }, + }, + }, + }, + }, +}); diff --git a/packages/geoview-basemap-panel/src/basemap-panel.tsx b/packages/geoview-basemap-panel/src/basemap-panel.tsx index 6eaf281c18c..687dcf5375d 100644 --- a/packages/geoview-basemap-panel/src/basemap-panel.tsx +++ b/packages/geoview-basemap-panel/src/basemap-panel.tsx @@ -10,6 +10,7 @@ import { TypeBasemapOptions, TypeValidMapProjectionCodes, } from 'geoview-core'; +import { getSxClasses } from './basemap-panel-style'; const w = window as TypeWindow; @@ -25,7 +26,7 @@ export function BasemapPanel(props: BaseMapPanelProps): JSX.Element { const myMap = cgpv.api.maps[mapId]; const { api, ui, react } = cgpv; - const { Select, Card } = ui.elements; + const { Select, Card, Box } = ui.elements; const { useState, useEffect } = react; @@ -33,85 +34,9 @@ export function BasemapPanel(props: BaseMapPanelProps): JSX.Element { const [activeBasemapId, setActiveBasemapId] = useState(''); const [canSwichProjection] = useState(config.canSwichProjection); - const useStyles = ui.makeStyles((theme) => ({ - basemapCard: { - backgroundColor: theme.palette.grey.A700, - color: theme.palette.primary.light, - display: 'flex', - flexDirection: 'column', - backgroundClip: 'padding-box', - border: `1px solid ${theme.basemapPanel.borderDefault}`, - borderRadius: 6, - boxShadow: 'none', - marginBottom: 16, - transition: 'all 0.3s ease-in-out', - '&:last-child': { - marginBottom: 0, - }, - '& .MuiCardHeader-root': { - backgroundColor: theme.palette.grey.A700, - color: theme.basemapPanel.header, - fontSize: 14, - fontWeight: 400, - margin: 0, - padding: '0 12px', - height: 60, - width: '100%', - order: 2, - }, - '& .MuiCardContent-root': { - order: 1, - height: 190, - position: 'relative', - padding: 0, - '&:last-child': { - padding: 0, - }, - '& .basemapCardThumbnail': { - position: 'absolute', - height: '100%', - width: '100%', - objectFit: 'cover', - top: 0, - left: 0, - }, - '& .basemapCardThumbnailOverlay': { - display: 'block', - height: '100%', - width: '100%', - position: 'absolute', - backgroundColor: theme.basemapPanel.overlayDefault, - transition: 'all 0.3s ease-in-out', - }, - }, - '&:hover': { - cursor: 'pointer', - borderColor: theme.basemapPanel.borderHover, - '& .MuiCardContent-root': { - '& .basemapCardThumbnailOverlay': { - backgroundColor: theme.basemapPanel.overlayHover, - }, - }, - }, - '&.active': { - borderColor: theme.basemapPanel.borderActive, - '& .MuiCardContent-root': { - '& .basemapCardThumbnailOverlay': { - backgroundColor: theme.basemapPanel.overlayActive, - }, - }, - '&:hover': { - borderColor: 'rgba(255,255,255,0.75)', - '& .MuiCardContent-root': { - '& .basemapCardThumbnailOverlay': { - backgroundColor: 'rgba(0,0,0,0)', - }, - }, - }, - }, - }, - })); - const classes = useStyles(); + const theme = ui.useTheme(); + + const sxClasses = getSxClasses(theme); // TODO: change the path for getting projection on schema refactor const projections: number[] = @@ -220,7 +145,7 @@ export function BasemapPanel(props: BaseMapPanelProps): JSX.Element { }, []); return ( -
+ {canSwichProjection && (