Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
22 lines (19 sloc)
480 Bytes
This file contains 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
import getContrast from './getContrast'; | |
const guidelines = { | |
decorative: 1.5, | |
readable: 3, | |
aa: 4.5, | |
aaa: 7, | |
}; | |
/** | |
* Returns whether or not a color has bad contrast against a background | |
* according to a given standard. | |
*/ | |
function hasBadContrast( | |
color: string, | |
standard: 'decorative' | 'readable' | 'aa' | 'aaa' = 'aa', | |
background: string = '#fff' | |
): boolean { | |
return getContrast(color, background) < guidelines[standard]; | |
} | |
export default hasBadContrast; |