scttcper / ngx-color

🎨 Color Pickers from Sketch, Photoshop, Chrome, Github, Twitter & more
https://ngx-color.vercel.app
MIT License
433 stars 55 forks source link

Allow color to be undefined on init #340

Open SvenSeemann opened 3 years ago

SvenSeemann commented 3 years ago

It would be nice to allow the color to be undefined on init.

Current behaviour when color input is undefined:

Cannot read property 'hex' of undefined
at toState (color.ts:28)

This could be achieved by adding a check before processing color input here https://github.com/scttcper/ngx-color/blob/e84c0f15a96cc1b2423e75a12c5d99ade8a0eea9/src/lib/common/color-wrap.component.ts#L58

Small example: https://stackblitz.com/edit/angular-wc1bod

Give me short feedback if this would be a possible solution and I'm happy to provide a PR.