Last active
June 9, 2020 13:36
-
-
Save philwolstenholme/718a13a5a6e9267edf88c6bc8a98f5ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function randomSkinTone() { | |
const fitzPatrickTones = [ | |
'#ffe2cc', | |
'#fadbaf', | |
'#e5bd95', | |
'#bf8b60', | |
'#98562e', | |
'#673929', | |
]; | |
const tone = _.sample(fitzPatrickTones); | |
const element = document.createElement('style'); | |
element.innerHTML = `.random-skin-tone-fill { fill: ${tone} !important; }`; | |
const header = document.getElementsByTagName('HEAD')[0]; | |
header.appendChild(element); | |
})(); |
(Note the Lodash dependency on line #11, but that could be swapped with any method of randomly picking an item from an array)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Colours are based on https://en.wikipedia.org/wiki/Fitzpatrick_scale and the hex codes are taken from https://notebook.hongkonggong.com/2017/10/12/inclusive-skintones/