Allow passing custom themes to create layers
So far it was only possible to generate styles based on a set of fixed themes maintained by the protomaps project.
With this change, it is possible to pass a custom colour theme to create layers, without interfering with the final style. Also passing partial themes is possible to override only a small set of properties.
Example:
const myCustomTheme: Theme = {...}
const style = layersWithCustomTheme("protomaps", myCustomTheme)
or
const partialTheme: Partial<Theme> = { background: "#fff" };
const style = layersWithPartialCustomTheme(
"protomaps",
"dark", // use dark theme as base
partialTheme
);
Related issue: https://github.com/protomaps/basemaps/issues/224
This is just my take on addressing this problem. Please let me know if you have any suggestions or if you think some of these changes aren't necessary. And feel free to edit or rename anything.
Thanks :)
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
No data about Duplication
I like the partial theme solution, though I'm trying to imagine the use case where you want to change only one color - it seems more likely we will want a way to selectively remove a layer completely instead of just change the color values. Is the partial theme solution as implemented here enough for your use case?
Thanks!