From 0f8739abc06e1610174e99bccf157d93f27804ea Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 3 Sep 2020 20:51:46 -0400 Subject: [PATCH] Switch color options to use input type=color and removed save button --- public/options/options.css | 3 ++ .../CategorySkipOptionsComponent.tsx | 37 +++++-------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/public/options/options.css b/public/options/options.css index 8ad87e3d..971c6893 100644 --- a/public/options/options.css +++ b/public/options/options.css @@ -350,4 +350,7 @@ svg { .categoryColorTextBox { width: 60px; + + background: none; + border: none; } \ No newline at end of file diff --git a/src/components/CategorySkipOptionsComponent.tsx b/src/components/CategorySkipOptionsComponent.tsx index 0a44b172..cbfd42cf 100644 --- a/src/components/CategorySkipOptionsComponent.tsx +++ b/src/components/CategorySkipOptionsComponent.tsx @@ -71,7 +71,7 @@ class CategorySkipOptionsComponent extends React.Component this.setColorState(event, false)} value={this.state.color} /> @@ -79,20 +79,11 @@ class CategorySkipOptionsComponent extends React.Component this.setColorState(event, true)} value={this.state.previewColor} /> - -
this.save()}> - {chrome.i18n.getMessage("save")} -
- - - , preview: boolean) { + setColorState(event: React.FormEvent, preview: boolean) { if (preview) { this.setState({ - previewColor: event.target.value + previewColor: event.currentTarget.value }); + + Config.config.barTypes["preview-" + this.props.category].color = event.currentTarget.value; + } else { this.setState({ - color: event.target.value + color: event.currentTarget.value }); - } - } - // Save text box data - save() { - // Validate colors - let checkVar = [this.state.color, this.state.previewColor] - for (const color of checkVar) { - if (color[0] !== "#" || (color.length !== 7 && color.length !== 4) || !utils.isHex(color.slice(1))) { - alert(chrome.i18n.getMessage("colorFormatIncorrect") + " " + color.slice(1) + " " + utils.isHex(color.slice(1)) + " " + utils.isHex("abcd123")); - return; - } + Config.config.barTypes[this.props.category].color = event.currentTarget.value; } - // Save colors - Config.config.barTypes[this.props.category].color = this.state.color; - Config.config.barTypes["preview-" + this.props.category].color = this.state.previewColor; // Make listener get called Config.config.barTypes = Config.config.barTypes; }