burgee/contrast
Every export of burgee/contrast, with its signature and doc comment: mix, ratio, check, report, fieldColorAt, auditBurgee and 3 more, plus 2 types.
Contrast, as a thing the package checks rather than a thing someone remembers.
import { mix, ratio, check, … } from 'burgee/contrast';Functions
auditBurgee
Every contrast relationship a burgee has to survive.
function auditBurgee(brand: AuditInput, grounds?: readonly string[]): ContrastFinding[];| Parameter | Type |
|---|---|
brand | AuditInput |
grounds (optional) | readonly string[] |
Returns ContrastFinding[]
check
function check(what: string, a: string, b: string, required?: 3): ContrastFinding;| Parameter | Type |
|---|---|
what | string |
a | string |
b | string |
required (optional) | 3 |
Returns ContrastFinding
contrast
The WCAG contrast ratio between two colours. Order does not matter.
function contrast(a: string, b: string): number;| Parameter | Type |
|---|---|
a | string |
b | string |
Returns number
fieldColorAt
The field colour at a point along the gradient axis, for stops given in order.
function fieldColorAt(stops: ReadonlyArray<{
offset: number;
color: string;
}>, at: number): string;| Parameter | Type |
|---|---|
stops | ReadonlyArray<{ offset: number; color: string; }> |
at | number |
Returns string
luminance
WCAG relative luminance.
function luminance(hex: string): number;| Parameter | Type |
|---|---|
hex | string |
Returns number
mix
Mix two colours in sRGB. Enough for reading a gradient stop, not for colour science.
function mix(a: string, b: string, t: number): string;| Parameter | Type |
|---|---|
a | string |
b | string |
t | number |
Returns string
ratio
Round to 2dp for reporting, without pretending to more precision than that — roundel's round2.
function ratio(a: string, b: string): number;| Parameter | Type |
|---|---|
a | string |
b | string |
Returns number
report
One line per finding, aligned, for a terminal or a failing test.
function report(findings: readonly ContrastFinding[]): string;| Parameter | Type |
|---|---|
findings | readonly ContrastFinding[] |
Returns string
Constants
AA
The floors WCAG 2.2 sets, as ratios.
const AA: {
/** Body text against its background. */
readonly TEXT: 4.5;
/** Large text, UI components, and meaningful parts of a graphic. */
readonly GRAPHIC: 3;
};Interfaces
AuditInput
interface AuditInput {
mark: {
lead: string;
follow: string;
};
field: ReadonlyArray<{
offset: number;
color: string;
}>;
bordure?: {
color: string;
width: number;
} | ReadonlyArray<{
color: string;
width: number;
}>;
}ContrastFinding
interface ContrastFinding {
/** What was compared, in the words someone fixing it would use. */
what: string;
a: string;
b: string;
ratio: number;
required: number;
passes: boolean;
}burgee/brand
Every export of burgee/brand, with its signature and doc comment: opposedField, burgeeFlagPath, fieldId, chargeTransform, chargeRotation, placeCharge and 8 more, plus 7 types.
burgee/cli
Every export of burgee/cli, with its signature and doc comment: brandCommand, devCommand, migrateCommand, pluginCheckCommand, skillCommand, initCommand and 1 more.