-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[colorManipulator][docs] Document the color helpers #13039
Comments
At work, we are often using these helpers by tapping into the private API 🤷♂️. Keeping the module within a reasonable size is critical for Material-UI. In the long run, I think that moving the styles folder into a @mbrookes What about keeping it where it is now? |
I would prefer to be able to use the color manipulator functions without having to download the entire core library. I think it would be sensible to create a |
@petermikitsh We are working on improving that overhead, but I understand the motivation: https://packagephobia.now.sh/result?p=%40material-ui%2Fcore . @mbrookes What do you think of a |
@oliviertassinari sure, why not. What else would you include? Yes, it's a dupe of #10789. |
@oliviertassinari Besides what we've discussed here already (e.g., moving the styles directory into a separate module), is there anything else you'd like to see in a PR that could close this issue and #10789? |
Not strictly true - all offer varying degrees of additional functionality; somewhat proportional to their size. The exception is colorManipulator's
I thought it would be helpful to benchmark the function (or method) names that are used for equivalents to Note that some of these functions take a relative value, e.g.
My preference for I don't have a strong preference for an alternative name |
I would add polished to the list of libraries to benchmark against. I agree, setAlpha > fade. What do you think of rgba as a name suggestion? |
polished added. Interesting that two other the libraries use The only issue with |
I would add CSS, Post CSS, SASS and Less in the benchmark list. We handle the same problem https://alligator.io/css/color-function/. |
Huh, interesting. So maybe |
👍 for |
For "Darken light / lighten dark": |
Sort of, but only if you were to apply a sufficiently large coefficient, and even then, the degree of contrast would be arbitrary. for example if you significantly emphasise a color that is only just on the dark side of the luminosity threshold, the contrast ratio would be much less than for the same transformation of say black, or near black. The typical use case is to slightly lighten a dark color, or slightly darken a light color, rather than to create a contrasting color. |
I was curious about the polished bundle size cost for us to use it. I couldn't get tree-shaking to work. With ES5 modules, the bundle size cost is +3 kB gzipped. |
Going back to the original problem stated :) Now that these helpers are part of the |
for lazy ppl like me who end up at this page: |
Does it still make sense to take time to document these color utilities in Q4 2023, given that MUI System is set to be replaced with the zero-runtime CSS-in-JS package? |
Expected Behavior
I've done a comparison of various JS color utility libraries. I found that
@material-ui/core/es/styles/colorManipulator.js
offers the smallest bundle size of all options I could find. Here's a comparison to other libraries (all numbers are minified; second number is minified + gzipped):Current Behavior
@oliviertassinari has stated that the color manipulator is a private API. He also openly asked if there were better open-source alternatives to the private implementation. In my view, there is no better alternative. colorManipulator.js offers basically identical functionality to all of the other libraries, and does it in the fewest amount of bytes.
Context
Color Manipulation is a very generic problem, this library has the best solution, but it is a private API. I think it could be easily publishable as a separate entity within the mono-repo structure. It's already fully unit tested, so there could be no disagreement that it would be in a good state to make publicly accessible.
The text was updated successfully, but these errors were encountered: