{"id":15756096,"url":"https://github.com/mikaello/re-color-contrast","last_synced_at":"2026-01-08T15:33:57.660Z","repository":{"id":36932636,"uuid":"179098301","full_name":"mikaello/re-color-contrast","owner":"mikaello","description":"Calculate color contrast of two colors","archived":false,"fork":false,"pushed_at":"2023-07-11T17:45:23.000Z","size":473,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T12:58:55.455Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Reason","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikaello.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-02T14:42:09.000Z","updated_at":"2022-04-02T15:51:40.000Z","dependencies_parsed_at":"2024-10-31T08:16:34.464Z","dependency_job_id":null,"html_url":"https://github.com/mikaello/re-color-contrast","commit_stats":{"total_commits":44,"total_committers":4,"mean_commits":11.0,"dds":0.4545454545454546,"last_synced_commit":"4c862b4057b3165a8706b7d4a3d6a3d09579b12e"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikaello%2Fre-color-contrast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikaello%2Fre-color-contrast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikaello%2Fre-color-contrast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikaello%2Fre-color-contrast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikaello","download_url":"https://codeload.github.com/mikaello/re-color-contrast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246437294,"owners_count":20777188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T08:41:47.390Z","updated_at":"2026-01-08T15:33:52.629Z","avatar_url":"https://github.com/mikaello.png","language":"Reason","funding_links":[],"categories":[],"sub_categories":[],"readme":"# re-color-contrast\n\n[![NPM version](http://img.shields.io/npm/v/re-color-contrast.svg)](https://www.npmjs.org/package/re-color-contrast)\n[![Build Status](https://travis-ci.org/mikaello/re-color-contrast.svg?branch=master)](https://travis-ci.org/mikaello/re-color-contrast)\n\nReasonML library to calculate color contrast of two colors. The result is a number between 1.0 and 21.0, and can be used to determine if contrast fullfills [WCAG success criterion for color contrast](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html).\n\n## Getting started\n\n```\nyarn add re-color-contrast\n```\n\nThen add `re-color-contrast` as a dependency to `bsconfig.json`:\n\n```diff\n\"bs-dependencies\": [\n+  \"re-color-contrast\"\n]\n```\n\n## Example\n\n```reason\nopen ReColorContrast;\n\nlet blue = \"#00f\";\nlet green = \"#00ff00\";\n\nColorContrast.getContrast(blue, green); // 6.2618 ...\n\nColorContrast.getRelativeLuminance(blue); // 0.0722\n```\n\n## API\n\n- `getContrast(string, string) =\u003e float` - takes in two hex color strings and returns a float in range `[1..21]`. 1 is no contrast, and 21 is best contrast (colors of opposing side of spectrum). See [WCAG](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef) for details on calculation.\n- `getRelativeLuminance(string) =\u003e float` - takes in a hex color string and returns a float in range `[0..1]`. 0 is no luminance and 1 is max. See [WCAG](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef) for details on calculation.\n\n## Alternatives\n\n- [bs-tinycolor](https://github.com/mikaello/bs-tinycolor) has accessibility functions that does contrast checking and more\n- [color-contrast](https://github.com/jescalan/color-contrast) is a JS library with same functionality as this library, but does also accepts all kinds of input formats (not only hex)\n\n## Contribute\n\n- If you find bugs or want to improve this library, feel free to open an issue or PR.\n- If you are upgrading any dependencies, please use yarn so `yarn.lock` is updated.\n- Try to adhere to [Angular commit guidelines](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guideline).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikaello%2Fre-color-contrast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikaello%2Fre-color-contrast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikaello%2Fre-color-contrast/lists"}