From c6a883d96584b56e89664479b237e0685e68e26f Mon Sep 17 00:00:00 2001 From: "vicky_primathon.in" Date: Tue, 19 May 2020 22:54:38 +0530 Subject: [PATCH] light and dark theme added in dropdown component --- .../components/editorComponents/Button.tsx | 12 +++++- .../DynamicAutocompleteInput.tsx | 28 +++++++----- .../editorComponents/LightningMenu/index.tsx | 43 +++++++++++++++++-- .../propertyControls/ChartDataControl.tsx | 1 - .../propertyControls/CodeEditorControl.tsx | 1 - .../propertyControls/InputTextControl.tsx | 32 +++++++------- app/client/src/constants/Colors.tsx | 2 + app/client/src/constants/DefaultTheme.tsx | 16 ++++--- .../CustomizedDropdown/StyledComponents.tsx | 21 ++++++--- .../pages/common/CustomizedDropdown/index.tsx | 11 +++-- 10 files changed, 117 insertions(+), 50 deletions(-) diff --git a/app/client/src/components/editorComponents/Button.tsx b/app/client/src/components/editorComponents/Button.tsx index 97f31ec9b5..d2ef37538a 100644 --- a/app/client/src/components/editorComponents/Button.tsx +++ b/app/client/src/components/editorComponents/Button.tsx @@ -21,6 +21,7 @@ const buttonStyles = css<{ intent?: Intent; filled?: string; fluid?: boolean; + themeType?: string; }>` ${BlueprintButtonIntentsCSS} &&&& { @@ -33,14 +34,18 @@ const buttonStyles = css<{ props.filled || props.outline ? "inherit" : "transparent"}; width: ${props => (props.fluid ? "100%" : "auto")}; + color: ${props => + props.themeType === "dark" + ? props.theme.colors.textOnDarkBG + : props.theme.colors.textDefault}; } - ${props => (props.outline ? outline : "")} `; const StyledButton = styled(BlueprintButton)<{ outline?: string; intent?: Intent; filled?: string; + themeType?: string; }>` ${buttonStyles} `; @@ -48,6 +53,7 @@ const StyledAnchorButton = styled(BlueprintAnchorButton)<{ outline?: string; intent?: Intent; filled?: string; + themeType?: string; }>` ${buttonStyles} `; @@ -67,9 +73,11 @@ export type ButtonProps = { type?: "button" | "submit" | "reset"; className?: string; fluid?: boolean; + themeType?: string; }; export const Button = (props: ButtonProps) => { + console.log("theme", props.themeType); const icon: IconName | undefined = props.icon && (props.iconAlignment === Directions.LEFT || @@ -94,7 +102,9 @@ export const Button = (props: ButtonProps) => { type: props.type, className: props.className, fluid: props.fluid ? props.fluid.toString() : undefined, + themeType: props.themeType ? props.themeType : undefined, }; + // console.log("themeType", baseProps.themeType); if (props.href) { return ( ; - } & { - forwardRef: React.RefObject; }; type State = { @@ -288,11 +287,10 @@ class DynamicAutocompleteInput extends Component { isFocused: false, autoCompleteVisible: false, }; - console.log("ref inside DynamicAutoComplete", props.forwardRef); } componentDidMount(): void { - if (this.props.forwardRef.current) { + if (this.textArea.current) { const options: EditorConfiguration = {}; if (this.props.theme === "DARK") options.theme = "monokai"; if (!this.props.input.onChange || this.props.disabled) { @@ -304,7 +302,7 @@ class DynamicAutocompleteInput extends Component { "Ctrl-Space": "autocomplete", }; if (!this.props.allowTabIndent) extraKeys["Tab"] = false; - this.editor = CodeMirror.fromTextArea(this.props.forwardRef.current, { + this.editor = CodeMirror.fromTextArea(this.textArea.current, { mode: this.props.mode || { name: "javascript", globalVars: true }, viewportMargin: 10, tabSize: 2, @@ -368,6 +366,19 @@ class DynamicAutocompleteInput extends Component { } } } + if (prevProps.defaultValue !== this.props.defaultValue) { + const cursorPosition = this.props.defaultValue + ? this.props.defaultValue.length + 1 + : 1; + this.editor.setValue( + this.props.defaultValue ? this.props.defaultValue : "", + ); + this.editor.focus(); + this.editor.setCursor({ + line: 1, + ch: cursorPosition, + }); + } } handleEditorFocus = () => { @@ -485,7 +496,6 @@ class DynamicAutocompleteInput extends Component { hasError && this.state.isFocused && !this.state.autoCompleteVisible; } console.log(className); - console.log("textarea ref", this.props.forwardRef); return ( { )}