Skip to content

Commit

Permalink
Merge pull request #1061 from datopian/feature/style-in-map-component
Browse files Browse the repository at this point in the history
Created the style property for the map component
  • Loading branch information
Gutts-n authored Dec 20, 2023
2 parents f23d796 + 4ddfc11 commit 2ec1437
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-trainers-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@portaljs/components': patch
---

Created the style property in the Map component
15 changes: 9 additions & 6 deletions packages/components/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ export type MapProps = {
ending: string;
};
tooltip?:
| {
propNames: string[];
}
| boolean;
| {
propNames: string[];
}
| boolean;
_id?: number;
}[];
title?: string;
center?: { latitude: number | undefined; longitude: number | undefined };
zoom?: number;
style?: Object;
};

export function Map({
Expand All @@ -44,6 +45,7 @@ export function Map({
center = { latitude: 45, longitude: 45 },
zoom = 2,
title = '',
style = {}
}: MapProps) {
const [isLoading, setIsLoading] = useState<boolean>(false);
const [layersData, setLayersData] = useState<any>([]);
Expand Down Expand Up @@ -96,6 +98,7 @@ export function Map({
zoom={zoom}
scrollWheelZoom={false}
className="h-80 w-full"
style={style ?? {}}
// @ts-ignore
whenReady={(map: any) => {
// Enable zoom using scroll wheel
Expand All @@ -104,13 +107,13 @@ export function Map({
// Create the title box
var info = new L.Control() as any;

info.onAdd = function () {
info.onAdd = function() {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};

info.update = function () {
info.update = function() {
this._div.innerHTML = `<h4 style="font-weight: 600; background: #f9f9f9; padding: 5px; border-radius: 5px; color: #464646;">${title}</h4>`;
};

Expand Down
3 changes: 3 additions & 0 deletions packages/components/stories/Map.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const meta: Meta = {
zoom: {
description: 'Zoom level',
},
style: {
description: "Styles for the container"
}
},
};

Expand Down

1 comment on commit 2ec1437

@vercel
Copy link

@vercel vercel bot commented on 2ec1437 Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

portaljs-storybook – ./packages/components/

portaljs-storybook-datopian1.vercel.app
portaljs-storybook-git-main-datopian1.vercel.app
storybook.portaljs.org
portaljs-storybook.vercel.app

Please sign in to comment.