feat: feature/mvp-sprint-1 Fixed magic input placeholder rendering weird server-side
This commit is contained in:
parent
180608a8b8
commit
6489baa60b
@ -8,6 +8,12 @@ export const MagicInput = (props) => {
|
|||||||
|
|
||||||
const [inputValue, setInputValue] = React.useState()
|
const [inputValue, setInputValue] = React.useState()
|
||||||
|
|
||||||
|
const [isClientSide, setIsClientSide] = React.useState(false)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
setIsClientSide(true)
|
||||||
|
}, [])
|
||||||
|
|
||||||
const contentEditableRef = React.useRef(null)
|
const contentEditableRef = React.useRef(null)
|
||||||
const editValueRef = React.useRef({})
|
const editValueRef = React.useRef({})
|
||||||
|
|
||||||
@ -147,7 +153,7 @@ export const MagicInput = (props) => {
|
|||||||
position="absolute"
|
position="absolute"
|
||||||
top={0}
|
top={0}
|
||||||
left={0}
|
left={0}
|
||||||
display={inputValue ? "none" : "block"}
|
display={inputValue || !isClientSide ? "none" : "block"}
|
||||||
width="100%"
|
width="100%"
|
||||||
maxWidth="100%"
|
maxWidth="100%"
|
||||||
color="greys.dark"
|
color="greys.dark"
|
||||||
|
@ -19,7 +19,14 @@ export const SettingsMenu = (props) => {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const types = React.useMemo(() => {
|
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
|
return ret
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
@ -29,13 +36,22 @@ export const SettingsMenu = (props) => {
|
|||||||
},
|
},
|
||||||
[props?.onChangeType]
|
[props?.onChangeType]
|
||||||
)
|
)
|
||||||
|
const onDelete = React.useCallback(
|
||||||
|
(type) => {
|
||||||
|
props?.onDelete?.()
|
||||||
|
},
|
||||||
|
[props?.onDelete]
|
||||||
|
)
|
||||||
|
|
||||||
const iconSize = 10
|
const iconSize = 10
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Center
|
<Center
|
||||||
position="relative"
|
position="relative"
|
||||||
|
// width="100%"
|
||||||
|
paddingRight={36}
|
||||||
opacity={props?.opacity}
|
opacity={props?.opacity}
|
||||||
|
cursor="pointer"
|
||||||
transition={props?.transition || "all 0.2s ease-in-out"}
|
transition={props?.transition || "all 0.2s ease-in-out"}
|
||||||
onMouseEnter={showMenu}
|
onMouseEnter={showMenu}
|
||||||
onMouseLeave={hideMenu}
|
onMouseLeave={hideMenu}
|
||||||
@ -43,7 +59,6 @@ export const SettingsMenu = (props) => {
|
|||||||
<Flex
|
<Flex
|
||||||
paddingLeft={1}
|
paddingLeft={1}
|
||||||
// opacity={showContextIcon ? 1 : 0}
|
// opacity={showContextIcon ? 1 : 0}
|
||||||
cursor="pointer"
|
|
||||||
transition="all 0.2s ease-in-out"
|
transition="all 0.2s ease-in-out"
|
||||||
// onClick={deleteValue}
|
// onClick={deleteValue}
|
||||||
>
|
>
|
||||||
@ -64,7 +79,6 @@ export const SettingsMenu = (props) => {
|
|||||||
background="greys.lightt"
|
background="greys.lightt"
|
||||||
borderRadius={4}
|
borderRadius={4}
|
||||||
boxShadow={props?.boxShadow || "0px 2px 7px 0px rgba(0,0,0,0.2)"}
|
boxShadow={props?.boxShadow || "0px 2px 7px 0px rgba(0,0,0,0.2)"}
|
||||||
cursor="pointer"
|
|
||||||
paddingY={basePadding}
|
paddingY={basePadding}
|
||||||
>
|
>
|
||||||
{!props?.readonly && (
|
{!props?.readonly && (
|
||||||
@ -124,6 +138,23 @@ export const SettingsMenu = (props) => {
|
|||||||
return ret
|
return ret
|
||||||
})}
|
})}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
{!props?.readonly && (
|
||||||
|
<Flex
|
||||||
|
alignItems="center"
|
||||||
|
flexDirection="row"
|
||||||
|
_hover={{
|
||||||
|
background: "greys.light",
|
||||||
|
}}
|
||||||
|
onClick={onDelete}
|
||||||
|
paddingX={basePadding * 1}
|
||||||
|
paddingY={basePadding / 2}
|
||||||
|
>
|
||||||
|
<Icon marginBottom="-2px" name="bin" size={iconSize}></Icon>
|
||||||
|
<Text marginTop="-2px" paddingLeft={2} fontSize="xs">
|
||||||
|
Recycle
|
||||||
|
</Text>
|
||||||
|
</Flex>
|
||||||
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Center>
|
</Center>
|
||||||
|
@ -373,7 +373,8 @@ export const Thingtime = (props) => {
|
|||||||
|
|
||||||
const onChangeType = React.useCallback(
|
const onChangeType = React.useCallback(
|
||||||
(type) => {
|
(type) => {
|
||||||
const newType = type?.key || type?.value || type
|
const newType =
|
||||||
|
type?.key || type?.value || type?.label || type?.icon || type
|
||||||
|
|
||||||
if (newType === "object") {
|
if (newType === "object") {
|
||||||
updateValue({ value: {} })
|
updateValue({ value: {} })
|
||||||
@ -664,15 +665,6 @@ export const Thingtime = (props) => {
|
|||||||
marginTop={-1}
|
marginTop={-1}
|
||||||
paddingLeft={1}
|
paddingLeft={1}
|
||||||
>
|
>
|
||||||
<Flex
|
|
||||||
paddingLeft={1}
|
|
||||||
opacity={showContextIcon ? 1 : 0}
|
|
||||||
cursor="pointer"
|
|
||||||
transition="all 0.2s ease-in-out"
|
|
||||||
onClick={resetValue}
|
|
||||||
>
|
|
||||||
<Icon name="magic" size={9}></Icon>
|
|
||||||
</Flex>
|
|
||||||
<SettingsMenu
|
<SettingsMenu
|
||||||
transition="all 0.2s ease-in-out"
|
transition="all 0.2s ease-in-out"
|
||||||
opacity={showContextIcon ? 1 : 0}
|
opacity={showContextIcon ? 1 : 0}
|
||||||
@ -680,16 +672,8 @@ export const Thingtime = (props) => {
|
|||||||
fullPath={fullPath}
|
fullPath={fullPath}
|
||||||
readonly={!props?.edit}
|
readonly={!props?.edit}
|
||||||
onChangeType={onChangeType}
|
onChangeType={onChangeType}
|
||||||
|
onDelete={deleteValue}
|
||||||
></SettingsMenu>
|
></SettingsMenu>
|
||||||
<Flex
|
|
||||||
paddingLeft={1}
|
|
||||||
opacity={showContextIcon ? 1 : 0}
|
|
||||||
cursor="pointer"
|
|
||||||
transition="all 0.2s ease-in-out"
|
|
||||||
onClick={deleteValue}
|
|
||||||
>
|
|
||||||
<Icon name="bin" size={6}></Icon>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
Loading…
Reference in New Issue
Block a user