Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: color module #801

Merged
merged 82 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
3fc9231
feat: add seperate color module and definition
harsohailB Apr 7, 2022
4f21dee
feat: add color definitions to LocalDefinition
harsohailB Apr 7, 2022
0dbb047
chore: move color definitions for all locales
harsohailB Apr 7, 2022
7b979b3
feat: update all locales color files
harsohailB Apr 7, 2022
e210ebd
Merge pull request #1 from harsohailB/feature/color-module-locales-ch…
harsohailB Apr 7, 2022
4fc40a6
feat: add test file for color module
harsohailB Apr 7, 2022
feadbbb
feat: add rgb generation in both hex and decimal format
harsohailB Apr 7, 2022
a634a54
feat: add generation of rgba in hex and decimal format
harsohailB Apr 7, 2022
2627330
feat: add seeded tests for rgb and rgba methods
harsohailB Apr 7, 2022
43bbe3a
feat: add generation of CMYK colors
harsohailB Apr 7, 2022
10a7307
feat: simplify generation of rgba hex generation
harsohailB Apr 7, 2022
b9f438e
feat: add hsla generation
harsohailB Apr 7, 2022
9eb05eb
fix: change percentage generation to have percision of two decimal pl…
harsohailB Apr 7, 2022
79bf1d9
fix: change # in docs to 0x to match method outputs
harsohailB Apr 8, 2022
f731676
fix: generate locales again to fix syntax
harsohailB Apr 8, 2022
44dd389
fix: add a period at the end of docs
harsohailB Apr 8, 2022
c7f255e
fix: revert deletion of color method in commerce and add deprecation …
harsohailB Apr 8, 2022
ffaaad7
fix: rename methods that return hex format to have suffix Hex in meth…
harsohailB Apr 8, 2022
5e8515b
feat: add options for prefix and letter casing to hex colors
harsohailB Apr 8, 2022
dc45280
fix: change commerce color method to call color API
harsohailB Apr 8, 2022
ec6147d
feat: create percentage generator in commerce and use it in color module
harsohailB Apr 8, 2022
8d4234f
feat: create percentage generator in commerce and use it in color module
harsohailB Apr 8, 2022
38cb1ec
feat: add hwb, lab, and lch generation and tests
harsohailB Apr 9, 2022
ac58157
feat: add display p3 generation and test
harsohailB Apr 9, 2022
4f5c9cb
feat: add formating and options to rgb generation
harsohailB Apr 9, 2022
ed68ec7
feat: add formatting options to cmyk generation
harsohailB Apr 9, 2022
f66fd4c
feat: add formatting options to hsl generator
harsohailB Apr 9, 2022
32e1056
feat: add formatting options to hwb generator
harsohailB Apr 9, 2022
4a71385
feat: add formatting options for lab, lch, and display-p3 generators
harsohailB Apr 9, 2022
9e26b3b
feat: add seeded tests for all functions
harsohailB Apr 9, 2022
c676431
feat: add random color gamut name generator and test
harsohailB Apr 9, 2022
643d25e
fix: return css strings from switch cases and add default rgb case
harsohailB Apr 9, 2022
579f015
fix: remove string quotes around array return type of rgb() example
harsohailB Apr 9, 2022
317ec86
fix: change color definition object to be partial
harsohailB Apr 9, 2022
c91b5c2
fix: change color definition object for all locales to be partial
harsohailB Apr 9, 2022
ba84e5b
fix: change colorSpace fallback to rgb for toColorFormat function to …
harsohailB Apr 9, 2022
0272c06
feat: create the seperation between color gamut and color space
harsohailB Apr 10, 2022
1f58b0d
fix: make gamut readonly in color definition to resolve assignment error
harsohailB Apr 10, 2022
977be94
feat: seperate CSS functions, color spaces, and create their generators
harsohailB Apr 10, 2022
35a8424
fix: update options object doc casing
harsohailB Apr 11, 2022
3fa7156
chore: change inline if statement to be on new line
harsohailB Apr 11, 2022
f0e031c
fix: spelling mistake in docs for "formatted"
harsohailB Apr 11, 2022
eef1d6d
fix: add type to map function on values
harsohailB Apr 11, 2022
b1b87ab
fix: small grammatical, typos, and type inferences
harsohailB Apr 11, 2022
b4b475a
fix: only calculate percentages in toCSS when needed
harsohailB Apr 11, 2022
73a98a4
feat: extract color format to be reused
harsohailB Apr 11, 2022
d1e8905
feat: improve readability of rgb generator
harsohailB Apr 11, 2022
d0eafbb
feat: use js Array to construct arrays
harsohailB Apr 11, 2022
75674dd
fix: remove percentage generator from commerce and generate percentag…
harsohailB Apr 11, 2022
e8c65f4
fix: update docs noticeable typo
harsohailB Apr 16, 2022
fcfea40
fix: simplify toColorFormat switch statement
harsohailB Apr 16, 2022
80cc9cb
fix: condition for checking if number is a float
harsohailB Apr 16, 2022
07314ac
feat: add doc for hex format option in rgb function
harsohailB Apr 16, 2022
8a9b9d6
fix: move css functions and spaces out of locales into color.ts
harsohailB Apr 17, 2022
8c6dad4
feat: change rgb() default values to (prefix:#, case:lower)
harsohailB Apr 17, 2022
11fdcc8
feat: add function overloading to generators that can return string o…
harsohailB Apr 17, 2022
b7d871d
feat: add overloaded return types for when no options are passed
harsohailB Apr 17, 2022
8e8f04f
fix: remove first condition in isFloat check and make css functions a…
harsohailB Apr 17, 2022
3e7da9e
chore: change type case option to be named casing
harsohailB Apr 18, 2022
2df75b6
Merge branch 'main' into feature/color-module
Shinigami92 Apr 18, 2022
9d5cd2c
chore: run generate scripts
Shinigami92 Apr 18, 2022
e62bd40
chore: merge in main branch
harsohailB May 9, 2022
dfcaa8f
fix: color module import into color spec file
harsohailB May 9, 2022
1ee36fd
fix: update seed call in color spec file
harsohailB May 9, 2022
d261bdb
fix: move function comments to last signature to be picked up by docs
harsohailB May 18, 2022
2cc1f63
chore: run generate:locales
harsohailB May 18, 2022
ecd90df
Merge branch 'main' into feature/color-module
Shinigami92 May 19, 2022
ae17a7b
chore: update docs
Shinigami92 May 19, 2022
07a3d1e
chore: fix docs
Shinigami92 May 19, 2022
1701a1a
chore: replace internal usage
Shinigami92 May 19, 2022
da9da56
chore: fix generate:locales script
Shinigami92 May 19, 2022
3a919d3
chore: generate locales
Shinigami92 May 19, 2022
76b7ced
chore: reexport color types
Shinigami92 May 19, 2022
88e3553
chore: not the module
Shinigami92 May 19, 2022
aa9a14b
Merge branch 'main' into feature/color-module
Shinigami92 May 21, 2022
83374fc
Merge branch 'main' into feature/color-module
Shinigami92 May 21, 2022
7d312b3
chore: add additional signaturs for docs
Shinigami92 May 21, 2022
9a4e06e
chore: apply suggestions
ST-DDT May 21, 2022
0f9c312
Merge branch 'main' into feature/color-module
Shinigami92 May 21, 2022
2516b16
Merge branch 'main' into feature/color-module
Shinigami92 May 22, 2022
b172a94
chore: apply jsdoc suggestions
Shinigami92 May 22, 2022
61c2bc2
Merge branch 'main' into feature/color-module
Shinigami92 May 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.vitepress/api-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export const apiPages = [
{ text: 'Address', link: '/api/address.html' },
{ text: 'Animal', link: '/api/animal.html' },
{ text: 'Color', link: '/api/color.html' },
{ text: 'Commerce', link: '/api/commerce.html' },
{ text: 'Company', link: '/api/company.html' },
{ text: 'Database', link: '/api/database.html' },
Expand Down
1 change: 1 addition & 0 deletions scripts/generateLocales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type DefinitionsType = {
const definitionsTypes: DefinitionsType = {
address: 'AddressDefinitions',
animal: 'AnimalDefinitions',
color: 'ColorDefinitions',
commerce: 'CommerceDefinitions',
company: 'CompanyDefinitions',
database: 'DatabaseDefinitions',
Expand Down
15 changes: 15 additions & 0 deletions src/definitions/color.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { LocaleEntry } from './definitions';

/**
* The possible definitions related to color.
*/
export type ColorDefinitions = LocaleEntry<{
/**
* Human readable color names
*/
human: string[];
/**
* Color space names.
*/
space: string[];
}>;
4 changes: 0 additions & 4 deletions src/definitions/commerce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import type { LocaleEntry } from './definitions';
* The possible definitions related to commerce.
*/
export type CommerceDefinitions = LocaleEntry<{
/**
* Human readable color names
*/
color: string[];
/**
* Department names inside a shop.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/definitions/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AddressDefinitions } from './address';
import type { AnimalDefinitions } from './animal';
import type { ColorDefinitions } from './color';
import type { CommerceDefinitions } from './commerce';
import type { CompanyDefinitions } from './company';
import type { DatabaseDefinitions } from './database';
Expand All @@ -26,6 +27,7 @@ export type LocaleEntry<T> = Partial<T> &
export interface Definitions {
address: AddressDefinitions;
animal: AnimalDefinitions;
color: ColorDefinitions;
commerce: CommerceDefinitions;
company: CompanyDefinitions;
database: DatabaseDefinitions;
Expand Down
1 change: 1 addition & 0 deletions src/definitions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export type { AddressDefinitions } from './address';
export type { AnimalDefinitions } from './animal';
export type { ColorDefinitions } from './color';
export type {
CommerceDefinitions,
CommerceProductNameDefinitions,
Expand Down
2 changes: 2 additions & 0 deletions src/faker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FakerError } from './errors/faker-error';
import type { KnownLocale } from './locales';
import { Address } from './modules/address';
import { Animal } from './modules/animal';
import { Color } from './modules/color';
import { Commerce } from './modules/commerce';
import { Company } from './modules/company';
import { Database } from './modules/database';
Expand Down Expand Up @@ -60,6 +61,7 @@ export class Faker {

readonly address: Address = new Address(this);
readonly animal: Animal = new Animal(this);
readonly color: Color = new Color(this);
readonly commerce: Commerce = new Commerce(this);
readonly company: Company = new Company(this);
readonly database: Database = new Database(this);
Expand Down
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import allLocales from './locales';
export type {
AddressDefinitions,
AnimalDefinitions,
ColorDefinitions,
CommerceDefinitions,
CommerceProductNameDefinitions,
CompanyDefinitions,
Expand All @@ -27,6 +28,14 @@ export type {
} from './definitions';
export { FakerError } from './errors/faker-error';
export type { FakerOptions, UsableLocale, UsedLocales } from './faker';
export type {
Casing,
ColorFormat,
CSSFunction,
CSSSpace,
NumberColorFormat,
StringColorFormat,
} from './modules/color';
export { Gender } from './modules/name';
export type { GenderType } from './modules/name';
export { Faker };
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions src/locales/ar/color/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { ColorDefinitions } from '../../..';
import human from './human';

const color: ColorDefinitions = {
human,
};

export default color;
2 changes: 0 additions & 2 deletions src/locales/ar/commerce/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
* Run 'pnpm run generate:locales' to update.
*/
import type { CommerceDefinitions } from '../../..';
import color from './color';
import department from './department';
import product_name from './product_name';

const commerce: CommerceDefinitions = {
color,
department,
product_name,
};
Expand Down
2 changes: 2 additions & 0 deletions src/locales/ar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import type { LocaleDefinition } from '../..';
import address from './address';
import cell_phone from './cell_phone';
import color from './color';
import commerce from './commerce';
import date from './date';
import name_ from './name';
Expand All @@ -17,6 +18,7 @@ const ar: LocaleDefinition = {
separator: ' & ',
address,
cell_phone,
color,
commerce,
date,
name: name_,
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions src/locales/az/color/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { ColorDefinitions } from '../../..';
import human from './human';

const color: ColorDefinitions = {
human,
};

export default color;
2 changes: 0 additions & 2 deletions src/locales/az/commerce/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
* Run 'pnpm run generate:locales' to update.
*/
import type { CommerceDefinitions } from '../../..';
import color from './color';
import department from './department';
import product_name from './product_name';

const commerce: CommerceDefinitions = {
color,
department,
product_name,
};
Expand Down
2 changes: 2 additions & 0 deletions src/locales/az/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
import type { LocaleDefinition } from '../..';
import address from './address';
import color from './color';
import commerce from './commerce';
import company from './company';
import date from './date';
Expand All @@ -15,6 +16,7 @@ const az: LocaleDefinition = {
title: 'Azerbaijani',
separator: ' və ',
address,
color,
commerce,
company,
date,
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions src/locales/el/color/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { ColorDefinitions } from '../../..';
import human from './human';

const color: ColorDefinitions = {
human,
};

export default color;
2 changes: 0 additions & 2 deletions src/locales/el/commerce/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
* Run 'pnpm run generate:locales' to update.
*/
import type { CommerceDefinitions } from '../../..';
import color from './color';
import department from './department';
import product_name from './product_name';

const commerce: CommerceDefinitions = {
color,
department,
product_name,
};
Expand Down
2 changes: 2 additions & 0 deletions src/locales/el/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import address from './address';
import app from './app';
import business from './business';
import cell_phone from './cell_phone';
import color from './color';
import commerce from './commerce';
import company from './company';
import finance from './finance';
Expand All @@ -24,6 +25,7 @@ const el: LocaleDefinition = {
app,
business,
cell_phone,
color,
commerce,
company,
finance,
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions src/locales/en/color/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { ColorDefinitions } from '../../..';
import human from './human';
import space from './space';

const color: ColorDefinitions = {
human,
space,
};

export default color;
43 changes: 43 additions & 0 deletions src/locales/en/color/space.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export default [
'CIE 1931 XYZ',
'CIEUVW',
'Uniform Color Spaces (UCSs)',
'CIELUV',
'CIELAB',
'HSLuv',
'sRGB',
'Adobe RGB',
'Adobe Wide Gamut RGB',
'Rec. 2100',
'ProPhoto RGB Color Space',
'scRGB',
'DCI-P3',
'Display-P3',
'Rec. 601',
'Rec. 709',
'Academy Color Encoding System (ACES)',
'Rec. 2020',
'YPbPr',
'YDbDr',
'YIQ',
'xvYCC',
'sYCC',
'HSV',
'HSL',
'HWB',
'RGBA',
'HSLA',
'LCh',
'CMY',
'CMYK',
'Munsell Color System',
'Natural Color System (NSC)',
'Pantone Matching System (PMS)',
'RAL',
'Federal Standard 595C',
'British Standard Colour (BS)',
'HKS',
'LMS',
'RG',
'RGK',
Shinigami92 marked this conversation as resolved.
Show resolved Hide resolved
];
2 changes: 0 additions & 2 deletions src/locales/en/commerce/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
* Run 'pnpm run generate:locales' to update.
*/
import type { CommerceDefinitions } from '../../..';
import color from './color';
import department from './department';
import product_description from './product_description';
import product_name from './product_name';

const commerce: CommerceDefinitions = {
color,
department,
product_description,
product_name,
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import animal from './animal';
import app from './app';
import business from './business';
import cell_phone from './cell_phone';
import color from './color';
import commerce from './commerce';
import company from './company';
import database from './database';
Expand All @@ -32,6 +33,7 @@ const en: LocaleDefinition = {
app,
business,
cell_phone,
color,
commerce,
company,
database,
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions src/locales/es/color/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { ColorDefinitions } from '../../..';
import human from './human';

const color: ColorDefinitions = {
human,
};

export default color;
2 changes: 0 additions & 2 deletions src/locales/es/commerce/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
* Run 'pnpm run generate:locales' to update.
*/
import type { CommerceDefinitions } from '../../..';
import color from './color';
import department from './department';
import product_name from './product_name';

const commerce: CommerceDefinitions = {
color,
department,
product_name,
};
Expand Down
2 changes: 2 additions & 0 deletions src/locales/es/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import type { LocaleDefinition } from '../..';
import address from './address';
import cell_phone from './cell_phone';
import color from './color';
import commerce from './commerce';
import company from './company';
import internet from './internet';
Expand All @@ -15,6 +16,7 @@ const es: LocaleDefinition = {
title: 'Spanish',
address,
cell_phone,
color,
commerce,
company,
internet,
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions src/locales/es_MX/color/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { ColorDefinitions } from '../../..';
import human from './human';

const color: ColorDefinitions = {
human,
};

export default color;
2 changes: 0 additions & 2 deletions src/locales/es_MX/commerce/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
* Run 'pnpm run generate:locales' to update.
*/
import type { CommerceDefinitions } from '../../..';
import color from './color';
import department from './department';
import product_name from './product_name';

const commerce: CommerceDefinitions = {
color,
department,
product_name,
};
Expand Down
Loading