Skip to content

Commit

Permalink
Build(deps): bump css-color-converter from 1.1.1 to 2.0.0 in /badge-m…
Browse files Browse the repository at this point in the history
…aker (#5615)

* Build(deps): bump css-color-converter in /badge-maker

Bumps [css-color-converter](https://github.com/andyjansson/css-color-converter) from 1.1.1 to 2.0.0.
- [Release notes](https://github.com/andyjansson/css-color-converter/releases)
- [Changelog](https://github.com/andyjansson/css-color-converter/blob/master/CHANGELOG.md)
- [Commits](https://github.com/andyjansson/css-color-converter/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Update implementation and package-lock.json

* Fix some URLs which switched to HTTP

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: PyvesB <PyvesDev@gmail.com>
  • Loading branch information
dependabot-preview[bot] and PyvesB committed Sep 28, 2020
1 parent 63f56f0 commit 501c53a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
12 changes: 5 additions & 7 deletions badge-maker/lib/color.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const cssColorConverter = require('css-color-converter')
const { fromString } = require('css-color-converter')

// When updating these, be sure also to update the list in `badge-maker/README.md`.
const namedColors = {
Expand Down Expand Up @@ -38,10 +38,7 @@ function isHexColor(s = '') {
}

function isCSSColor(color) {
return (
typeof color === 'string' &&
typeof cssColorConverter(color.trim()).toRgbaArray() !== 'undefined'
)
return typeof color === 'string' && fromString(color.trim())
}

function normalizeColor(color) {
Expand Down Expand Up @@ -73,8 +70,9 @@ function toSvgColor(color) {

function brightness(color) {
if (color) {
const rgb = cssColorConverter(color).toRgbaArray()
if (rgb) {
const cssColor = fromString(color)
if (cssColor) {
const rgb = cssColor.toRgbaArray()
return +((rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 255000).toFixed(2)
}
}
Expand Down
4 changes: 2 additions & 2 deletions badge-maker/lib/color.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test(normalizeColor, () => {
given(' blue ').expect(' blue ')
given('rgb(100%, 200%, 222%)').expect('rgb(100%, 200%, 222%)')
given('rgb(122, 200, 222)').expect('rgb(122, 200, 222)')
given('rgb(100%, 200, 222)').expect('rgb(100%, 200, 222)')
given('rgb(122, 200, 222, 1)').expect('rgb(122, 200, 222, 1)')
given('rgba(100, 20, 111, 1)').expect('rgba(100, 20, 111, 1)')
given('hsl(122, 200%, 222%)').expect('hsl(122, 200%, 222%)')
given('hsla(122, 200%, 222%, 1)').expect('hsla(122, 200%, 222%, 1)')
Expand All @@ -46,8 +46,8 @@ test(normalizeColor, () => {
given(''),
given('not-a-color'),
given('#ABCFGH'),
given('rgb(122, 200, 222, 1)'),
given('rgb(-100, 20, 111)'),
given('rgb(100%, 200, 222)'),
given('rgba(-100, 20, 111, 1.1)'),
given('hsl(122, 200, 222, 1)'),
given('hsl(122, 200, 222)'),
Expand Down
10 changes: 4 additions & 6 deletions badge-maker/lib/make-badge.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ describe('The badge generator', function () {
]).expect('#abc123')
// valid rgb(a)
given('rgb(0,128,255)').expect('rgb(0,128,255)')
given('rgb(220,128,255,0.5)').expect('rgb(220,128,255,0.5)')
given('rgba(0,0,255)').expect('rgba(0,0,255)')
given('rgba(0,128,255,0)').expect('rgba(0,128,255,0)')
// valid hsl(a)
given('hsl(100, 56%, 10%)').expect('hsl(100, 56%, 10%)')
given('hsl(360,50%,50%,0.5)').expect('hsl(360,50%,50%,0.5)')
given('hsla(25,20%,0%,0.1)').expect('hsla(25,20%,0%,0.1)')
given('hsla(0,50%,101%)').expect('hsla(0,50%,101%)')
// CSS named color.
given('papayawhip').expect('papayawhip')
// Shields named color.
Expand All @@ -53,12 +57,6 @@ describe('The badge generator', function () {
// invalid hex
given('#123red'), // contains letter above F
given('#red'), // contains letter above F
// invalid rgb(a)
given('rgb(220,128,255,0.5)'), // has alpha
given('rgba(0,0,255)'), // no alpha
// invalid hsl(a)
given('hsl(360,50%,50%,0.5)'), // has alpha
given('hsla(0,50%,101%)'), // no alpha
// neither a css named color nor colorscheme
given('notacolor'),
given('bluish'),
Expand Down
2 changes: 1 addition & 1 deletion badge-maker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"anafanafo": "^1.0.0",
"css-color-converter": "^1.1.1"
"css-color-converter": "^2.0.0"
},
"scripts": {
"test": "echo 'Run tests from parent dir'; false"
Expand Down
21 changes: 16 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 501c53a

Please sign in to comment.