Skip to content
This repository was archived by the owner on Nov 3, 2022. It is now read-only.

No grade bug fix#1

Open
diego-codes wants to merge 12 commits intoIBM-Design:masterfrom
diego-codes:no-grade-bug-fix
Open

No grade bug fix#1
diego-codes wants to merge 12 commits intoIBM-Design:masterfrom
diego-codes:no-grade-bug-fix

Conversation

@diego-codes
Copy link
Copy Markdown

@diego-codes diego-codes commented Feb 22, 2017

This PR addresses the issue submitted in the colors repo: IBM-Design/colors#53

Problem

The assumption is that if I use the color function without a grade argument, I should get the core grade of the color I am requesting:

.foo {
  color: color('blue'); // Core grade is 50, so the color to return should be #2d74da
}

The default value for the $grade parameter in the color() function is set to 0 which currently no color has this as a possible grade. Updating the default $grade value to a number that does in fact exist in all palettes doesn't work because each color has a different core grade associated with it.

Solution

The solution I have come up with is to add one more grade item to each color map in the output _bee-palette.scss with the key of core and value of whatever that palette's core grade hex value is. This way we can set the default value for $grade in the color() function to 'core' and fulfill the expected behavior of calling the color() function without supplying a grade.

Along with this solutions, I took the liberty to:

  • Update the .ase, .json, and .scl output templates to include the core grade value.
  • Improve (fix?) error handling inside of the color() function to throw an error if the user provides a color or grade that does not exist as well as a warning if they're outside of the $alpha channel value range.
  • Lastly, added unit tests for the color() function using True and Mocha! Sadly, I don't think there is a way to test for errors which would have been nice.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant