- ${this.swatches.map(swatch => {
+ ${swatches.map(swatch => {
+ const parsedColor = this.parseColor(swatch);
+
+ // If we can't parse it, skip it
+ if (!parsedColor) {
+ console.error(`Unable to parse swatch color: "${swatch}"`, this);
+ return '';
+ }
+
return html`
this.selectSwatch(swatch)}
@keydown=${(event: KeyboardEvent) =>
- !this.disabled && event.key === 'Enter' && this.setColor(swatch)}
+ !this.disabled && event.key === 'Enter' && this.setColor(parsedColor.hexa)}
>
-
+
`;
})}