Code Monkey home page Code Monkey logo

tints-and-shades's Introduction

Screenshot of app home page Screenshot of color swatches after submitting form Perfect score on Lighthouse

What is the Tint & Shade Generator?

The purpose of this tool is to accurately produce tints (pure white added) and shades (pure black added) of a given hex color in 10% increments.

Why is this tool unique?

It takes the math seriously. In my experience similar tools get the calculation incorrect due to rounding errors, creator preferences, or other inconsistencies.

Testing shows that the output matches Chrome DevTools' calculation method as well as some established, popular methods to derive tints and shades via Sass.

When would I use this?

It's best used when you already have some base colors but would like complimentary colors for gradients, borders, backgrounds, shadows or other elements.

This is useful for designers who may be communicating color intent to developers who use Sass or PostCSS in their builds. It's also a solid way to quickly preview what tints and shades look like for a base color you may be considering for your design.

I've also heard it's useful for teachers, data professionals, and people who make presentations.

Calculation method

The given hex color is first converted to RGB. Then each component of the RGB color has the following calculation performed on it, respectively.

  • Tints: New value = current value + ((255 - current value) x tint factor)
  • Shades: New value = current value x shade factor

The new value is rounded if necessary, and then converted back to hex for display.

Example calculation

Let's say we want tints and shades of Rebecca Purple, #663399.

10% tint

  1. #663399 is converted to the RGB equivalent of 102, 51, 153
  2. R: 102 + ((255 - 102) x .1) = 117.3, rounded to 117
  3. G: 51 + ((255 - 51) x .1) = 71.4, rounded to 71
  4. B: 153 + ((255 - 153) x .1) = 163.2, rounded to 163
  5. RGB 117, 71, 163 is converted to the hex equivalent of #7547a3

10% shade

  1. #663399 is converted to the RGB equivalent of 102, 51, 153
  2. R: 102 x .9 = 91.8, rounded to 92
  3. G: 51 x .9 = 45.9, rounded to 46
  4. B: 153 x .9 = 137.7, rounded to 138
  5. RGB 92, 46, 138 is converted to the hex equivalent of #5c2e8a

Feedback and contributing

This project is open source and I'd love your help!

If you notice a bug or want a feature added please file an issue on GitHub. If you don't have an account there, just email me the details.

If you're a developer and want to help with the project, please comment on open issues or create a new one and communicate your intentions. Once we agree on a path forward you can just make a pull request and take it to the finish line.

Support this project

The Tint & Shade Generator will always be free but your support is greatly appreciated.

Credits

Michael Edelstone designed and organized the project with big-time assistance from Nick Wing on the color calculations.

We use these amazing open-source libraries across the project:

Many thanks to Joel Carr, Sebastian Gutierrez, Tim Scalzo, Aman Agarwal, Aleksandr Hovhannisyan, Shubhendu Sen, and Luis Escarrilla for their valuable contributions.

Other details

  • Typography: Work Sans by Wei Huang
  • Colors: #000000, #ffffff, #e96443, and #ca228e
  • Performance: We have a perfect score on Google's web page auditing tool, Lighthouse. Check out the full report.
  • Privacy: We use Google Analytics to record basic information about your visit strictly to improve the application and understand the people who use it.
  • Like Google's Material Design? Try this other thing I made.

tints-and-shades's People

Contributors

aleksandrhovhannisyan avatar amanagarwal041 avatar edelstone avatar joelcarr avatar latesc avatar pepas24 avatar sen-442b avatar tjscalzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tints-and-shades's Issues

#ffffff color cell at bottom right of color table copies in all caps

For some reason, the color #fffffff copies in all caps, like #FFFFFF. This only happens when #ffffff is in the bottom right of the table. So if you used #ffffff as the color to generate tints and shades, even though all the tint table cells are #ffffff, only the right-most #ffffff cell copies in all caps.

Show feedback when hex code is successfully copied

Since #8 we now have the ability to copy hex codes by clicking on a color square. It might be a nice addition to the UX to give some feedback to the user when they've successfully copied a hex code, like a tooltip that says "Copied!" or the copy icon morphs into a green checkmark.

GitHub kind of does both; we could just use one of these ideas...

SeBVw5LCeA

Consider suggesting a color name when supplying tints/shades

Got an email from one Nguyen Tung asking if it would be possible to give a name suggestion for the color after a hex is supplied. Perhaps some designers don't like coming up with color names. Not sure where we'd start with this or how it might work/look, but he did supply this link and said it has an API: https://www.colorhexa.com/color-names. Maybe we could just give the name of the closest official HTML color name, although I think the emailer was wanting more unique names.

Personally when I'm making color systems, if a color is the Danger color, for example, I just call that color "red". I'm not typically looking for a clever variant like "cherry" or "ferrari" or something like that. Exception being if the brand is very expressive I may choose a naming convention that speaks to their identity.

Consider making a Figma plugin that mimics the Tint & Shade Generator precisely

I've had a few emails about a Tint and Shade Generator Figma plugin over the last year. Just received this today from Daniele in Australia:

Hi, I love your tool you’ve created,

I wish you had that exact tool to generate shades straight into Figma, with squares ready to be used into a UI KIT.

Thanks,
Daniele

He subsequently told me the exact math is the missing factor in the various current Figma plugin options available now. For those who don't need/want the exact formula that the Tint & Shade Generator provides (i.e. 10 each of tints and shades using a very particular formula), check out one of below Figma plugins to see if they meet your needs:

  1. Color Shades (this is the one Daniele uses)
  2. Tints and Shades
  3. Color Designer

Include # in codes shown under colors?

It's kind of misleading to show just the code because when you copy a color it includes the #. I think it would make more sense to show the code exactly as it will be copied.

Add dark mode

This could help when evaluating tints and shades for dark interfaces. Would be cool if it could remember state for return visits and across pages within the app (/about, /404).

Think of the possibilities!

Screen Shot 2020-04-18 at 2 15 20 PM

Consider adding complimentary colors for all the tints and shades

Received this email from David Eno requesting a new feature. This would obviously add a lot of complexity – feel free to comment.

Hi Michael

Your Tint and Shade Generator is really useful and I'm sure I'll return frequently now I've found it.

It would be amazing if this could also show the complimentaries for all the tints and shades - something I need quite often.

Thanks for all the hard work

Regards

David

Better error messaging

Right now the only validation on the form is catching blank submissions. Ideally we'd have some error messaging for other issues.

Make it possible to generate CSS/SCSS variables out of tint and shades

Problem

If you want to use the generated colors as variables (CSS/SCSS) in your code base, you have to copy every single value one by one and paste it in correct place.

Solution

Make it possible to create CSS/SCSS variables from tint and shades.
Might be related to this: #30
Would especially be useful in combination with this feature: #32

How could it work?

Define the color, name for your variable and the amount of tint and shades to be generated. Hit "generate variables" button.

Example

Color: #00a870
Name: accent-color
Amount of tint and shades: 9

Result CSS-Variables

--accent-color-100: #cceee2;
--accent-color-200: #99dcc6;
--accent-color-300: #66cba9;
--accent-color-400: #33b98d;
--accent-color-500: #00a870; // main color
--accent-color-600: #00865a;
--accent-color-700: #006543;
--accent-color-800: #00432d;
--accent-color-900: #002216;

Result SCSS-Variables

$accent-color-100: #cceee2;
$accent-color-200: #99dcc6;
$accent-color-300: #66cba9;
$accent-color-400: #33b98d;
$accent-color-500: #00a870; // main color
$accent-color-600: #00865a;
$accent-color-700: #006543;
$accent-color-800: #00432d;
$accent-color-900: #002216;

Happy to discuss how the prefix numbers (in this case: 100-900) should determined and how the range of colors should be calculated.

Remove black and white from tint and shade tails?

Right now we include #ffffff and #000000 squares at the end of each tint and shade table row.

My question is, should we do that? We could be leaving those off from the tin/shade palette. I'm not sure if it's superfluous or repetitive, or perhaps helps with orientation around the color suggestions.

Looking for feedback. Thanks.

Submit button cannot be focused in Safari?

When navigating with the keyboard, hitting tab while in the text area will skip over the submit button completely. I noticed this bug when I was working on #10 but didn't realize that it indicated a major piece of functionality was broken. I will try to take a look at what might be causing this. But I'm not well-versed in browser-specific issues so I'm not sure how much help I'll be.

I am using Safari 13.0.2 on macOS 10.15 Catalina.

Handling of hex shorthand

Right now "333" would not work, while "333333" does. Ideally the former would also be a valid input.

Consider adding a way to copy an entire set of tints or shades

Has anyone wanted the ability to copy out an entire set of tints, shades, or both with a single click?

Not sure how this would behave or where the functionality would live; just making an issue to see if anyone has any comments. Feel free to chime in or thumbs-up the issue.

[Feature Request] Color Picker & Live Tints & Shades

Color Picker

There can be a color picker field along with the text input field. Sometimes we need minor changes in the base color's hue, saturation, etc. The Coolors color picker is the best I came around.

Live Tints & Shades

Since we may be adjusting, let's say the hue, it would be better to see how the tints & shades will look in realtime instead of hitting the Generate button every time.

Better and more consistent keyboard tabbing/focus behavior across browsers

Keyboard tabbing through the site, and particularly the color table after copying a hex color, is not standard across browsers.

The way Chrome treats tabbing after a copy seems to be the most ideal way to me: After copying, the focus appears to stay on the copied cell even though the copy/checkmark button disappears. If you tab again from this position, the next table cell is focused. This seems logical to me, but it's not the current behavior in FF or Safari on the Mac, and perhaps other browsers too.

Would be cool if the keyboard tabbing was standardized around this. We had a PR that initially played with this a bit (#23) but it was abandoned. There might be some useful comments/code there.

Persist settings across sessions

We now have a switch that allows a user to copy colors with the hashtag prefix or without, and there are issues for a dark mode option (#31) and a way to have more or fewer tints or shades generated (#32).

It would be good if the browser remembered these settings for the user. @AleksandrHovhannisyan has made a suggestion how to do this here, and I made this issue in response. Seems like it can be done independently of the other settings-based issues.

Show percentage levels of each swatch for quick glance reference

Got an email from Justin with the following suggestion. Thumbs up or comment if you have the same concern.

----

Hi Michael,

Thank you so much for the maketintsandshades.com tool – I use it almost every day in my role as a web designer. I just wanted to make a feature suggestion which I find myself constantly looking for – when I’m testing tints/shades to see what works best, it would be super useful to have the percentage somewhere near the swatch so you can easily distinguish between 40% and 50% for example. Sometimes I find myself having to count across the swatches to find which one I’ve used or tried.

Thank you so much!

Justin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.