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

[Themes] colorManipulator cleanup #3966

Merged
merged 3 commits into from
Apr 14, 2016
Merged

[Themes] colorManipulator cleanup #3966

merged 3 commits into from
Apr 14, 2016

Conversation

mbrookes
Copy link
Member

  • PR has tests - oodles of em! / docs demo, and is linted.
  • Commit and PR titles begin with [ComponentName], and are in imperative form: "[Component] Fix leaky abstraction".
  • Description explains the issue / use-case resolved, and auto-closes the related issue(s) (http://tr.im/vFqem).

This started out as work to fix a bug in lighten() that was affecting styling in Chip, but it soon became apparent that there were broader issues.

This PR has three commits:

[Themes] Remove default export from colorManipulator

  • Self explanatory

[Themes] Overhaul colorManipulator

  • Fix lighten() - it returned incorrect values
  • Simplify lighten() - remove default alpha (use fade() instead)
  • Fix darken() - it returned incorrect values, and was foobar for hsl
  • Fix converColorToString() - Correct hsl output (adds '%' where needed)
  • Fix decomposeColor() - return values as numbers not strings
    Previously it broke formula where addition of a number to a string resulted in a string ('2' + 2 = '22')
  • Refactor getContrastRatio() formula - remove conditional
  • Fix getContrastRatio() (return a number, not a string)
  • Remove getContrastRatioLevel() (dead code)
  • Update getLuminance() to support hsl
  • Refactor and simplfy fade()
  • Document everything, including jshint style @param tags
  • Test all the things - 44 new unit tests!

[Themes] Move some duplicate logic out of getMuiTheme.js

  • Create a new function emphasize() which darkens a light color and lightens a dark color according to luminance. (Will be used in Chip)
  • Update some styles in getMuiTheme.js to use the new function.
  • More tests.

This started out as work to fix a bug in `lighten()` that was
affecting styling in `Chip`, but it soon became apparent that
there were broader issues.

* Fix `lighten()` - it returned incorrect values
* Simplify `lighten()` - remove default alpha (use `fade()` instead)
* Fix `darken()` - it returned incorrect values, and was foobar for hsl
* Fix `converColorToString()` - Correct hsl output (adds '%' where needed)
* Fix `decomposeColor()` - return values as numbers not strings
  Previously it broke formula where addition of a number to a string
* Refactor `getContrastRatio()` formula - remove conditional
* Fix `getContrastRatio()` (return a number, not a string)
* Remove `getContrastRatioLevel()` (dead code)
* Update `getLuminance()` to support hsl
* Refactor and simplfy `fade()`
* Document everything, including jshint style `@param` tags
* Test all the things - **44 new unit tests!**
@newoga
Copy link
Contributor

newoga commented Apr 13, 2016

This looks like it's going to be awesome 😄

@mbrookes mbrookes added bug 🐛 Something doesn't work PR: Needs Review labels Apr 13, 2016
@nathanmarks
Copy link
Member

Just reviewed it, apart from the one thing I mentioned on gitter (comment block) this looks good. I'll give it one more look over thought in the morning and accept it (pretty tired right now).

Create a new function `emphasize()` which darkens a light color and
lightens a dark color according to luminance.

Update some styles in `getMuiTheme.js` to use the new function.

Has tests.
@nathanmarks
Copy link
Member

@callemall/material-ui one of you give this a once over!

@alitaheri
Copy link
Member

Looking good 👍 👍

@alitaheri alitaheri merged commit e12f3f5 into mui:master Apr 14, 2016
@mbrookes mbrookes deleted the color-manipulator-cleanup branch April 14, 2016 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants