Skip to content

Instantly share code, notes, and snippets.

View sgomes's full-sized avatar

Sérgio Gomes sgomes

View GitHub Profile
@sgomes
sgomes / functions.scss
Last active September 27, 2022 12:36
[Using Sass to automatically pick text colors] #4 - step 2
/**
* Calculate the luminance for a color.
* See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
*/
@function luminance($color) {
$red: nth($linear-channel-values, red($color) + 1);
$green: nth($linear-channel-values, green($color) + 1);
$blue: nth($linear-channel-values, blue($color) + 1);
@return .2126 * $red + .7152 * $green + .0722 * $blue;
@sgomes
sgomes / step1.scss
Last active December 21, 2016 15:50
[Using Sass to automatically pick text colors] #3 - step 1
$theme-color: #3f51b5 !default;
theme-color-bg {
background-color: $theme-color;
}
theme-color-bg-contrast {
color: choose-contrast-color($theme-color);
}
@sgomes
sgomes / known.css
Created December 21, 2016 15:06
[Using Sass to automatically pick text colors] #1 - known colors
dark-background-contrast {
color: white;
}
light-background-contrast {
color: black;
}
@sgomes
sgomes / output.css
Last active December 21, 2016 15:03
[Using Sass to automatically pick text colors] #2 - desired output
theme-color-bg {
background-color: #3f51b5;
}
theme-color-bg-contrast {
color: white;
}
@sgomes
sgomes / gist:732d76689db163ea4b94
Created January 13, 2015 14:20
Keybase proof
### Keybase proof
I hereby claim:
* I am sgomes on github.
* I am sgomes (https://keybase.io/sgomes) on keybase.
* I have a public key whose fingerprint is E59A DF7F F82A E973 F7CF 196B B273 014C 8B9F 3B03
To claim this, I am signing this object: