faker-js / faker

Generate massive amounts of fake data in the browser and node.js
https://fakerjs.dev
Other
13.04k stars 920 forks source link

faker.internet.color -> faker.color.? #1959

Open matthewmayer opened 1 year ago

matthewmayer commented 1 year ago

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?

Shinigami92 commented 1 year ago

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

matthewmayer commented 1 year ago

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

xDivisionByZerox commented 1 year ago

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 commented 1 year ago

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 :)

ST-DDT commented 1 year ago

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.

matthewmayer commented 1 year ago

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.

Shinigami92 commented 1 year ago

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?

matthewmayer commented 1 year ago

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 commented 1 year ago

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 :)