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

Use contrast-switch function for buttons #294

Merged
merged 1 commit into from
Jun 30, 2017
Merged

Conversation

tysongach
Copy link
Contributor

Bourbon comes with a contrast-switch function which switches between
two colors based on the contrast to another color. In this case, we
check the contrast of the button's background color and output either
black or white for the text color. It helps to ensure button text is
accessible.

No visual difference with the button's look-and-feel occurs by using
contrast-switch, as we were already within the acceptable contrast
ratio range.

This change also DRYs up the use of $action-color and creates a better
system to add further variations of button colors in the future.
Meaning, you can easily add something like
$_button-secondary-background-color when the time comes.

Finally, this closely mimics the variables we have set up in the
_forms partial, as well.

@mborsare
Copy link

Seems legit 🥇

@kylefiedler
Copy link
Contributor

Fancy. 👍

@tysongach
Copy link
Contributor Author

Here’s a few examples of this in action. The switching of white and black text inside the button is contrast-switch doing its thing.

localhost-4567- 1

localhost-4567- 2

localhost-4567-

Bourbon comes with a `contrast-switch` function which switches between
two colors based on the contrast to another color. In this case, we
check the contrast of the button's background color and output either
black or white for the text color. It helps to ensure button text is
accessible.

No visual difference with the button's look-and-feel occurs by using
`contrast-switch`, as we were already within the acceptable contrast
ratio range.

This change also DRYs up the use of `$action-color` and creates a better
system to add further variations of button colors in the future.
Meaning, you can easily add something like
`$_button-secondary-background-color` when the time comes.

Finally, this closely mimics the variables we have set up in the
`_forms` partial, as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants