Skip to content

Commit 80a4a4e

Browse files
authored
native-like styles for interactive features (#478)
* native-like styles for interactive features * Use `LinkText` system color (if supported) to highlight interactive features * Remove `.mapml-vector-container` scope for feature styles Per #478 (comment). * Use `#0000EE` fallback color for interactive features
1 parent 987a8f5 commit 80a4a4e

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/mapml/layers/FeatureLayer.js

+18-12
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,23 @@ export var MapMLFeatures = L.FeatureGroup.extend({
1313
// info: https://github.com/Leaflet/Leaflet/pull/4597
1414
L.DomUtil.addClass(this._container, 'leaflet-pane mapml-vector-container');
1515
L.setOptions(this.options.renderer, {pane: this._container});
16-
let anim = L.DomUtil.create("style", "mapml-feature-animation", this._container);
17-
anim.innerHTML = `@keyframes pathSelect {
18-
0% {stroke: white;}
19-
50% {stroke: black;}
20-
}
21-
g:focus > path,
22-
path:focus {
23-
animation-name: pathSelect;
24-
animation-duration: 1s;
25-
stroke-width: 5;
26-
stroke: black;
16+
let style = L.DomUtil.create("style", "mapml-feature-style", this._container);
17+
style.innerHTML = `
18+
g[role="link"]:focus,
19+
g[role="link"]:hover,
20+
g[role="button"]:focus,
21+
g[role="button"]:hover,
22+
g[role="link"] path:focus,
23+
g[role="link"] path:hover,
24+
g[role="button"] path:focus,
25+
g[role="button"] path:hover,
26+
g[role="link"]:focus path,
27+
g[role="link"]:hover path,
28+
g[role="button"]:focus path,
29+
g[role="button"]:hover path {
30+
outline: 0!important;
31+
stroke: #0000EE;
32+
stroke: LinkText;
2733
}`;
2834
}
2935

@@ -310,7 +316,7 @@ export var MapMLFeatures = L.FeatureGroup.extend({
310316
_removeCSS: function(){
311317
let toDelete = this._container.querySelectorAll("link[rel=stylesheet],style");
312318
for(let i = 0; i < toDelete.length;i++){
313-
if(toDelete[i].classList.contains("mapml-feature-animation")) continue;
319+
if(toDelete[i].classList.contains("mapml-feature-style")) continue;
314320
this._container.removeChild(toDelete[i]);
315321
}
316322
},

0 commit comments

Comments
 (0)