AykutSarac 2 лет назад
Родитель
Сommit
fc65d2ef88
2 измененных файлов с 11 добавлено и 4 удалено
  1. 1 1
      src/components/CustomNode/ObjectNode.tsx
  2. 10 3
      src/components/CustomNode/styles.tsx

+ 1 - 1
src/components/CustomNode/ObjectNode.tsx

@@ -22,7 +22,7 @@ const ObjectNode: React.FC<CustomNodeProps<[string, string][]>> = ({
               data-x={x}
               data-x={x}
               data-y={y}
               data-y={y}
               key={idx}
               key={idx}
-              width={width}
+              width={`${width - 20}px`}
               value={JSON.stringify(val[1])}
               value={JSON.stringify(val[1])}
             >
             >
               <Styled.StyledKey objectKey>
               <Styled.StyledKey objectKey>

+ 10 - 3
src/components/CustomNode/styles.tsx

@@ -83,12 +83,19 @@ export const StyledKey = styled.span<{
   font-size: ${({ parent }) => parent && "14px"};
   font-size: ${({ parent }) => parent && "14px"};
 `;
 `;
 
 
-export const StyledRow = styled.span<{ width: number; value: string }>`
+export const StyledRow = styled.span.attrs<{
+  width: string;
+  value: string;
+  theme: DefaultTheme;
+}>((props) => ({
+  style: {
+    width: props.width,
+    color: getTypeColor(props.value, props.theme),
+  },
+}))<{ width: string; value: string; theme: DefaultTheme }>`
   height: 18px;
   height: 18px;
   overflow: hidden;
   overflow: hidden;
   text-overflow: ellipsis;
   text-overflow: ellipsis;
   white-space: nowrap;
   white-space: nowrap;
   padding: 0 auto;
   padding: 0 auto;
-  width: ${({ width }) => `${width - 20}px`};
-  color: ${({ theme, value }) => getTypeColor(value, theme)};
 `;
 `;