Skip to content

Commit

Permalink
refactor: namespace TooltipIconButton.Props (#1210)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Nov 24, 2024
1 parent ca98f96 commit ec37d8f
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 56 deletions.
6 changes: 3 additions & 3 deletions packages/react/src/primitives/threadList/ThreadListItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ComponentType, FC, memo, useMemo } from "react";
import { ThreadListItemRuntimeProvider } from "../../context/providers/ThreadListItemRuntimeProvider";
import { useAssistantRuntime, useThreadList } from "../../context";

export namespace MessagePrimitiveContent {
export namespace ThreadListPrimitiveItems {
export type Props = {
archived?: boolean | undefined;
components: {
Expand All @@ -16,7 +16,7 @@ export namespace MessagePrimitiveContent {
type ThreadListItemProps = {
partIndex: number;
archived: boolean;
components: MessagePrimitiveContent.Props["components"];
components: ThreadListPrimitiveItems.Props["components"];
};

const ThreadListItemImpl: FC<ThreadListItemProps> = ({
Expand Down Expand Up @@ -52,7 +52,7 @@ const ThreadListItem = memo(
prev.components.ThreadListItem === next.components.ThreadListItem,
);

export const ThreadListPrimitiveItems: FC<MessagePrimitiveContent.Props> = ({
export const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props> = ({
archived = false,
components,
}) => {
Expand Down
17 changes: 7 additions & 10 deletions packages/react/src/ui/assistant-action-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import {
ThumbsUpIcon,
} from "lucide-react";
import { ActionBarPrimitive, MessagePrimitive } from "../primitives";
import {
TooltipIconButton,
TooltipIconButtonProps,
} from "./base/tooltip-icon-button";
import { TooltipIconButton } from "./base/tooltip-icon-button";
import { withDefaults } from "./utils/withDefaults";
import { useThreadConfig } from "./thread-config";
import { useThread } from "../context";
Expand Down Expand Up @@ -91,7 +88,7 @@ AssistantActionBarRoot.displayName = "AssistantActionBarRoot";

namespace AssistantActionBarCopy {
export type Element = ActionBarPrimitive.Copy.Element;
export type Props = Partial<TooltipIconButtonProps> & {
export type Props = Partial<TooltipIconButton.Props> & {
copiedDuration?: number | undefined;
};
}
Expand Down Expand Up @@ -141,7 +138,7 @@ const AssistantActionBarSpeechControl: FC = () => {

namespace AssistantActionBarSpeak {
export type Element = ActionBarPrimitive.Speak.Element;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const AssistantActionBarSpeak = forwardRef<
Expand All @@ -168,7 +165,7 @@ AssistantActionBarSpeak.displayName = "AssistantActionBarSpeak";

namespace AssistantActionBarStopSpeaking {
export type Element = ActionBarPrimitive.StopSpeaking.Element;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const AssistantActionBarStopSpeaking = forwardRef<
Expand Down Expand Up @@ -197,7 +194,7 @@ AssistantActionBarStopSpeaking.displayName = "AssistantActionBarStopSpeaking";

namespace AssistantActionBarReload {
export type Element = ActionBarPrimitive.Reload.Element;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const AssistantActionBarReload = forwardRef<
Expand All @@ -223,7 +220,7 @@ AssistantActionBarReload.displayName = "AssistantActionBarReload";

namespace AssistantActionBarFeedbackPositive {
export type Element = ActionBarPrimitive.FeedbackPositive.Element;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const AssistantActionBarFeedbackPositive = forwardRef<
Expand Down Expand Up @@ -256,7 +253,7 @@ AssistantActionBarFeedbackPositive.displayName =

namespace AssistantActionBarFeedbackNegative {
export type Element = ActionBarPrimitive.FeedbackNegative.Element;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const AssistantActionBarFeedbackNegative = forwardRef<
Expand Down
9 changes: 3 additions & 6 deletions packages/react/src/ui/assistant-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import { BotIcon, ChevronDownIcon } from "lucide-react";
import { AssistantModalPrimitive } from "../primitives";
import Thread from "./thread";
import { withDefaults } from "./utils/withDefaults";
import {
TooltipIconButton,
TooltipIconButtonProps,
} from "./base/tooltip-icon-button";
import { TooltipIconButton } from "./base/tooltip-icon-button";
import {
ThreadConfig,
ThreadConfigProvider,
Expand Down Expand Up @@ -50,7 +47,7 @@ AssistantModalRoot.displayName = "AssistantModalRoot";

namespace AssistantModalTrigger {
export type Element = HTMLButtonElement;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const AssistantModalTrigger = forwardRef<
Expand Down Expand Up @@ -81,7 +78,7 @@ const ModalButtonStyled = withDefaults(TooltipIconButton, {

namespace AssistantModalButton {
export type Element = HTMLButtonElement;
export type Props = Partial<TooltipIconButtonProps> & {
export type Props = Partial<TooltipIconButton.Props> & {
"data-state"?: "open" | "closed";
};
}
Expand Down
7 changes: 2 additions & 5 deletions packages/react/src/ui/attachment-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {
import { CircleXIcon, FileIcon } from "lucide-react";
import { withDefaults } from "./utils/withDefaults";
import { useThreadConfig } from "./thread-config";
import {
TooltipIconButton,
TooltipIconButtonProps,
} from "./base/tooltip-icon-button";
import { TooltipIconButton } from "./base/tooltip-icon-button";
import { AttachmentPrimitive } from "../primitives";
import { useAttachment } from "../context/react/AttachmentContext";
import {
Expand Down Expand Up @@ -169,7 +166,7 @@ AttachmentUI.displayName = "Attachment";

namespace AttachmentRemove {
export type Element = HTMLButtonElement;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const AttachmentRemove = forwardRef<
Expand Down
5 changes: 1 addition & 4 deletions packages/react/src/ui/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ export { Button, buttonVariants, type ButtonProps } from "./button";

export { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";

export {
TooltipIconButton,
type TooltipIconButtonProps,
} from "./tooltip-icon-button";
export { TooltipIconButton } from "./tooltip-icon-button";

export { CircleStopIcon } from "./CircleStopIcon";
12 changes: 7 additions & 5 deletions packages/react/src/ui/base/tooltip-icon-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import { forwardRef } from "react";
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
import { Button, ButtonProps } from "./button";

export type TooltipIconButtonProps = ButtonProps & {
tooltip: string;
side?: "top" | "bottom" | "left" | "right";
};
export namespace TooltipIconButton {
export type Props = ButtonProps & {
tooltip: string;
side?: "top" | "bottom" | "left" | "right";
};
}

export const TooltipIconButton = forwardRef<
HTMLButtonElement,
TooltipIconButtonProps
TooltipIconButton.Props
>(({ children, tooltip, side = "bottom", ...rest }, ref) => {
return (
<Tooltip>
Expand Down
9 changes: 3 additions & 6 deletions packages/react/src/ui/branch-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import { ComponentPropsWithoutRef, forwardRef, type FC } from "react";
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";

import {
TooltipIconButton,
TooltipIconButtonProps,
} from "./base/tooltip-icon-button";
import { TooltipIconButton } from "./base/tooltip-icon-button";
import { withDefaults } from "./utils/withDefaults";
import { useThreadConfig } from "./thread-config";
import { BranchPickerPrimitive } from "../primitives";
Expand Down Expand Up @@ -40,7 +37,7 @@ BranchPickerRoot.displayName = "BranchPickerRoot";

namespace BranchPickerPrevious {
export type Element = BranchPickerPrimitive.Previous.Element;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const BranchPickerPrevious = forwardRef<
Expand Down Expand Up @@ -88,7 +85,7 @@ BranchPickerState.displayName = "BranchPickerState";

namespace BranchPickerNext {
export type Element = BranchPickerPrimitive.Next.Element;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const BranchPickerNext = forwardRef<
Expand Down
11 changes: 4 additions & 7 deletions packages/react/src/ui/composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { ComponentPropsWithoutRef, forwardRef, type FC } from "react";
import { PaperclipIcon, SendHorizontalIcon } from "lucide-react";
import { withDefaults } from "./utils/withDefaults";
import { useThreadConfig } from "./thread-config";
import {
TooltipIconButton,
TooltipIconButtonProps,
} from "./base/tooltip-icon-button";
import { TooltipIconButton } from "./base/tooltip-icon-button";
import { CircleStopIcon } from "./base/CircleStopIcon";
import { ComposerPrimitive, ThreadPrimitive } from "../primitives";
import { useThread } from "../context/react/ThreadContext";
Expand Down Expand Up @@ -94,7 +91,7 @@ const ComposerAttachButton = withDefaults(TooltipIconButton, {

namespace ComposerAddAttachment {
export type Element = HTMLButtonElement;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const ComposerAddAttachment = forwardRef<
Expand Down Expand Up @@ -152,7 +149,7 @@ const ComposerSendButton = withDefaults(TooltipIconButton, {

namespace ComposerSend {
export type Element = HTMLButtonElement;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const ComposerSend = forwardRef<ComposerSend.Element, ComposerSend.Props>(
Expand All @@ -179,7 +176,7 @@ const ComposerCancelButton = withDefaults(TooltipIconButton, {

namespace ComposerCancel {
export type Element = HTMLButtonElement;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const ComposerCancel = forwardRef<ComposerCancel.Element, ComposerCancel.Props>(
Expand Down
7 changes: 2 additions & 5 deletions packages/react/src/ui/thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import { ArrowDownIcon } from "lucide-react";
import { withDefaults } from "./utils/withDefaults";
import Composer from "./composer";
import ThreadWelcome from "./thread-welcome";
import {
TooltipIconButton,
TooltipIconButtonProps,
} from "./base/tooltip-icon-button";
import { TooltipIconButton } from "./base/tooltip-icon-button";
import AssistantMessage from "./assistant-message";
import UserMessage from "./user-message";
import EditComposer from "./edit-composer";
Expand Down Expand Up @@ -133,7 +130,7 @@ const ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {

namespace ThreadScrollToBottom {
export type Element = HTMLButtonElement;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const ThreadScrollToBottom = forwardRef<
Expand Down
7 changes: 2 additions & 5 deletions packages/react/src/ui/user-action-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import { forwardRef, type FC } from "react";
import { PencilIcon } from "lucide-react";

import {
TooltipIconButton,
TooltipIconButtonProps,
} from "./base/tooltip-icon-button";
import { TooltipIconButton } from "./base/tooltip-icon-button";
import { withDefaults } from "./utils/withDefaults";
import { useThreadConfig } from "./thread-config";
import { useThread } from "../context";
Expand Down Expand Up @@ -38,7 +35,7 @@ UserActionBarRoot.displayName = "UserActionBarRoot";

namespace UserActionBarEdit {
export type Element = ActionBarPrimitive.Edit.Element;
export type Props = Partial<TooltipIconButtonProps>;
export type Props = Partial<TooltipIconButton.Props>;
}

const UserActionBarEdit = forwardRef<
Expand Down

0 comments on commit ec37d8f

Please sign in to comment.