wcag-color
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -5,1 +5,2 @@ export type Score = 'Fail' | 'AA Large' | 'AA' | 'AAA' | ||
export declare const scoreFromRatio: (ratio: number) => Score | ||
export declare const best: (firstColor: string, secondColor: string, background: string) => string |
@@ -334,2 +334,17 @@ 'use strict'; | ||
function calculate$1(first, second, background) { | ||
var firstRatio = calculate(first, background); | ||
var secondRatio = calculate(second, background); | ||
var match = firstRatio > secondRatio; | ||
if (match) { | ||
return first; | ||
} else { | ||
return second; | ||
} | ||
} | ||
/* No side effect */ | ||
// Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE | ||
function calculateFromRatio(ratio) { | ||
@@ -347,3 +362,3 @@ if (ratio >= 7.0) { | ||
function calculate$1(foreground, background) { | ||
function calculate$2(foreground, background) { | ||
return calculateFromRatio(calculate(foreground, background)); | ||
@@ -355,8 +370,10 @@ } | ||
var ratio = calculate; | ||
var score = calculate$1; | ||
var score = calculate$2; | ||
var scoreFromRatio = calculateFromRatio; | ||
var best = calculate$1; | ||
/* No side effect */ | ||
exports.best = best; | ||
exports.ratio = ratio; | ||
exports.score = score; | ||
exports.scoreFromRatio = scoreFromRatio; |
@@ -330,2 +330,17 @@ var out_of_memory = | ||
function calculate$1(first, second, background) { | ||
var firstRatio = calculate(first, background); | ||
var secondRatio = calculate(second, background); | ||
var match = firstRatio > secondRatio; | ||
if (match) { | ||
return first; | ||
} else { | ||
return second; | ||
} | ||
} | ||
/* No side effect */ | ||
// Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE | ||
function calculateFromRatio(ratio) { | ||
@@ -343,3 +358,3 @@ if (ratio >= 7.0) { | ||
function calculate$1(foreground, background) { | ||
function calculate$2(foreground, background) { | ||
return calculateFromRatio(calculate(foreground, background)); | ||
@@ -351,6 +366,7 @@ } | ||
var ratio = calculate; | ||
var score = calculate$1; | ||
var score = calculate$2; | ||
var scoreFromRatio = calculateFromRatio; | ||
var best = calculate$1; | ||
/* No side effect */ | ||
export { ratio, score, scoreFromRatio }; | ||
export { best, ratio, score, scoreFromRatio }; |
{ | ||
"name": "wcag-color", | ||
"description": "Color constrast helpers to achieve the WCAG 2.0 standard", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "dist/wcag-color.cjs.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/wcag-color.esm.js", |
# WCAG Color | ||
[![npm version](https://badge.fury.io/js/wcag-color.svg)](https://badge.fury.io/js/wcag-color) | ||
[![Build Status](https://travis-ci.com/believer/wcag-color.svg?branch=master)](https://travis-ci.com/believer/wcag-color) | ||
@@ -70,2 +71,19 @@ | ||
### Best color out of two | ||
`best` takes two colors and a background color and returns the color which is | ||
best suited, from a contrast perspective, for that background color. | ||
```js | ||
best(firstColor: string, secondColor: string, background: string) => string | ||
``` | ||
#### Example | ||
```js | ||
import { best } from 'wcag-color' | ||
best('#ffffff', '#000000', '#ffffff') // #000000 | ||
``` | ||
## Score and ratio | ||
@@ -72,0 +90,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
20700
686
94