1.0.8 • Published 3 years ago

@harryho/swatch-color v1.0.8

Weekly downloads
20
License
ISC
Repository
github
Last release
3 years ago

The package of Swatch Color

This package manages the generation of all Swatch Colors.

  • This package has all definition of SWatch Colors
  • This package manage validation of SWatch Color Data during the generation
  • This package will be consumed by any app which requires the Swatch Color

How to add new Color type

Example: A new type -- YourNewColorType

1 Add a new color type

export interface YourNewColorType extends Color{
    type: SwatchColorType.YourNewColorType,
}

2 Update SwatchColor

export type SwatchColor = RGB | HSL | BRGB | YourNewColorType;

3 Update SwatchColorType

export type SwatchColorType ={
    ...
    YourNewColorType = "YourNewColorType"
}
  1. Add your new type validation
function isValidColorData(colorData: SwatchColor ) : boolean { 
    let isValid = true;
    switch (colorData.type) {
        ...
        case "YourNewColorType":
            // TODO -- Add your validation here
            break;
    }
    return isValid;
}

Q & A

  • What will happen if color data is invalid

    Color Factory will return the null object instead of empty object

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago