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

Improve overloads and types #144

Merged
merged 6 commits into from
Nov 27, 2023
Merged

Improve overloads and types #144

merged 6 commits into from
Nov 27, 2023

Conversation

elchininet
Copy link
Owner

This pull request improves the TypeScript support and the flexibility of the API adding more methods overloads and allowing to accept also strings in the enum parameters. Also some bugs have been fixed.

The next changes are the main changes that have been applied:

1. For methods that use Mix and Harmony enums, now it is possible to send also string values.

2. Make optional the shades and tints parameters of the getShades and getTints methods respectively (the default will be 5)

3. getBlendStatic methods now have two overloads

getBlendColorsStaticMethod(
  fromColor: string | object,
  toColor: string | object,
  options?: Options
)

// Specifying the number of steps
getBlendColorsStaticMethod(
  fromColor: string | object,
  toColor: string | object,
  steps: number,
  options?: Options
)

4. getMixStatic methods now have two overloads

getMixColorsStaticMethod(
  colors: [string | object][],
  options?: Options
)

// Specifying the mix mode
getMixColorsStaticMethod(
  colors: [string | object][],
  mode: 'ADDITIVE' | 'SUBTRACTIVE',
  options?: Options
)

5. getHarmony method now have four overloads for each color input

// If harmony is not sent, the default will be "COMPLEMENTARY"
// If mode is not sent, the default will be "ADDITIVE"
getHarmony(
  color: string | object,
  options?: Options
)

// If mode is not sent, the default will be "ADDITIVE"
getHarmony(
  color: string | object,
  harmony: 'ANALOGOUS' | 'COMPLEMENTARY' | 'SPLIT_COMPLEMENTARY' | 'TRIADIC' | 'TETRADIC' | 'SQUARE',
  options?: Options
)

// If harmony is not sent, the default will be "COMPLEMENTARY"
getHarmony(
  color: string | object,
  mode: 'ADDITIVE' | 'SUBTRACTIVE',
  options?: Options
)

getHarmony(
  color: string | object,
  harmony: 'ANALOGOUS' | 'COMPLEMENTARY' | 'SPLIT_COMPLEMENTARY' | 'TRIADIC' | 'TETRADIC' | 'SQUARE',
  mode: 'ADDITIVE' | 'SUBTRACTIVE',
  options?: Options
)

@elchininet elchininet self-assigned this Nov 27, 2023
@elchininet elchininet merged commit 749df08 into master Nov 27, 2023
1 check passed
@elchininet elchininet deleted the improve_overloads_and_types branch November 27, 2023 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant