-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added icon component to ConversationStarters component
- Loading branch information
1 parent
9f9f44c
commit 377c2be
Showing
2 changed files
with
34 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 29 additions & 17 deletions
46
packages/react/core/src/components/ConversationStarters/ConversationStarters.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
import {ConversationStartersProps} from './props'; | ||
import { ConversationStarter } from "../../types/conversationStarter"; | ||
import { ConversationStartersProps } from "./props"; | ||
|
||
export const ConversationStarters = (props: ConversationStartersProps) => { | ||
const {onConversationStarterSelected} = props; | ||
return ( | ||
<div className="nlux-comp-conversationStarters"> | ||
{props.items.map((conversationStarter, index) => ( | ||
<button | ||
key={index} | ||
className="nlux-comp-conversationStarter" | ||
onClick={() => onConversationStarterSelected(conversationStarter)} | ||
> | ||
<span className="nlux-comp-conversationStarter-prompt"> | ||
{conversationStarter.prompt} | ||
</span> | ||
</button> | ||
))} | ||
</div> | ||
); | ||
const { onConversationStarterSelected } = props; | ||
return ( | ||
<div className="nlux-comp-conversationStarters"> | ||
{props.items.map((conversationStarter, index) => ( | ||
<button | ||
key={index} | ||
className="nlux-comp-conversationStarter" | ||
onClick={() => onConversationStarterSelected(conversationStarter)} | ||
> | ||
<ConversationStarterIcon icon={conversationStarter.icon} /> | ||
<span className="nlux-comp-conversationStarter-prompt"> | ||
{conversationStarter.prompt} | ||
</span> | ||
</button> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
const ConversationStarterIcon = ({ | ||
icon, | ||
}: { | ||
icon: ConversationStarter["icon"]; | ||
}) => { | ||
if (!icon) return null; | ||
if (typeof icon === "string") return <img src={icon} width={20} />; | ||
return icon; | ||
}; |