faker icon indicating copy to clipboard operation
faker copied to clipboard

faker.internet.color -> faker.color.?

Open matthewmayer opened this issue 2 years ago • 9 comments

faker.internet.color is a bit of an oddity in the faker.internet module which "Generates a random css hex color code in aesthetically pleasing color palette."

Deprecate and move to... faker.color.internet? faker.color.rgbFromBase?

matthewmayer avatar Mar 21 '23 16:03 matthewmayer

Just a random thought for "internet css colors" There is a finite set of all browser supported named css colors: https://www.w3schools.com/cssref/css_colors.php

Shinigami92 avatar Mar 21 '23 16:03 Shinigami92

without reading the code, i would never have guessed the current implementation.

matthewmayer avatar Mar 21 '23 16:03 matthewmayer

TBH, I don't see a problem here. I dont think we need to change anything.

The ColorModule obviously has a lot of different color-related functions. The InternetModule obviously has many different functions related to the internet.

If you now think about a color in the internet (from a dev perspective) - CSS is the first thing that comes to my mind. I may be biased since I am a frontend dev.

xDivisionByZerox avatar Mar 22 '23 09:03 xDivisionByZerox

without reading the code, i would never have guessed the current implementation.

Good thing we have documentation, so you don't need to read the source code :)

xDivisionByZerox avatar Mar 22 '23 09:03 xDivisionByZerox

Team Decision

We will try to merge the color function with color.rgb as an option. In the long run we want to deprecate the internet.color method.

ST-DDT avatar Mar 23 '23 16:03 ST-DDT

this seems logical, it could be an option for faker.color.rgb to make "nice" colors.

Also TBH if you want "nice" colors nowadays it's way easier to not use RGB but another color space like HSB or HSL, because you can fix the saturation and brightness/lightness and just change the hue, and you get nice matching colors.

matthewmayer avatar Mar 23 '23 17:03 matthewmayer

this seems logical, it could be an option for faker.color.rgb to make "nice" colors.

Also TBH if you want "nice" colors nowadays it's way easier to not use RGB but another color space like HSB or HSL, because you can fix the saturation and brightness/lightness and just change the hue, and you get nice matching colors.

So you mean we can just deprecate the internet.color at all and just suggest to switch to the color module and use a fitting method for the use case?

Shinigami92 avatar Mar 24 '23 07:03 Shinigami92

Not quite because the faker.color.* etc don't have a way to supply a base color. So I guess that would be needed first.

matthewmayer avatar Mar 24 '23 09:03 matthewmayer

For reference, some example colors for faker.internet.color (with and without a base color) vs faker.color.rgb:

image

https://stackblitz.com/edit/faker-js-demo-861y3v

whether its "aethetically pleasing" is a matter of opinion :)

matthewmayer avatar Mar 25 '23 05:03 matthewmayer