-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: color swatches for layers and layer groups (#1379)
* feat: implement color swatches for layers and layer groups * feat: implement better color swatch position * chore: lint and format * chore: rename story * style: make color swatches consistent with the size of checkboxes * test: add case to check if color swatch appears correctly * chore: add missing comment
- Loading branch information
1 parent
ac619ba
commit c6bd1ce
Showing
7 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { html } from "lit"; | ||
import { | ||
STORIES_MAP_STYLE, | ||
STORIES_LAYER_SENTINEL_HUB, | ||
STORIES_LAYER_REGION, | ||
STORIES_LAYER_S2, | ||
STORIES_LAYER_OSM, | ||
} from "../src/enums"; | ||
|
||
const COLORED_LAYERS = [ | ||
{ | ||
type: "Group", | ||
properties: { | ||
id: "group2", | ||
title: "Data Layers", | ||
layerControlExpand: true, | ||
description: "# Hello world", | ||
}, | ||
layers: [ | ||
{ | ||
...STORIES_LAYER_SENTINEL_HUB.wind, | ||
color: "#008955", | ||
}, | ||
{ | ||
...STORIES_LAYER_SENTINEL_HUB.no2, | ||
color: "#008397", | ||
}, | ||
{ | ||
...STORIES_LAYER_REGION, | ||
color: "#007bcb", | ||
}, | ||
], | ||
}, | ||
{ | ||
type: "Group", | ||
properties: { | ||
id: "group1", | ||
title: "Background Layers", | ||
}, | ||
layers: [STORIES_LAYER_S2, STORIES_LAYER_OSM], | ||
}, | ||
]; | ||
|
||
export const LayerColor = { | ||
args: { | ||
idProperty: "id", | ||
titleProperty: "title", | ||
unstyled: false, | ||
}, | ||
render: (args) => html` | ||
<div style="display: flex"> | ||
<eox-layercontrol | ||
.idProperty=${args.idProperty} | ||
.titleProperty=${args.titleProperty} | ||
.unstyled=${args.unstyled} | ||
for="eox-map" | ||
></eox-layercontrol> | ||
<eox-map | ||
.style=${STORIES_MAP_STYLE} | ||
.zoom=${3} | ||
.layers=${COLORED_LAYERS} | ||
></eox-map> | ||
</div> | ||
`, | ||
}; | ||
|
||
export default LayerColor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Check if the color swatch appears when a `color` property is present | ||
const colorSwatch = () => { | ||
// Set up the layers in the mock map | ||
cy.get("mock-map").then(($el) => { | ||
const mockMap = $el[0]; // Accessing the mock map element | ||
|
||
// Setting layers: one visible and another with layerControlDisable: true | ||
mockMap.setLayers([ | ||
{ visible: true, color: "green" }, | ||
{ properties: { layerControlDisable: true } }, | ||
]); | ||
}); | ||
|
||
// Verify the effect on the LayerControl | ||
cy.get("eox-layercontrol") | ||
.shadow() | ||
.within(() => { | ||
cy.get(".color-swatch").should("exist"); | ||
}); | ||
}; | ||
|
||
export default colorSwatch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters