From 54c1edba0ca6c584cfb080ce51ce76b5395201f8 Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Fri, 12 Nov 2021 14:09:00 -0500 Subject: [PATCH] added input text view + moved things --- .../components/{ => Inputs}/InputBoolean.tsx | 0 web/src/components/{ => Inputs}/InputList.tsx | 1 - .../components/{ => Inputs}/InputNumber.tsx | 2 - web/src/components/{ => Inputs}/InputText.tsx | 4 +- web/src/components/Inputs/InputViewEdit.tsx | 56 +++++++++++++++ .../components/{ => Inputs}/InputWrapper.tsx | 0 web/src/components/{ => Inputs}/InputYaml.tsx | 0 web/src/components/Inputs/index.tsx | 0 web/src/icons/checkmark.tsx | 12 ++++ web/src/icons/pencil.tsx | 22 ++++++ web/src/styles/components/AutomationDAG.scss | 25 ++++++- .../styles/components/AutomationEditor.scss | 44 ------------ web/src/styles/components/AutomationNode.scss | 69 ------------------- web/src/styles/components/InputWrapper.scss | 41 +++++++++++ web/src/styles/components/index.scss | 2 - web/src/styles/icons.scss | 8 +++ web/src/styles/index.scss | 1 + 17 files changed, 166 insertions(+), 121 deletions(-) rename web/src/components/{ => Inputs}/InputBoolean.tsx (100%) rename web/src/components/{ => Inputs}/InputList.tsx (93%) rename web/src/components/{ => Inputs}/InputNumber.tsx (85%) rename web/src/components/{ => Inputs}/InputText.tsx (91%) create mode 100644 web/src/components/Inputs/InputViewEdit.tsx rename web/src/components/{ => Inputs}/InputWrapper.tsx (100%) rename web/src/components/{ => Inputs}/InputYaml.tsx (100%) create mode 100644 web/src/components/Inputs/index.tsx create mode 100644 web/src/icons/checkmark.tsx create mode 100644 web/src/icons/pencil.tsx delete mode 100644 web/src/styles/components/AutomationEditor.scss delete mode 100644 web/src/styles/components/AutomationNode.scss create mode 100644 web/src/styles/icons.scss diff --git a/web/src/components/InputBoolean.tsx b/web/src/components/Inputs/InputBoolean.tsx similarity index 100% rename from web/src/components/InputBoolean.tsx rename to web/src/components/Inputs/InputBoolean.tsx diff --git a/web/src/components/InputList.tsx b/web/src/components/Inputs/InputList.tsx similarity index 93% rename from web/src/components/InputList.tsx rename to web/src/components/Inputs/InputList.tsx index fa555bc..8c4cd1e 100644 --- a/web/src/components/InputList.tsx +++ b/web/src/components/Inputs/InputList.tsx @@ -1,4 +1,3 @@ -import { SelectHTMLAttributes } from "react"; import InputWrapper from "./InputWrapper"; diff --git a/web/src/components/InputNumber.tsx b/web/src/components/Inputs/InputNumber.tsx similarity index 85% rename from web/src/components/InputNumber.tsx rename to web/src/components/Inputs/InputNumber.tsx index 88d873b..ae1c116 100644 --- a/web/src/components/InputNumber.tsx +++ b/web/src/components/Inputs/InputNumber.tsx @@ -1,4 +1,3 @@ -import { useToolTip } from "../tooltip/context"; import InputWrapper from "./InputWrapper"; export interface Props { @@ -11,7 +10,6 @@ export default function InputNumber({ value=0, onChange, }: Props) { - const tooltip = useToolTip(); return void; + additionalTooltipFilters?: Record; +} +export default function InputViewEdit({ + label, + textBoxFor, + value="", + onChange, + additionalTooltipFilters={}, +}: Props) { + const tooltip = useToolTip(); + const [isEditing, setIsEditing] = useState(false); + const onChangeWrapped = (t: string) => { + onChange(t); + setIsEditing(false); + } + const inputRef = useRef(null); + useEffect(() => { + if (isEditing && inputRef.current) { + inputRef.current.focus() + } + }, [inputRef.current, isEditing]) + return + {isEditing ? { + e.preventDefault(); + onChangeWrapped(e.target.value) + }} + onFocus={e => textBoxFor && tooltip.setFocus( + e.target.getBoundingClientRect(), + { + searchObject: textBoxFor, + searchText: value, + filterObjects: additionalTooltipFilters, + }, + onChangeWrapped + )} + />:
+ {value} +
} + setIsEditing(!isEditing)} className={`icon pencil ${isEditing ? 'opened' : ''}`}/> + setIsEditing(!isEditing)} className={`icon checkmark ${isEditing ? 'opened' : ''}`}/> +
+} \ No newline at end of file diff --git a/web/src/components/InputWrapper.tsx b/web/src/components/Inputs/InputWrapper.tsx similarity index 100% rename from web/src/components/InputWrapper.tsx rename to web/src/components/Inputs/InputWrapper.tsx diff --git a/web/src/components/InputYaml.tsx b/web/src/components/Inputs/InputYaml.tsx similarity index 100% rename from web/src/components/InputYaml.tsx rename to web/src/components/Inputs/InputYaml.tsx diff --git a/web/src/components/Inputs/index.tsx b/web/src/components/Inputs/index.tsx new file mode 100644 index 0000000..e69de29 diff --git a/web/src/icons/checkmark.tsx b/web/src/icons/checkmark.tsx new file mode 100644 index 0000000..5189ca7 --- /dev/null +++ b/web/src/icons/checkmark.tsx @@ -0,0 +1,12 @@ + + +import { AnchorHTMLAttributes } from "react"; + + +export default function CheckMarkIcon(props: AnchorHTMLAttributes) { + return + + + + +} \ No newline at end of file diff --git a/web/src/icons/pencil.tsx b/web/src/icons/pencil.tsx new file mode 100644 index 0000000..33c92f1 --- /dev/null +++ b/web/src/icons/pencil.tsx @@ -0,0 +1,22 @@ +import { AnchorHTMLAttributes } from "react"; + + +export default function PencilIcon(props: AnchorHTMLAttributes) { + return + + + + + + + + + +} \ No newline at end of file diff --git a/web/src/styles/components/AutomationDAG.scss b/web/src/styles/components/AutomationDAG.scss index be23c74..8410e20 100644 --- a/web/src/styles/components/AutomationDAG.scss +++ b/web/src/styles/components/AutomationDAG.scss @@ -2,6 +2,9 @@ height: 99%; width: 99%; border: 1px solid $secondary-accent; + font-size: 0.5em; + color: $primary-accent; + svg { height: 100%; width: 100%; @@ -9,6 +12,27 @@ margin: 0; } + &-title { + .input-wrapper { + max-height: 100%; + max-width: 100%; + height: 100%; + width: 100%; + + * { + margin: 0; + } + label { + display: none; + } + input, + div { + // min-height: 100%; + // max-height: 100%; + font-size: 1em; + } + } + } .edge { stroke: $secondary-accent; } @@ -25,7 +49,6 @@ max-height: 100%; max-width: 100%; width: 100%; - font-size: 0.5em; &-inner { display: flex; diff --git a/web/src/styles/components/AutomationEditor.scss b/web/src/styles/components/AutomationEditor.scss deleted file mode 100644 index f7bc99e..0000000 --- a/web/src/styles/components/AutomationEditor.scss +++ /dev/null @@ -1,44 +0,0 @@ -.automation-editor { - width: 100%; - height: 100%; - overflow: hidden; - - .automation-node { - flex-direction: column; - justify-content: center; - > &-inner { - min-width: 100%; - } - } - &--root { - display: flex; - flex-direction: row; - width: 100%; - // justify-content: center; - // align-items: center; - } - &--triggers { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - } - &--playground { - width: 100%; - > .automation-editor--elm-list { - display: flex; - flex-direction: row; - align-items: start; - } - } - button.elm-list { - width: 90%; - } - &--elm-list { - max-height: 20vh; - overflow-y: auto; - overflow-x: auto; - padding: 5%; - width: 100%; - } -} diff --git a/web/src/styles/components/AutomationNode.scss b/web/src/styles/components/AutomationNode.scss deleted file mode 100644 index 4d23363..0000000 --- a/web/src/styles/components/AutomationNode.scss +++ /dev/null @@ -1,69 +0,0 @@ -.automation-node { - display: flex; - flex-direction: row; - - &-inner { - padding: 10px; - border-radius: 25px; - background-color: $secondary; - max-width: 200px; - max-height: 75px; - min-width: 200px; - min-height: 75px; - - display: flex; - flex-direction: row; - flex-wrap: nowrap; - justify-content: space-around; - - &-text { - flex: 2; - display: flex; - text-align: center; - justify-content: center; - align-items: center; - } - &-edge { - flex: 1; - border-radius: 30px; - display: flex; - flex-direction: column; - flex-wrap: nowrap; - - justify-content: space-around; - align-items: center; - &.left { - border-left: 1px $secondary-accent solid; - border-top-right-radius: 0; - border-bottom-right-radius: 0; - } - &.right { - border-right: 1px $secondary-accent solid; - border-top-left-radius: 0; - border-bottom-left-radius: 0; - } - &:hover { - background-color: $primary-accent; - cursor: pointer; - } - } - } - &-children { - min-width: 250px; - padding: 20px; - - &.closed { - height: 0; - width: 0; - display: none; - } - &.open { - border-radius: 25px; - border-color: $secondary-accent; - border-width: 1px; - border-style: solid; - display: flex; - flex-direction: column; - } - } -} diff --git a/web/src/styles/components/InputWrapper.scss b/web/src/styles/components/InputWrapper.scss index 7fb01d6..2af7da0 100644 --- a/web/src/styles/components/InputWrapper.scss +++ b/web/src/styles/components/InputWrapper.scss @@ -1,8 +1,49 @@ .input-wrapper { + position: relative; display: flex; flex-direction: column; margin-bottom: 8px; label { font-size: 12px; } + .input-view { + @extend input; + cursor: default; + } + a.icon { + cursor: pointer; + position: absolute; + right: 0.5em; + top: 0.5em; + + &:hover { + transform: rotate(90deg); + > svg { + fill: $secondary-accent; + } + } + + &.opened { + transform: rotate(360deg); + height: 0.5em; + right: 0.25em; + &.checkmark { + opacity: 1; + z-index: 1; + } + &.pencil { + opacity: 0; + z-index: -1; + } + } + + &.pencil { + opacity: 1; + z-index: 1; + } + &.checkmark { + opacity: 0; + z-index: -1; + } + } } diff --git a/web/src/styles/components/index.scss b/web/src/styles/components/index.scss index 20e923f..f2253a1 100644 --- a/web/src/styles/components/index.scss +++ b/web/src/styles/components/index.scss @@ -1,5 +1,3 @@ -@import "./AutomationNode.scss"; -@import "./AutomationEditor.scss"; @import "./NewNodeModal.scss"; @import "./InputWrapper.scss"; @import "./AutomationDAG.scss"; diff --git a/web/src/styles/icons.scss b/web/src/styles/icons.scss new file mode 100644 index 0000000..2159986 --- /dev/null +++ b/web/src/styles/icons.scss @@ -0,0 +1,8 @@ +a.icon { + height: 1em; + width: 1em; + display: flex; + svg { + fill: $primary-accent; + } +} diff --git a/web/src/styles/index.scss b/web/src/styles/index.scss index e0db30e..2241944 100644 --- a/web/src/styles/index.scss +++ b/web/src/styles/index.scss @@ -4,3 +4,4 @@ @import "./common.scss"; @import "./components/index.scss"; @import "./tooltip.scss"; +@import "./icons.scss";