Skip to content

Commit

Permalink
feat(ui): allow icon override (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Jul 12, 2024
1 parent caf0774 commit 7ff0bf3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
16 changes: 10 additions & 6 deletions packages/react/src/ui/assistant-action-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ const AssistantActionBarCopy = forwardRef<
return (
<ActionBarPrimitive.Copy asChild>
<TooltipIconButton tooltip={tooltip} {...props} ref={ref}>
<MessagePrimitive.If copied>
<CheckIcon />
</MessagePrimitive.If>
<MessagePrimitive.If copied={false}>
<CopyIcon />
</MessagePrimitive.If>
{props.children ?? (
<>
<MessagePrimitive.If copied>
<CheckIcon />
</MessagePrimitive.If>
<MessagePrimitive.If copied={false}>
<CopyIcon />
</MessagePrimitive.If>
</>
)}
</TooltipIconButton>
</ActionBarPrimitive.Copy>
);
Expand Down
19 changes: 12 additions & 7 deletions packages/react/src/ui/assistant-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ const AssistantModalButton = forwardRef<
{...rest}
ref={ref}
>
<BotIcon data-state={state} className="aui-modal-button-closed-icon" />

<ChevronDownIcon
data-state={state}
className="aui-modal-button-open-icon"
/>
<span className="aui-sr-only">{tooltip}</span>
{rest.children ?? (
<>
<BotIcon
data-state={state}
className="aui-modal-button-closed-icon"
/>
<ChevronDownIcon
data-state={state}
className="aui-modal-button-open-icon"
/>
</>
)}
</ModalButtonStyled>
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/ui/branch-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const BranchPickerPrevious = forwardRef<
return (
<BranchPickerPrimitive.Previous asChild>
<TooltipIconButton tooltip={tooltip} {...props} ref={ref}>
<ChevronLeftIcon />
{props.children ?? <ChevronLeftIcon />}
</TooltipIconButton>
</BranchPickerPrimitive.Previous>
);
Expand Down Expand Up @@ -76,7 +76,7 @@ const BranchPickerNext = forwardRef<
return (
<BranchPickerPrimitive.Next asChild>
<TooltipIconButton tooltip={tooltip} {...props} ref={ref}>
<ChevronRightIcon />
{props.children ?? <ChevronRightIcon />}
</TooltipIconButton>
</BranchPickerPrimitive.Next>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/ui/composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const ComposerSend = forwardRef<
return (
<ComposerPrimitive.Send asChild>
<ComposerSendButton tooltip={tooltip} {...props} ref={ref}>
<SendHorizonalIcon />
{props.children ?? <SendHorizonalIcon />}
</ComposerSendButton>
</ComposerPrimitive.Send>
);
Expand All @@ -115,7 +115,7 @@ const ComposerCancel = forwardRef<
return (
<ComposerPrimitive.Cancel asChild>
<ComposerCancelButton tooltip={tooltip} {...props} ref={ref}>
<CircleStopIcon />
{props.children ?? <CircleStopIcon />}
</ComposerCancelButton>
</ComposerPrimitive.Cancel>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/ui/edit-composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const EditComposerCancel = forwardRef<HTMLButtonElement, Partial<ButtonProps>>(
return (
<ComposerPrimitive.Cancel asChild>
<Button variant="ghost" {...props} ref={ref}>
{label}
{props.children ?? label}
</Button>
</ComposerPrimitive.Cancel>
);
Expand All @@ -67,7 +67,7 @@ const EditComposerSend = forwardRef<HTMLButtonElement, Partial<ButtonProps>>(
return (
<ComposerPrimitive.Send asChild>
<Button {...props} ref={ref}>
{label}
{props.children ?? label}
</Button>
</ComposerPrimitive.Send>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ui/thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const ThreadScrollToBottom = forwardRef<
return (
<ThreadPrimitive.ScrollToBottom asChild>
<ThreadScrollToBottomIconButton tooltip={tooltip} {...props} ref={ref}>
<ArrowDownIcon />
|{props.children ?? <ArrowDownIcon />}
</ThreadScrollToBottomIconButton>
</ThreadPrimitive.ScrollToBottom>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ui/user-action-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const UserActionBarEdit = forwardRef<
return (
<ActionBarPrimitive.Edit asChild>
<TooltipIconButton tooltip={tooltip} {...props} ref={ref}>
<PencilIcon />
{props.children ?? <PencilIcon />}
</TooltipIconButton>
</ActionBarPrimitive.Edit>
);
Expand Down

0 comments on commit 7ff0bf3

Please sign in to comment.