Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing custom themes to create layers #234

Merged
merged 2 commits into from
May 10, 2024

Conversation

Edefritz
Copy link
Contributor

@Edefritz Edefritz commented Apr 8, 2024

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: #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 :)

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 color theme to create layers, without interfering with the final style. Also passing partial themes is possible to override only a small set of properties.
Copy link

sonarcloud bot commented Apr 9, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@bdon
Copy link
Member

bdon commented May 8, 2024

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?

@bdon bdon merged commit c4c2211 into protomaps:main May 10, 2024
4 checks passed
@bdon
Copy link
Member

bdon commented May 10, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants