Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tooltip to nodes #73

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import React from 'react';
import { Resource } from '../../graph';
import { Handle, NodeProps, Position } from 'reactflow';
import { Handle, NodeProps, Position, NodeToolbar } from 'reactflow';
import { parseResourceId } from '@radapp.io/rad-components';

// Note: the default style assigned to a node gives it a 150px width
// from style: .react-flow__node-default.

export type ResourceNodeProps = Pick<NodeProps<Resource>, 'data'>;

function ResourceNode(props: ResourceNodeProps) {
const group = parseResourceId(props.data.id)?.group;

return (
<>
<NodeToolbar position={Position.Left} align={'center'}>
<div
style={{ padding: '4px', backgroundColor: 'grey', fontSize: '.6rem' }}
>
<p style={{ textAlign: 'left' }}>Name: {props.data.name}</p>
<p style={{ textAlign: 'left' }}>Type: {props.data.type}</p>
<p style={{ textAlign: 'left' }}>Group: {group}</p>
</div>
</NodeToolbar>

<Handle type="target" position={Position.Top} />
<div style={{ padding: '2px', fontSize: '.6rem' }}>
<h3 style={{ textAlign: 'center' }}>{props.data.name}</h3>
Expand All @@ -21,4 +34,4 @@ function ResourceNode(props: ResourceNodeProps) {
);
}

export default ResourceNode;
export default React.memo(ResourceNode);
Loading