UNPKG

831 BJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = meetsContrastGuidelines;
5var _getContrast = _interopRequireDefault(require("./getContrast"));
6function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
7/**
8 * Determines which contrast guidelines have been met for two colors.
9 * Based on the [contrast calculations recommended by W3](https://www.w3.org/WAI/WCAG21/Understanding/contrast-enhanced.html).
10 *
11 * @example
12 * const scores = meetsContrastGuidelines('#444', '#fff');
13 */
14function meetsContrastGuidelines(color1, color2) {
15 var contrastRatio = (0, _getContrast["default"])(color1, color2);
16 return {
17 AA: contrastRatio >= 4.5,
18 AALarge: contrastRatio >= 3,
19 AAA: contrastRatio >= 7,
20 AAALarge: contrastRatio >= 4.5
21 };
22}
23module.exports = exports.default;
\No newline at end of file