Skip to content

Commit

Permalink
Use @hurumap/core/LocationTag in pesayetu
Browse files Browse the repository at this point in the history
  • Loading branch information
kilemensi committed Jul 15, 2024
1 parent 087156a commit dcfc5db
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 38 deletions.
13 changes: 6 additions & 7 deletions apps/pesayetu/src/components/HURUmap/Location/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { LocationTag } from "@hurumap/core";
import { Box } from "@mui/material";
import clsx from "clsx";
import PropTypes from "prop-types";
import React from "react";

import useStyles from "./useStyles";

import LocationHighlight from "@/pesayetu/components/HURUmap/LocationHighlight";
import LocationTag from "@/pesayetu/components/HURUmap/LocationTag";

function Location({ className, highlights, isLoading, tags, ...props }) {
const classes = useStyles(props);
Expand Down Expand Up @@ -34,11 +33,11 @@ function Location({ className, highlights, isLoading, tags, ...props }) {
{...tag}
active={index === tags.length - 1}
variant="highlight"
classes={{
root: classes.tag,
level: classes.tagLevel,
name: classes.tagName,
}}
sx={(theme) => ({
"&:not(:first-of-type)": {
marginLeft: theme.typography.pxToRem(10),
},
})}
/>
))}
</Box>
Expand Down
7 changes: 0 additions & 7 deletions apps/pesayetu/src/components/HURUmap/Location/useStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ const useStyles = makeStyles(({ palette, typography }) => ({
)} ${typography.pxToRem(12)} ${typography.pxToRem(21)}`,
width: typography.pxToRem(600),
},
tag: {
"&:not(:first-of-type)": {
marginLeft: typography.pxToRem(10),
},
},
tagLevel: {},
tagName: {},
highlights: {
borderTop: `1px solid ${palette.grey.main}`,
marginTop: 4.5,
Expand Down
46 changes: 22 additions & 24 deletions apps/pesayetu/src/components/HURUmap/Map/Layers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LocationTag } from "@hurumap/core";
import { ThemeProvider, StyledEngineProvider } from "@mui/material/styles";
import makeStyles from "@mui/styles/makeStyles";
import L from "leaflet";
import PropTypes from "prop-types";
import React, { useCallback, useEffect, useRef } from "react";
Expand All @@ -13,14 +12,6 @@ import theme, {
CHART_SECONDARY_COLOR_SCHEME,
} from "@/pesayetu/theme";

const useStyles = makeStyles(() => ({
locationtag: {
position: "absolute",
top: 0,
left: 0,
},
}));

const primaryGeoStyles = {
inactive: {
color: CHART_PRIMARY_COLOR_SCHEME[3],
Expand Down Expand Up @@ -100,27 +91,37 @@ function Layers({
parentsGeometries,
secondaryGeography,
selectedBoundary,
...props
}) {
const map = useMap();
const groupRef = useRef();
const siblingRef = useRef();
const classes = useStyles(props);

const pinIcon = L.divIcon({
html: ReactDOMServer.renderToStaticMarkup(
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<LocationTag
IconButtonProps={{
children: <CancelIcon />,
MarkerProps={{
children: <CancelIcon sx={{ fill: "currentColor" }} />,
sx: {
"&:hover": {
color: "#666666",
"& .Component108-4_svg__b": {
stroke: theme.palette.text?.secondary,
},
},
},
}}
level={geography?.level}
name={geography?.name?.toLowerCase()}
code={geography?.code}
classes={{ root: classes.locationtag }}
color="primary"
variant="marker"
sx={{
left: 0,
position: "absolute",
top: 0,
}}
/>
</ThemeProvider>
</StyledEngineProvider>,
Expand All @@ -141,10 +142,14 @@ function Layers({
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<LocationTag
color={isPinOrCompare ? "secondary" : "primary"}
level={level}
name={name.toLowerCase()}
classes={{ root: classes.locationtag }}
color={isPinOrCompare ? "secondary" : "primary"}
sx={{
left: 0,
position: "absolute",
top: 0,
}}
/>
</ThemeProvider>
</StyledEngineProvider>,
Expand Down Expand Up @@ -206,14 +211,7 @@ function Layers({
}
}
},
[
classes.locationtag,
geography,
isPinOrCompare,
secondaryGeography,
locationCodes,
onClick,
],
[geography, isPinOrCompare, secondaryGeography, locationCodes, onClick],
);

useEffect(() => {
Expand Down

0 comments on commit dcfc5db

Please sign in to comment.