Skip to content

Commit 5c79467

Browse files
maidi29agviegas
andauthored
feat(front): Make cluster element customizable (#578)
* Make cluster element styleable Add possibility to edit the styling defaults of the cluster element (the number defining the count of merged markers) * Remove empty lines --------- Co-authored-by: Antonio González Viegas <[email protected]>
1 parent a58020a commit 5c79467

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

packages/front/src/core/Marker/index.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,24 @@ export class Marker extends OBC.Component implements OBC.Disposable {
8989
*/
9090
autoCluster = true;
9191

92+
private static readonly DEFAULT_CLUSTER_STYLES = {
93+
backgroundColor: "#FFFFFF",
94+
textColor: "#000000",
95+
fontSize: "1.2rem",
96+
fontWeight: "500",
97+
borderRadius: "50%",
98+
padding: "5px 11px",
99+
textAlign: "center",
100+
cursor: "pointer",
101+
hoverBackgroundColor: "#BCF124",
102+
transition: undefined,
103+
};
104+
105+
// Customizable cluster element styles
106+
clusterElementStyles: Partial<typeof Marker.DEFAULT_CLUSTER_STYLES> = {
107+
...Marker.DEFAULT_CLUSTER_STYLES,
108+
};
109+
92110
/**
93111
* A Map containing the markers grouped by world UUID.
94112
* Each world can have its own set of markers.
@@ -425,10 +443,10 @@ export class Marker extends OBC.Component implements OBC.Disposable {
425443
div.style.padding = "5px 11px";
426444
div.style.textAlign = "center";
427445
div.addEventListener("pointerover", () => {
428-
div.style.background = "#BCF124";
446+
div.style.background = hoverBackgroundColor;
429447
});
430448
div.addEventListener("pointerout", () => {
431-
div.style.background = "#FFFFFF";
449+
div.style.background = backgroundColor;
432450
});
433451
return div;
434452
};

0 commit comments

Comments
 (0)