Improve actions buttons

feat/topic-chat
Kamran Ahmed 1 week ago
parent fb052e9793
commit d5949fd54f
  1. 2
      src/components/TopicDetail/PredefinedActionGroup.tsx
  2. 26
      src/components/TopicDetail/PredefinedActions.tsx
  3. 4
      src/components/TopicDetail/TopicDetailAI.tsx

@ -39,7 +39,7 @@ export function PredefinedActionGroup(props: PredefinedActionGroupProps) {
<PredefinedActionButton <PredefinedActionButton
key={action.label} key={action.label}
{...action} {...action}
className="h-7 w-full rounded-none bg-transparent hover:bg-gray-200" className="py-2 pl-2.5 pr-5 w-full rounded-none bg-transparent hover:bg-gray-200"
onClick={() => { onClick={() => {
onSelect(action); onSelect(action);
setIsOpen(false); setIsOpen(false);

@ -3,7 +3,9 @@ import {
BookOpenTextIcon, BookOpenTextIcon,
BrainIcon, BrainIcon,
ChevronDownIcon, ChevronDownIcon,
ListIcon,
NotebookPenIcon, NotebookPenIcon,
PencilLine,
type LucideIcon, type LucideIcon,
} from 'lucide-react'; } from 'lucide-react';
import { cn } from '../../lib/classname'; import { cn } from '../../lib/classname';
@ -23,9 +25,20 @@ export const actions: PredefinedActionType[] = [
children: [ children: [
{ {
icon: NotebookPenIcon, icon: NotebookPenIcon,
label: 'Explain Topic', label: 'Explain the topic',
prompt: 'Explain this topic in detail and include examples', prompt: 'Explain this topic in detail and include examples',
}, },
{
icon: ListIcon,
label: 'List the key points',
prompt: 'List the key points to remember from this topic',
},
{
icon: PencilLine,
label: 'Summarize the topic',
prompt:
'Briefly explain the topic in a few sentences. Treat it as a brief answer to an interview question. Your response should just be the answer to the question, nothing else.',
},
{ {
icon: BabyIcon, icon: BabyIcon,
label: 'Explain like I am five', label: 'Explain like I am five',
@ -46,6 +59,15 @@ export const promptLabelMapping = actions.reduce(
if (action.prompt) { if (action.prompt) {
acc[action.prompt] = action.label; acc[action.prompt] = action.label;
} }
if (action.children) {
action.children.forEach((child) => {
if (child.prompt) {
acc[child.prompt] = child.label;
}
});
}
return acc; return acc;
}, },
{} as Record<string, string>, {} as Record<string, string>,
@ -107,7 +129,7 @@ export function PredefinedActionButton(props: PredefinedActionButtonProps) {
)} )}
onClick={onClick} onClick={onClick}
> >
{Icon && <Icon className="size-3.5" />} {Icon && <Icon className="size-3.5 mr-1" />}
{label} {label}
{isGroup && <ChevronDownIcon className="size-3.5" />} {isGroup && <ChevronDownIcon className="size-3.5" />}
</button> </button>

@ -267,7 +267,7 @@ export function TopicDetailAI(props: TopicDetailAIProps) {
<div <div
className={cn( className={cn(
'flex items-center justify-between gap-2 border-gray-200 px-3 py-2 text-sm', 'flex min-h-[46px] items-center justify-between gap-2 border-gray-200 px-3 py-2 text-sm',
)} )}
> >
{hasSubjects && ( {hasSubjects && (
@ -295,7 +295,7 @@ export function TopicDetailAI(props: TopicDetailAIProps) {
<div className="flex gap-1.5"> <div className="flex gap-1.5">
{hasChatHistory && ( {hasChatHistory && (
<button <button
className="rounded-md bg-white px-2 text-xs font-medium text-black hover:bg-gray-200" className="rounded-md bg-white py-2 px-2 text-xs font-medium text-black hover:bg-gray-200"
onClick={() => { onClick={() => {
setAiChatHistory(defaultChatHistory); setAiChatHistory(defaultChatHistory);
}} }}

Loading…
Cancel
Save