prompt-modal.tsx


Overview

prompt-modal.tsx defines a React functional component named PromptModal. This component renders a modal dialog using the Ant Design (antd) library to display a textual prompt with syntax highlighting. The modal is intended to show detailed prompt content, likely used in feedback or chat-related interfaces where users or systems interact with prompts.

The component is designed to be reusable and configurable via props, supporting visibility toggling, closing behavior, and dynamic prompt content. It leverages custom components for rendering highlighted markdown and SVG icons, enhancing the user interface with visual clarity and branding.


Detailed Component Documentation

PromptModal

Description

PromptModal is a presentational React component that displays a modal dialog containing a prompt message formatted in markdown with syntax highlighting. It provides UI elements such as a title with an icon and a content area that renders the prompt.

Props

This component accepts the following props, combining a generic modal interface and an optional prompt string:

Prop Name

Type

Required

Description

visible

boolean

Yes

Controls the visibility of the modal. When true, the modal is shown; when false, it is hidden.

hideModal

() => void

Yes

Callback function invoked when the modal is requested to be closed (e.g., clicking outside or on the close icon).

prompt

string

No

The textual prompt content to display inside the modal, rendered with markdown highlighting.

Note: The visible and hideModal props are part of the interface IModalProps<IFeedbackRequestBody>, indicating integration with a feedback or chat request context, but only their usage in this component is relevant.

Return Value

The component returns JSX representing the modal UI.

Usage Example

import PromptModal from './prompt-modal';

const ExampleUsage = () => {
  const [isModalVisible, setModalVisible] = React.useState(false);
  const promptText = "### Example Prompt\nThis is a sample prompt with **markdown** support.";

  return (
    <>
      <button onClick={() => setModalVisible(true)}>Show Prompt</button>
      <PromptModal
        visible={isModalVisible}
        hideModal={() => setModalVisible(false)}
        prompt={promptText}
      />
    </>
  );
};

Implementation Details


Interaction with Other Parts of the System

This file is likely used within a broader feedback or chat UI flow where users interact with prompts, review them, and optionally provide feedback or take further actions.


Visual Diagram

componentDiagram
    component PromptModal {
        +visible: boolean
        +hideModal(): void
        +prompt?: string
    }
    component Modal
    component Space
    component SvgIcon
    component HightLightMarkdown

    PromptModal --> Modal : renders
    Modal --> Space : uses for title layout
    Space --> SvgIcon : displays icon
    Modal --> HightLightMarkdown : renders prompt content

Summary

This component encapsulates prompt display logic, making it easy to integrate prompt visualization consistently across the application.