From 8a33d05cedc366e59c2885e7cd8b69cf72bf4837 Mon Sep 17 00:00:00 2001 From: Ari Date: Tue, 24 May 2022 22:00:34 -0400 Subject: [PATCH] slightly better node condition editor --- .../ConditionEditor/ConditionNode.tsx | 4 +- .../ConditionEditor/editorRender.tsx | 24 ++--- .../src/components/ConditionEditor/style.ts | 6 +- webapp/src/components/Inputs/InputText.tsx | 93 +++++++------------ .../src/components/MultiNodeEditors/index.css | 17 ++++ .../src/components/MultiNodeEditors/index.tsx | 6 +- webapp/src/components/NodeEditor/index.css | 3 +- 7 files changed, 74 insertions(+), 79 deletions(-) diff --git a/webapp/src/components/ConditionEditor/ConditionNode.tsx b/webapp/src/components/ConditionEditor/ConditionNode.tsx index 18f0382..c9bc476 100644 --- a/webapp/src/components/ConditionEditor/ConditionNode.tsx +++ b/webapp/src/components/ConditionEditor/ConditionNode.tsx @@ -117,7 +117,9 @@ export const ConditionNode: FC<{ value={condition} onChange={update => onUpdate(update as any)} />} - {!yamlMode && childrenConditions} +
+ {!yamlMode && childrenConditions} +
{!yamlMode && hasChildren &&
} diff --git a/webapp/src/components/ConditionEditor/editorRender.tsx b/webapp/src/components/ConditionEditor/editorRender.tsx index 31ac544..79f98ed 100644 --- a/webapp/src/components/ConditionEditor/editorRender.tsx +++ b/webapp/src/components/ConditionEditor/editorRender.tsx @@ -45,7 +45,7 @@ export const TemplateEditor: Editor = ({ onChange, condition, }) => { - return
+ return <> onChange({ ...condition, alias @@ -54,7 +54,7 @@ export const TemplateEditor: Editor = ({ ...condition, value_template })} /> -
+ } @@ -62,7 +62,7 @@ export const NumericStateEditor: Editor = ({ onChange, condition, }) => { - return
+ return <> onChange({ ...condition, alias @@ -98,7 +98,7 @@ export const NumericStateEditor: Editor = ({ ...condition, value_template })} /> -
+ } @@ -126,7 +126,7 @@ export const StateEditor: Editor = ({ onChange, condition, }) => { - return
+ return <> onChange({ ...condition, alias @@ -158,14 +158,14 @@ export const StateEditor: Editor = ({ for: _for, })} /> -
+ } export const TimeEditor: Editor = ({ onChange, condition, }) => { - return
+ return <> onChange({ ...condition, alias @@ -187,14 +187,14 @@ export const TimeEditor: Editor = ({ })} /> Weekday not support for no, use yaml for now {condition.weekday} -
+ } export const TriggerEditor: Editor = ({ onChange, condition, }) => { - return
+ return <> onChange({ ...condition, alias @@ -203,14 +203,14 @@ export const TriggerEditor: Editor = ({ ...condition, id })} /> -
+ } export const ZoneEditor: Editor = ({ onChange, condition, }) => { - return
+ return <> onChange({ ...condition, alias @@ -234,5 +234,5 @@ export const ZoneEditor: Editor = ({ state, })} /> -
+ } \ No newline at end of file diff --git a/webapp/src/components/ConditionEditor/style.ts b/webapp/src/components/ConditionEditor/style.ts index 5d028db..c95125d 100644 --- a/webapp/src/components/ConditionEditor/style.ts +++ b/webapp/src/components/ConditionEditor/style.ts @@ -86,6 +86,9 @@ export const useStyles = createAppUseStyles<{ }), icon: {}, deleteBtn, + conditionWrap: { + overflow: 'auto', + }, children: ({ hasChildren }) => ({ flex: 1, paddingLeft: hasChildren ? 50 : 10, @@ -96,7 +99,8 @@ export const useStyles = createAppUseStyles<{ border: `1px solid ${theme.secondaryAccent}`, borderBottomRightRadius: hasChildren ? 10 : 0, borderBottomLeftRadius: hasChildren ? 10 : 0, - minHeight: hasChildren ? undefined : '100%' + minHeight: hasChildren ? undefined : '100%', + overflow: 'scroll' }), addBtnContainer: { display: 'flex', diff --git a/webapp/src/components/Inputs/InputText.tsx b/webapp/src/components/Inputs/InputText.tsx index 69c6f87..d94fbb8 100644 --- a/webapp/src/components/Inputs/InputText.tsx +++ b/webapp/src/components/Inputs/InputText.tsx @@ -1,6 +1,7 @@ import { PropsWithChildren, useState } from "react"; import { useToolTip } from "tooltip/context"; import TextField from '@mui/material/TextField'; +import InputWrapper from "./InputWrapper"; export interface Props { textBoxFor?: string; @@ -25,67 +26,35 @@ export default function InputText({ }: PropsWithChildren) { const tooltip = useToolTip(); const [isFocused, setIsFocused] = useState(false) - return { - if (e.key === 'Enter') { - onEnter(); - } - }} - onChange={e => { - e.preventDefault(); - onChange(e.target.value) - }} - onBlur={() => { - setIsFocused(false) - }} - onFocus={e => { - setIsFocused(true) - if (textBoxFor) { - tooltip.setFocus( - e.target.getBoundingClientRect(), - { - searchObject: textBoxFor, - searchText: value, - filterObjects: additionalTooltipFilters, - }, - onChange - ) - } - }} - > + return + { + if (e.key === 'Enter') { + onEnter(); + } + }} + onChange={e => { + e.preventDefault(); + onChange(e.target.value) + }} + onBlur={() => { + setIsFocused(false) + }} + onFocus={e => { + setIsFocused(true) + if (textBoxFor) { + tooltip.setFocus( + e.target.getBoundingClientRect(), + { + searchObject: textBoxFor, + searchText: value, + filterObjects: additionalTooltipFilters, + }, + onChange + ) + } + }} + /> {children} - - // return - // { - // if (e.key === 'Enter') { - // onEnter(); - // } - // }} - // onChange={e => { - // e.preventDefault(); - // onChange(e.target.value) - // }} - // onBlur={e => { - // setIsFocused(false) - // }} - // onFocus={e => { - // setIsFocused(true) - // if (textBoxFor) { - // tooltip.setFocus( - // e.target.getBoundingClientRect(), - // { - // searchObject: textBoxFor, - // searchText: value, - // filterObjects: additionalTooltipFilters, - // }, - // onChange - // ) - // } - // }} - // /> - // {children} - // + } diff --git a/webapp/src/components/MultiNodeEditors/index.css b/webapp/src/components/MultiNodeEditors/index.css index bdfe002..ea10c7d 100644 --- a/webapp/src/components/MultiNodeEditors/index.css +++ b/webapp/src/components/MultiNodeEditors/index.css @@ -1,5 +1,22 @@ .multinode-editor { max-width: 80vw; + min-width: 60vw; +} + +.multinode-editor.mobile { + max-width: 95vw; +} + +.multinode-editor .node-editor--root { + padding: 0; +} + +.multinode-editor .node-editor--body { + padding-bottom: 1em; + padding-top: 0.25em; + padding-left: 0.25em; + padding-right: 0.25em; + max-height: 60vh; } .multinode-editor--navbar { diff --git a/webapp/src/components/MultiNodeEditors/index.tsx b/webapp/src/components/MultiNodeEditors/index.tsx index 7fc7b66..5d5ec85 100644 --- a/webapp/src/components/MultiNodeEditors/index.tsx +++ b/webapp/src/components/MultiNodeEditors/index.tsx @@ -4,11 +4,13 @@ import { NodeEditor } from 'components/NodeEditor'; import { Button } from 'components/Inputs/Button'; import { useMultiNodeEditorState } from "./state"; import { MultiNodeEditorProps } from "./types"; +import useWindowSize from 'utils/useWindowSize'; export const MultiNodeEditor: FC = props => { // state - const state = useMultiNodeEditorState(props) + const state = useMultiNodeEditorState(props); + const { isMobile } = useWindowSize(); // components const nextOrAddBtn = diff --git a/webapp/src/components/NodeEditor/index.css b/webapp/src/components/NodeEditor/index.css index d95ee2f..50eb527 100644 --- a/webapp/src/components/NodeEditor/index.css +++ b/webapp/src/components/NodeEditor/index.css @@ -4,7 +4,7 @@ justify-content: center; align-items: center; height: 100%; - padding: 1em; + padding: 0.5em; margin-top: 0.5em; } @@ -39,6 +39,7 @@ min-width: 100%; min-height: fit-content; + max-width: 100%; } .node-editor--footer {