adobe / leonardo

Generate colors based on a desired contrast ratio
http://www.leonardocolor.io
Apache License 2.0
1.94k stars 104 forks source link

leonardocolor.io website's JS API documentation's updateColor definition to be updated to reflect correct theme.js capabilities #229

Closed dorukde closed 5 months ago

dorukde commented 7 months ago

Description

Leonardo JS API documentation explains the update function as Theme.updateColor = {name, property}

`const red = new Color({...}) // Change the colors ratios theme.updateColor = {name: 'red', ratios: [3, 4.5, 7]};

// Change the colors colorKeys
theme.updateColor = {name: 'red', colorKeys: ['#ff0000']};

// Change the color's name
theme.updateColor = {name: 'red', name: 'Crimson'};`

However, theme.js definition of updateColor uses color: "red" to filter (and to find) the color, and name:"blue" to change the name of the color.

Steps to reproduce

  1. Create a theme
  2. Update color & name of the new color in the theme theme.updateColor = {color: 'blue' name: 'red', colorKeys: ['#ff0000'] }; ` This will find the color with the name blue, and update its name & value at the same time. The documentation is not wrong, however I (and some other developers) found it confusing when filtering from an external function. I think extending the update definition may clarify. I found the definition at theme.js to be more helpful.

Expected behavior

The documentation should explain this capability. I think the theme.js should stay as is, as many projects are probably already consuming it. It makes more sense to update the documentation. There's a comment in theme.js which explains how this function should be used.

Screenshots

Leonardo package and version

leonardocolor.io website

Environment

MacOS

Additional context