Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions packages/module/src/SourcesCard/SourcesCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
list-style: none;
gap: var(--pf-t--global--spacer--xs);
}

.pf-chatbot__sources-list-item {
display: flex;
width: var(--pf-chatbot-sources-card-max-width);
}

.pf-chatbot__sources-card {
flex: 1;
}
}

.pf-chatbot__sources-card {
Expand Down
8 changes: 4 additions & 4 deletions packages/module/src/SourcesCardBase/SourcesCardBase.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ describe('SourcesCardBase', () => {
]}
/>
);
const firstCard = screen.getByText('How to make an apple pie').closest('.pf-chatbot__sources-card');
expect(firstCard).toHaveStyle({ maxWidth: '400px' });
const firstListItem = screen.getByText('How to make an apple pie').closest('.pf-chatbot__sources-list-item');
expect(firstListItem).toHaveStyle({ '--pf-chatbot-sources-card-max-width': '400px' });
});

it('should apply custom cardMaxWidth when using wrap layout', () => {
Expand All @@ -279,7 +279,7 @@ describe('SourcesCardBase', () => {
cardMaxWidth="500px"
/>
);
const firstCard = screen.getByText('How to make an apple pie').closest('.pf-chatbot__sources-card');
expect(firstCard).toHaveStyle({ maxWidth: '500px' });
const firstListItem = screen.getByText('How to make an apple pie').closest('.pf-chatbot__sources-list-item');
expect(firstListItem).toHaveStyle({ '--pf-chatbot-sources-card-max-width': '500px' });
});
});
15 changes: 12 additions & 3 deletions packages/module/src/SourcesCardBase/SourcesCardBase.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// ============================================================================
// Chatbot Main - Messages - Sources Card
// ============================================================================
import type { FunctionComponent, MouseEvent as ReactMouseEvent, KeyboardEvent as ReactKeyboardEvent } from 'react';
import type {
FunctionComponent,
MouseEvent as ReactMouseEvent,
KeyboardEvent as ReactKeyboardEvent,
CSSProperties
} from 'react';
import { useState } from 'react';
// Import PatternFly components
import {
Expand Down Expand Up @@ -122,8 +127,12 @@ const SourcesCardBase: FunctionComponent<SourcesCardBaseProps> = ({
};

const renderUncontrolledSourceCard = (source: SourcesCardBaseProps['sources'][0], index: number) => (
<li key={index} className="pf-chatbot__sources-list-item">
<Card isCompact={isCompact} className="pf-chatbot__sources-card" style={{ maxWidth: cardMaxWidth }} {...props}>
<li
key={index}
className="pf-chatbot__sources-list-item"
style={{ '--pf-chatbot-sources-card-max-width': cardMaxWidth } as CSSProperties}
>
<Card isCompact={isCompact} className="pf-chatbot__sources-card" {...props}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like we discussed offline, you should be able to address the jagged height with isFullheight on the Card. Alternatively you could remove the li and make the card an li with component="li" but that's probably less flexible.

<CardTitle className="pf-chatbot__sources-card-title" {...cardTitleProps}>
<div className="pf-chatbot__sources-card-title-container">
<Button
Expand Down
Loading