Skip to content

Commit

Permalink
Updated DOM structure related to conversation starters
Browse files Browse the repository at this point in the history
  • Loading branch information
salmenus committed Jun 2, 2024
1 parent bdffe50 commit e828efc
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.nlux-comp-conversationStarters-container {
.nlux-conversationStarters-container {
overflow-y: scroll;

> .nlux-comp-conversationStarters {
Expand Down
4 changes: 4 additions & 0 deletions packages/css/themes/src/common/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
overflow-y: auto;
flex: 1;
padding: var(--nlux-chtr--pdng) var(--nlux-chtr--pdng) var(--nlux-dvr--mrgBtm) var(--nlux-chtr--pdng);

> .nlux-conversationStarters-container:empty {
display: none;
}
}

> .nlux-composer-container {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export const renderConversation: CompRenderer<
segmentsContainer.classList.add('nlux-chatSegments-container');

const conversationStartersContainer = document.createElement('div') as HTMLElement;
conversationStartersContainer.classList.add('nlux-comp-conversationStarters-container');
conversationStartersContainer.classList.add('nlux-conversationStarters-container');

appendToRoot(segmentsContainer);
appendToRoot(conversationStartersContainer);
appendToRoot(segmentsContainer);

//
// Create welcome message container
Expand All @@ -63,7 +63,7 @@ export const renderConversation: CompRenderer<
}

if (renderingContext.welcomeMessageContainer) {
segmentsContainer.insertAdjacentElement('afterend', renderingContext.welcomeMessageContainer);
conversationStartersContainer.insertAdjacentElement('beforebegin', renderingContext.welcomeMessageContainer);
}
}

Expand Down Expand Up @@ -94,8 +94,8 @@ export const renderConversation: CompRenderer<
: createDefaultWelcomeMessageDom();

if (renderingContext.welcomeMessageContainer) {
segmentsContainer.insertAdjacentElement(
'afterend',
conversationStartersContainer.insertAdjacentElement(
'beforebegin',
renderingContext.welcomeMessageContainer,
);
}
Expand All @@ -120,8 +120,8 @@ export const renderConversation: CompRenderer<
: createDefaultWelcomeMessageDom();

if (renderingContext.welcomeMessageContainer) {
segmentsContainer.insertAdjacentElement(
'afterend',
conversationStartersContainer.insertAdjacentElement(
'beforebegin',
renderingContext.welcomeMessageContainer,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ export const ConversationComp: ConversationCompType = function <AiMsg>(
message={personaOptions!.assistant!.tagline}
/>
)}
{showConversationStarters && (
<ConversationStarters
items={conversationOptions!.conversationStarters ?? []}
onConversationStarterSelected={props.onConversationStarterSelected}
/>
)}
<div className="nlux-conversationStarters-container">
{showConversationStarters && (
<ConversationStarters
items={conversationOptions!.conversationStarters ?? []}
onConversationStarterSelected={props.onConversationStarterSelected}
/>
)}
</div>
<div className="nlux-chatSegments-container">
{segments.map((segment, index) => {
const isLastSegment = index === segments.length - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ import {ConversationStartersProps} from './props';
export const ConversationStarters = (props: ConversationStartersProps) => {
const {onConversationStarterSelected} = props;
return (
<div className="nlux-comp-conversationStarters-container">
<div className="nlux-comp-conversationStarters">
{props.items.map((conversationStarter, index) => (
<button
key={index}
className="nlux-comp-conversationStarter"
onClick={() => onConversationStarterSelected(conversationStarter)}
>
{conversationStarter.prompt}
</button>
))}
</div>
<div className="nlux-comp-conversationStarters">
{props.items.map((conversationStarter, index) => (
<button
key={index}
className="nlux-comp-conversationStarter"
onClick={() => onConversationStarterSelected(conversationStarter)}
>
{conversationStarter.prompt}
</button>
))}
</div>
);
};

0 comments on commit e828efc

Please sign in to comment.