Skip to content

Use contrast-switch function for buttons#294

Merged
tysongach merged 1 commit intomasterfrom
tg-contrast-switch
Jun 30, 2017
Merged

Use contrast-switch function for buttons#294
tysongach merged 1 commit intomasterfrom
tg-contrast-switch

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.
@tysongach tysongach force-pushed the tg-contrast-switch branch from c04fe89 to 3d14a7b Compare June 30, 2017 13:36
@tysongach tysongach merged commit 3d14a7b into master Jun 30, 2017
@tysongach tysongach deleted the tg-contrast-switch branch June 30, 2017 13:37
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