Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
wcag-color
Advanced tools
Readme
According to the WHO an estimated 1.3 billion people live with some form of visual impairment. This includes people who are legally blind and people with less than 20/20 vision.
This library helps you achieve the accessibility standards for color contrast outlined in the WCAG 2.0 specification.
npm install wcag-color
ratio
takes two colors, a foreground color, and background color, and returns a contrast ratio. ratio
accepts most color formats:
#0088ff
), shorthand (#08f
) and without hash (08f
)rgb(255, 255, 255)
hsl(210, 100%, 40%)
ratio(foreground: string, background: string) => number
import { ratio } from 'wcag-color'
ratio('hsl(210, 100%, 40%)', '#ffffff') // 5.57
score
takes two colors and returns a score value. Read more below.
score(foreground: string, background: string) => 'Fail' | 'AA Large' | 'AA' | 'AAA'
import { score } from 'wcag-color'
score('hsl(210, 100%, 40%)', '#ffffff') // AA
scoreFromRatio
takes a ratio and returns a score value.
scoreFromRatio(ratio: number) => 'Fail' | 'AA Large' | 'AA' | 'AAA'
import { scoreFromRatio } from 'wcag-color'
scoreFromRatio(7.5) // AAA
best
takes two colors and a background color and returns the color which is
best suited, from a contrast perspective, for that background color.
best(firstColor: string, secondColor: string, background: string) => string
import { best } from 'wcag-color'
best('#ffffff', '#000000', '#ffffff') // #000000
3.0
3.0
.4.5
.7.0
. Valuable for texts that will be read for a longer period of time.FAQs
Color constrast helpers to achieve the WCAG 2.0 standard
The npm package wcag-color receives a total of 2,053 weekly downloads. As such, wcag-color popularity was classified as popular.
We found that wcag-color demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.