From 2f8a1da16cf1bd873cca884853d939d9ce5a2007 Mon Sep 17 00:00:00 2001 From: Shahriar <31452340+ShahriarKh@users.noreply.github.com> Date: Sat, 20 Jan 2024 01:16:09 +0330 Subject: [PATCH] code cleanup --- admin/src/components/CustomNode.js | 2 +- admin/src/components/OptionsBar.js | 2 +- admin/src/pages/HomePage/index.js | 18 ++++++++++-------- admin/src/utils/dataUtils.js | 10 ++++++++-- package.json | 4 ++-- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/admin/src/components/CustomNode.js b/admin/src/components/CustomNode.js index 60ec676..e2393ac 100644 --- a/admin/src/components/CustomNode.js +++ b/admin/src/components/CustomNode.js @@ -18,7 +18,7 @@ import { RelationIcon } from "./RelationIcon"; import { getIcon } from "../utils/themeUtils"; import "./CustomNode.css"; -export default function CustomNode({ data }) { +export function CustomNode({ data }) { let attributesToShow = Object.entries(data.attributes); if (data.options.showRelationsOnly) { diff --git a/admin/src/components/OptionsBar.js b/admin/src/components/OptionsBar.js index 717843a..77cd0f7 100644 --- a/admin/src/components/OptionsBar.js +++ b/admin/src/components/OptionsBar.js @@ -6,7 +6,7 @@ import { import React from "react"; import { useDigramStore } from "../store"; -export default function OptionsBar() { +export function OptionsBar() { const { options, toggleOption } = useDigramStore(); return (
{ @@ -86,7 +86,7 @@ const HomePage = () => { title="Content-Type Explorer" primaryAction={ } secondaryAction={ - } @@ -113,7 +117,6 @@ const HomePage = () => { onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onConnect={onConnect} - // onInit={fetchData} nodeTypes={nodeTypes} edgeTypes={edgeTypes} fitView @@ -121,7 +124,6 @@ const HomePage = () => { preventScrolling={!options.scrollMode} snapGrid={[20, 20]} snapToGrid={options.snapToGrid} - // viewport={diagram.viewport} fitViewOptions={{ maxZoom: 1, }} diff --git a/admin/src/utils/dataUtils.js b/admin/src/utils/dataUtils.js index 76b68f1..ed26c8f 100644 --- a/admin/src/utils/dataUtils.js +++ b/admin/src/utils/dataUtils.js @@ -10,7 +10,9 @@ export function createNodes(contentTypes, options) { id: node.key, position: { x: (index % CARDS_PER_ROW) * 320, - y: ((index - (index % CARDS_PER_ROW)) / CARDS_PER_ROW) * 560, + y: + ((index - (index % CARDS_PER_ROW)) / CARDS_PER_ROW) * 560 + + (index % 2) * 48, }, type: "special", @@ -38,7 +40,11 @@ export function createEdegs(contentTypes, options) { Object.keys(contentType.attributes).map((attr) => { if (contentType.attributes[attr].type == "relation") { // only add edge if target node is not excluded (not hidden) - if (contentTypes.some((node) => node.key === contentType.attributes[attr].target)) { + if ( + contentTypes.some( + (node) => node.key === contentType.attributes[attr].target + ) + ) { newEdges = [ ...newEdges, { diff --git a/package.json b/package.json index 566d37c..1f6a356 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,8 @@ } ], "engines": { - "node": ">=14.19.1 <=18.x.x", + "node": ">=14.19.1 <=20.x.x", "npm": ">=6.0.0" }, "license": "MIT" -} +} \ No newline at end of file