diff --git a/src/pages/editor/LiveEditor/Node.tsx b/src/pages/editor/LiveEditor/Node.tsx new file mode 100644 index 0000000..fbc1ed2 --- /dev/null +++ b/src/pages/editor/LiveEditor/Node.tsx @@ -0,0 +1,59 @@ +import React from "react"; +import { Handle, Position } from "react-flow-renderer"; +import styled from "styled-components"; + +const StyledWrapper = styled.div<{ isArray?: boolean }>` + background: ${({ theme }) => theme.BLACK_SECONDARY}; + border-radius: 5px; + padding: 16px; + color: ${({ theme, isArray }) => isArray && theme.SEAGREEN}; + width: auto; + min-width: 100px; + text-align: ${({ isArray }) => isArray && "center"}; +`; + +const StyledKey = styled.span` + color: ${({ theme }) => theme.BLURPLE}; +`; + +export const CustomNodeComponent: React.FC<{ data: any; id: string }> = ({ + id, + data, +}) => { + const { label: json } = data; + + if (typeof json === "string") { + return ( + + {json} + + + + ); + } + + if (typeof json === "object") { + const keyPairs = Object.entries(json); + + return ( + + {keyPairs.map((entries) => { + const isValidValue = + typeof entries[1] === "string" || typeof entries[1] === "number"; + + return ( +
+ {entries[0]}: + {isValidValue && entries[1]} +
+ ); + })} + + + +
+ ); + } + + return null; +};