From 6489baa60b72828ff222503f8fdbb57848f8981c Mon Sep 17 00:00:00 2001 From: Nikolaj Frey Date: Mon, 14 Aug 2023 15:10:46 +1000 Subject: [PATCH] feat: feature/mvp-sprint-1 Fixed magic input placeholder rendering weird server-side --- .../app/components/MagicInput/MagicInput.tsx | 8 +++- .../app/components/Thingtime/SettingsMenu.tsx | 37 +++++++++++++++++-- remix/app/components/Thingtime/Thingtime.tsx | 22 ++--------- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/remix/app/components/MagicInput/MagicInput.tsx b/remix/app/components/MagicInput/MagicInput.tsx index 3f2502e..d5dfae5 100644 --- a/remix/app/components/MagicInput/MagicInput.tsx +++ b/remix/app/components/MagicInput/MagicInput.tsx @@ -8,6 +8,12 @@ export const MagicInput = (props) => { const [inputValue, setInputValue] = React.useState() + const [isClientSide, setIsClientSide] = React.useState(false) + + React.useEffect(() => { + setIsClientSide(true) + }, []) + const contentEditableRef = React.useRef(null) const editValueRef = React.useRef({}) @@ -147,7 +153,7 @@ export const MagicInput = (props) => { position="absolute" top={0} left={0} - display={inputValue ? "none" : "block"} + display={inputValue || !isClientSide ? "none" : "block"} width="100%" maxWidth="100%" color="greys.dark" diff --git a/remix/app/components/Thingtime/SettingsMenu.tsx b/remix/app/components/Thingtime/SettingsMenu.tsx index 1cd6caa..4371203 100644 --- a/remix/app/components/Thingtime/SettingsMenu.tsx +++ b/remix/app/components/Thingtime/SettingsMenu.tsx @@ -19,7 +19,14 @@ export const SettingsMenu = (props) => { }, []) const types = React.useMemo(() => { - const ret = ["any", "object", "array", "string", "number", "boolean"] + const ret = [ + { label: "any", icon: "any" }, + "object", + "array", + "string", + "number", + "boolean", + ] return ret }, []) @@ -29,13 +36,22 @@ export const SettingsMenu = (props) => { }, [props?.onChangeType] ) + const onDelete = React.useCallback( + (type) => { + props?.onDelete?.() + }, + [props?.onDelete] + ) const iconSize = 10 return (
{ @@ -64,7 +79,6 @@ export const SettingsMenu = (props) => { background="greys.lightt" borderRadius={4} boxShadow={props?.boxShadow || "0px 2px 7px 0px rgba(0,0,0,0.2)"} - cursor="pointer" paddingY={basePadding} > {!props?.readonly && ( @@ -124,6 +138,23 @@ export const SettingsMenu = (props) => { return ret })} + {!props?.readonly && ( + + + + Recycle + + + )}
diff --git a/remix/app/components/Thingtime/Thingtime.tsx b/remix/app/components/Thingtime/Thingtime.tsx index 6b10528..7d2e5df 100644 --- a/remix/app/components/Thingtime/Thingtime.tsx +++ b/remix/app/components/Thingtime/Thingtime.tsx @@ -373,7 +373,8 @@ export const Thingtime = (props) => { const onChangeType = React.useCallback( (type) => { - const newType = type?.key || type?.value || type + const newType = + type?.key || type?.value || type?.label || type?.icon || type if (newType === "object") { updateValue({ value: {} }) @@ -664,15 +665,6 @@ export const Thingtime = (props) => { marginTop={-1} paddingLeft={1} > - - - { fullPath={fullPath} readonly={!props?.edit} onChangeType={onChangeType} + onDelete={deleteValue} > - - - )}