mindmap-drawer.tsx


Overview

mindmap-drawer.tsx is a React functional component that provides a UI drawer for displaying a mind map visualization. The drawer can toggle between a loading state, showing a progress bar representing the loading progress of the mind map data, and a loaded state, rendering the mind map as an indented tree structure.

This component is designed to be used as a modal drawer, integrating with the application's modal system through props such as hideModal and visible. It leverages internationalization (i18n) for text, and uses other UI components like a progress bar and an indented tree to render its content.


Component: MindMapDrawer

Description

MindMapDrawer renders a modal drawer that displays a mind map visualization. It manages two primary UI states:

It also includes a header with a title and a close button.

Signature

const MindMapDrawer: React.FC<IProps>

Props (IProps interface)

IProps extends a generic modal interface IModalProps<any> and includes:

Prop

Type

Description

data

any

The mind map data to be visualized in the indented tree.

hideModal

() => void (optional)

Function to close/hide the modal drawer.

visible

boolean (optional)

Controls the visibility of the drawer/modal.

loading

boolean (optional)

Indicates if the mind map data is currently loading.

Internal Hooks and Dependencies

Render Logic

Usage Example

import MindMapDrawer from './mindmap-drawer';

const mindMapData = {
  id: 1,
  name: "Root Node",
  children: [
    { id: 2, name: "Child 1", children: [] },
    { id: 3, name: "Child 2", children: [] }
  ]
};

const MyComponent = () => {
  const [visible, setVisible] = React.useState(true);
  const [loading, setLoading] = React.useState(false);

  return (
    <MindMapDrawer
      data={mindMapData}
      visible={visible}
      loading={loading}
      hideModal={() => setVisible(false)}
    />
  );
};

Implementation Details


Interactions with Other Parts of the System


Mermaid Component Diagram

The following diagram illustrates the main components and their relationships inside mindmap-drawer.tsx:

componentDiagram
    component MindMapDrawer {
      +data: any
      +hideModal(): void
      +visible: boolean
      +loading: boolean
    }
    component IndentedTree
    component Progress
    component XIcon
    component usePendingMindMap
    component useTranslation

    MindMapDrawer --> IndentedTree : renders mind map data
    MindMapDrawer --> Progress : shows loading progress
    MindMapDrawer --> XIcon : close button
    MindMapDrawer --> usePendingMindMap : retrieves loading %
    MindMapDrawer --> useTranslation : provides localized text

Summary

mindmap-drawer.tsx is a specialized React component designed to render a mind map inside a modal drawer interface. It elegantly handles loading states with a progress bar and displays the mind map data using an indented tree visualization. The component integrates with the broader application through modal controls, localization, and data loading hooks, making it a reusable and well-structured UI element for mind map presentation.


End of documentation for mindmap-drawer.tsx