feat: The Big One UI #47
@@ -53,6 +53,11 @@
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning-item:hover {
|
||||||
|
background: ButtonFace;
|
||||||
}
|
}
|
||||||
|
|
||||||
.warning-item--error {
|
.warning-item--error {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import {useReactFlow} from "@xyflow/react";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import useFlowStore from "../VisProgStores.tsx";
|
import useFlowStore from "../VisProgStores.tsx";
|
||||||
@@ -82,8 +83,13 @@ function WarningsList(props: { warnings: EditorWarning[] }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function WarningListItem(props: { warning: EditorWarning }) {
|
function WarningListItem(props: { warning: EditorWarning }) {
|
||||||
|
const jumpToNode = useJumpToNode();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx(styles.warningItem, styles[`warning-item--${props.warning.severity.toLowerCase()}`],)}>
|
<div
|
||||||
|
className={clsx(styles.warningItem, styles[`warning-item--${props.warning.severity.toLowerCase()}`],)}
|
||||||
|
onClick={() => jumpToNode(props.warning.scope.id)}
|
||||||
|
>
|
||||||
<div className={styles.description}>
|
<div className={styles.description}>
|
||||||
{props.warning.description}
|
{props.warning.description}
|
||||||
</div>
|
</div>
|
||||||
@@ -97,3 +103,22 @@ function WarningListItem(props: { warning: EditorWarning }) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function useJumpToNode() {
|
||||||
|
const { getNode, setCenter } = useReactFlow();
|
||||||
|
|
||||||
|
return (nodeId: string) => {
|
||||||
|
const node = getNode(nodeId);
|
||||||
|
if (!node) return;
|
||||||
|
|
||||||
|
const { position, width = 0, height = 0} = node;
|
||||||
|
|
||||||
|
// move to node
|
||||||
|
setCenter(
|
||||||
|
position!.x + width / 2,
|
||||||
|
position!.y + height / 2,
|
||||||
|
{ zoom: 2, duration: 300 }
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -46,6 +46,7 @@ export default function PhaseNode(props: NodeProps<PhaseNode>) {
|
|||||||
const {registerWarning, unregisterWarning} = useFlowStore.getState();
|
const {registerWarning, unregisterWarning} = useFlowStore.getState();
|
||||||
const connections = useNodeConnections({
|
const connections = useNodeConnections({
|
||||||
id: props.id,
|
id: props.id,
|
||||||
|
handleType: "target",
|
||||||
handleId: 'data'
|
handleId: 'data'
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ export default function PhaseNode(props: NodeProps<PhaseNode>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (connections.length === 0) { registerWarning(noConnectionWarning); }
|
if (connections.length === 0) { registerWarning(noConnectionWarning); }
|
||||||
else { unregisterWarning(props.id, `${noConnectionWarning.type}:source`); }
|
else { unregisterWarning(props.id, `${noConnectionWarning.type}:data`); }
|
||||||
}, [connections.length, props.id, registerWarning, unregisterWarning]);
|
}, [connections.length, props.id, registerWarning, unregisterWarning]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user