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

Add a color limiter option #5

Merged
merged 5 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading