From 1f1dbade1daf3be7265ce9f185f75c38a5ee4b02 Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Tue, 24 Sep 2019 12:24:56 -0700 Subject: [PATCH] add color palette generation frontend (beta) --- components/BackgroundSelect.js | 18 ++++++++++-- components/Editor.js | 1 + components/ImagePicker.js | 50 ++++++++++++++++++++++++++++++++-- components/RandomImage.js | 2 +- components/Settings.js | 2 +- components/Toggle.js | 23 ++++++++++++++-- lib/api.js | 2 +- 7 files changed, 88 insertions(+), 10 deletions(-) diff --git a/components/BackgroundSelect.js b/components/BackgroundSelect.js index 50ca6d2..f92c5cf 100644 --- a/components/BackgroundSelect.js +++ b/components/BackgroundSelect.js @@ -23,7 +23,16 @@ class BackgroundSelect extends React.PureComponent { handlePickColor = ({ rgb }) => this.props.onChange({ backgroundColor: stringifyRGBA(rgb) }) render() { - const { color, mode, image, onChange, isVisible, toggleVisibility, carbonRef } = this.props + const { + color, + mode, + image, + onChange, + isVisible, + toggleVisibility, + carbonRef, + updateHighlights + } = this.props const background = validateColor(color) ? color : DEFAULT_BG_COLOR @@ -70,7 +79,12 @@ class BackgroundSelect extends React.PureComponent { diff --git a/components/Editor.js b/components/Editor.js index 02f101f..06ac125 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -377,6 +377,7 @@ class Editor extends React.Component { /> c.hex) + /* + * Contributors, please feel free to adjust this algorithm to create the most + * readible or aesthetically pleasing syntax highlighting. + */ + this.props.updateHighlights({ + background: palette[0], + text: palette[1], + variable: palette[2], + attribute: palette[3], + definition: palette[4], + keyword: palette[5], + property: palette[6], + string: palette[7], + number: palette[8], + operator: palette[9], + meta: palette[10], + tag: palette[11], + comment: palette[12] + }) + } } removeImage() { @@ -192,6 +221,7 @@ export default class ImagePicker extends React.Component { Or use a random Unsplash image: + (this.generateColorPalette = value)} />