mindmap-drawer.tsx

Overview

mindmap-drawer.tsx defines a React functional component named MindMapDrawer that provides a user interface element for displaying a mind map inside a sliding drawer panel. It leverages Ant Design's Drawer component to present content conditionally based on loading state: either a circular progress indicator showing the loading percentage of a pending mind map or a fully rendered indented tree structure representing the mind map data.

This file mainly serves as a UI wrapper component that integrates translation support, loading progress visualization, and hierarchical data presentation for mind maps. It is intended to be used in contexts where a user needs to view or interact with a mind map in a collapsible side panel.


Detailed Explanations

interface IProps

Defines the props accepted by the MindMapDrawer component.

Property

Type

Description

data

any

The mind map data to be rendered by IndentedTree. Expected to be hierarchical.

hideModal

() => void

Function to close or hide the drawer/modal. (Inherited from IModalProps)

visible

boolean

Controls visibility of the drawer/modal. (Inherited from IModalProps)

loading

boolean

Indicates if the mind map data is in a loading state, triggering the display of a progress indicator.


MindMapDrawer Component

const MindMapDrawer = ({ data, hideModal, visible, loading }: IProps) => { ... }

Purpose

Renders a drawer UI that either displays a circular loading progress indicator or a mind map tree visualization, depending on the loading state.

Parameters

Returns

A React element representing the drawer with conditional content.

Internal Details and Usage

Example Usage

<MindMapDrawer
  data={mindMapData}
  visible={isDrawerVisible}
  hideModal={() => setDrawerVisible(false)}
  loading={isDataLoading}
/>

This would show the drawer with either the loading progress or the mind map depending on isDataLoading. The drawer visibility is controlled by isDrawerVisible, and closing it triggers setDrawerVisible(false).


Important Implementation Details


Interaction with Other Parts of the System


Visual Diagram

componentDiagram
    MindMapDrawer <|-- AntD_Drawer : uses
    MindMapDrawer <|-- IndentedTree : renders when !loading
    MindMapDrawer <|-- Progress : renders when loading
    MindMapDrawer o-- usePendingMindMap : calls hook for loading %
    MindMapDrawer o-- useTranslation : calls hook for localization

Summary

The mindmap-drawer.tsx file implements a specialized React component that provides a user-friendly, internationalized drawer interface for displaying and interacting with mind maps. It cleanly separates concerns between loading state visualization and data rendering, uses standardized UI components for consistency, and is designed to integrate seamlessly within a larger React application that manages mind map data and UI state externally.