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

Enhance Message Component to Support ReactNode in Content via extraContent Prop #418

Open
anujsingla opened this issue Jan 26, 2025 · 0 comments · May be fixed by #419
Open

Enhance Message Component to Support ReactNode in Content via extraContent Prop #418

anujsingla opened this issue Jan 26, 2025 · 0 comments · May be fixed by #419
Assignees
Labels
PF6 Applies to only the PF6 version

Comments

@anujsingla
Copy link

anujsingla commented Jan 26, 2025

Currently, the content prop in the Message component only accepts strings, limiting the flexibility for rendering dynamic or custom content. I propose adding an extraContent prop that allows consumers to inject custom React components at specific locations within the message.
Message component - https://github.com/patternfly/chatbot/blob/main/packages/module/src/Message/Message.tsx

Proposed Solution:
Introduce a new extraContent prop with the following structure:

export interface MessageExtraContent {
  /** Content to display before the main content */
  beforeMainContent?: ReactNode;

  /** Content to display after the main content */
  afterMainContent?: ReactNode;

  /** Content to display at the end */
  endContent?: ReactNode;
}

Example Usage:

<Message
  role="user"
  avatar="path/to/avatar.png"
  content="Hello, this is a string content"
  extraContent={{
    beforeMainContent: <div>Custom Component Before</div>,
    afterMainContent: <div>Custom Component After</div>,
    endContent: <div>Footer Component</div>,
  }}
/>

Benefits:

  • Enables more flexible and dynamic content rendering within the Message component.
  • Content still supports strings for basic use cases.
  • This change will enhance the usability of the Message component for developers who need custom layouts or additional content injection without breaking existing functionality.
@github-project-automation github-project-automation bot moved this to Needs triage in PatternFly Issues Jan 26, 2025
@rebeccaalpert rebeccaalpert added the PF6 Applies to only the PF6 version label Jan 28, 2025
@rebeccaalpert rebeccaalpert moved this from Needs triage to PR Review in PatternFly Issues Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PF6 Applies to only the PF6 version
Projects
Status: PR Review
Development

Successfully merging a pull request may close this issue.

2 participants