Skip to content

Commit

Permalink
Merge pull request #5 from mapbox/color-limiter-option
Browse files Browse the repository at this point in the history
Add a color limiter option
  • Loading branch information
tristen authored May 22, 2024
2 parents d03ecd1 + 6e0ce1a commit c13c3d5
Show file tree
Hide file tree
Showing 6 changed files with 10,121 additions and 23 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Returns

| Option | Value | Default | Description |
| --- | --- | --- | --- |
| `brightness` | `Number` | `undefined` | Adjusts brightness percentage from the derived min/max range. |
| `saturation` | `Number` | `undefined` | Adjusts saturation percentage from the derived min/max range. |
| `brightness` | `Number` | 0 | Adjusts brightness percentage from the derived min/max range. |
| `saturation` | `Number` | 0 | Adjusts saturation percentage from the derived min/max range. |
| `limit` | `Array` | `[]` | Limits the higher range of hues for a given color. Options can be `red`, `orange`, `yellow`, `green`, `blue`, `purple`, or `pink`. |

### Developing

Expand Down
4 changes: 3 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ <h1 class="txt-h4 txt-fancy block mb6">@mapbox/to-color</h1>
['mapbox.mapbox-streets-v8', 16, { saturation: 0.5 }],
['mapbox.mapbox-streets-v8', 16, { saturation: 1.5 }],
['mapbox.mapbox-streets-v8', 16, { brightness: 0.5 }],
['mapbox.mapbox-streets-v8', 16, { brightness: 1.5 }]
['mapbox.mapbox-streets-v8', 16, { brightness: 1.5 }],
['mapbox.mapbox-streets-v8', 16, { brightness: 1.5, limit: ['blue'] }]
].forEach(swatch => {
const seed = swatch[0];
const count = swatch[1];
Expand All @@ -47,6 +48,7 @@ <h1 class="txt-h4 txt-fancy block mb6">@mapbox/to-color</h1>
const { hsl } = s.getColor();
const swatchContainerItem = document.createElement('div');
swatchContainerItem.classList = `px12 py12 flex-child flex-child--grow h120`;
swatchContainerItem.style.flexBasis = 0;
swatchContainerItem.textContent = swatchContainerItem.title = swatchContainerItem.style.backgroundColor = hsl.formatted;
swatchContainer.appendChild(swatchContainerItem);
};
Expand Down
Loading

0 comments on commit c13c3d5

Please sign in to comment.