Skip to content

Commit 501c53a

Browse files
Build(deps): bump css-color-converter from 1.1.1 to 2.0.0 in /badge-maker (#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] <[email protected]> * 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 <[email protected]>
1 parent 63f56f0 commit 501c53a

File tree

5 files changed

+28
-21
lines changed

5 files changed

+28
-21
lines changed

badge-maker/lib/color.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

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

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

4040
function isCSSColor(color) {
41-
return (
42-
typeof color === 'string' &&
43-
typeof cssColorConverter(color.trim()).toRgbaArray() !== 'undefined'
44-
)
41+
return typeof color === 'string' && fromString(color.trim())
4542
}
4643

4744
function normalizeColor(color) {
@@ -73,8 +70,9 @@ function toSvgColor(color) {
7370

7471
function brightness(color) {
7572
if (color) {
76-
const rgb = cssColorConverter(color).toRgbaArray()
77-
if (rgb) {
73+
const cssColor = fromString(color)
74+
if (cssColor) {
75+
const rgb = cssColor.toRgbaArray()
7876
return +((rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 255000).toFixed(2)
7977
}
8078
}

badge-maker/lib/color.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test(normalizeColor, () => {
3737
given(' blue ').expect(' blue ')
3838
given('rgb(100%, 200%, 222%)').expect('rgb(100%, 200%, 222%)')
3939
given('rgb(122, 200, 222)').expect('rgb(122, 200, 222)')
40-
given('rgb(100%, 200, 222)').expect('rgb(100%, 200, 222)')
40+
given('rgb(122, 200, 222, 1)').expect('rgb(122, 200, 222, 1)')
4141
given('rgba(100, 20, 111, 1)').expect('rgba(100, 20, 111, 1)')
4242
given('hsl(122, 200%, 222%)').expect('hsl(122, 200%, 222%)')
4343
given('hsla(122, 200%, 222%, 1)').expect('hsla(122, 200%, 222%, 1)')
@@ -46,8 +46,8 @@ test(normalizeColor, () => {
4646
given(''),
4747
given('not-a-color'),
4848
given('#ABCFGH'),
49-
given('rgb(122, 200, 222, 1)'),
5049
given('rgb(-100, 20, 111)'),
50+
given('rgb(100%, 200, 222)'),
5151
given('rgba(-100, 20, 111, 1.1)'),
5252
given('hsl(122, 200, 222, 1)'),
5353
given('hsl(122, 200, 222)'),

badge-maker/lib/make-badge.spec.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ describe('The badge generator', function () {
3434
]).expect('#abc123')
3535
// valid rgb(a)
3636
given('rgb(0,128,255)').expect('rgb(0,128,255)')
37+
given('rgb(220,128,255,0.5)').expect('rgb(220,128,255,0.5)')
38+
given('rgba(0,0,255)').expect('rgba(0,0,255)')
3739
given('rgba(0,128,255,0)').expect('rgba(0,128,255,0)')
3840
// valid hsl(a)
3941
given('hsl(100, 56%, 10%)').expect('hsl(100, 56%, 10%)')
42+
given('hsl(360,50%,50%,0.5)').expect('hsl(360,50%,50%,0.5)')
4043
given('hsla(25,20%,0%,0.1)').expect('hsla(25,20%,0%,0.1)')
44+
given('hsla(0,50%,101%)').expect('hsla(0,50%,101%)')
4145
// CSS named color.
4246
given('papayawhip').expect('papayawhip')
4347
// Shields named color.
@@ -53,12 +57,6 @@ describe('The badge generator', function () {
5357
// invalid hex
5458
given('#123red'), // contains letter above F
5559
given('#red'), // contains letter above F
56-
// invalid rgb(a)
57-
given('rgb(220,128,255,0.5)'), // has alpha
58-
given('rgba(0,0,255)'), // no alpha
59-
// invalid hsl(a)
60-
given('hsl(360,50%,50%,0.5)'), // has alpha
61-
given('hsla(0,50%,101%)'), // no alpha
6260
// neither a css named color nor colorscheme
6361
given('notacolor'),
6462
given('bluish'),

badge-maker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
"dependencies": {
3838
"anafanafo": "^1.0.0",
39-
"css-color-converter": "^1.1.1"
39+
"css-color-converter": "^2.0.0"
4040
},
4141
"scripts": {
4242
"test": "echo 'Run tests from parent dir'; false"

package-lock.json

Lines changed: 16 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)