mapbox / mapbox/mapbox-gl-js

Coerce strings to colors automatically in expressions

Open
#8,713 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cross-platform :tv: feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

For some reason, the `'#ffff2f'` is not valid and it now requires the `to-color` conversion. Is this expected?

```js
paint: {
// does not work
// "line-color": [
// 'at',
// 2,
// ['literal', ['#d7191c', '#fdae31', '#ffff2f', '#a6d96a', '#1a9641']],
// ],

// works
"line-color": [
'to-color',
[
'at',
2,
['literal', ['#d7191c', '#fdae31', '#ffff2f', '#a6d96a', '#1a9641']],
]
],
},
```

Example: https://jsfiddle.net/NameFILIP/oLw1ysjm/42/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the line-color expression from the linked JSFiddle and trace how the expression result is validated for color properties. No source files or tests are named in the issue, so identify the relevant expression and paint-property code first. Done means the expected handling of hexadecimal color strings is established and covered by the appropriate behavior or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.