Skip to content

Commit

Permalink
docs: ComposerAttachment -> AttachmentUI (#1159)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Nov 12, 2024
1 parent 8dc104a commit fc42d01
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
20 changes: 12 additions & 8 deletions apps/docs/content/docs/ui/styled/Decomposition.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -206,28 +206,32 @@ Renders attachments.

Renders an add attachment button.

## ComposerAttachment
## AttachmentUI

<Callout type="info" emoji="💡">
`AttachmentUI` is still experimental.
</Callout>

Renders an attachment.

```tsx
import { ComposerAttachment } from "@assistant-ui/react";
import { AttachmentUI } from "@assistant-ui/react";

const MyComposerAttachment: FC = () => {
const MyAttachmentUI: FC = () => {
return (
<ComposerAttachment.Root>
<AttachmentUI.Root>
attachment
<ComposerAttachment.Remove />
</ComposerAttachment.Root>
<AttachmentUI.Remove />
</AttachmentUI.Root>
);
};
```

### ComposerAttachment.Root
### AttachmentUI.Root

Contains all parts of the composer attachment.

### ComposerAttachment.Remvoe
### AttachmentUI.Remove

Renders a remove attachment button.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const AttachmentThumb: FC = () => {
);
};

const Attachment: FC = () => {
const AttachmentUI: FC = () => {
const canRemove = useAttachment((a) => a.source !== "message");
const typeLabel = useAttachment((a) => {
const type = a.type;
Expand Down Expand Up @@ -165,7 +165,7 @@ const Attachment: FC = () => {
);
};

Attachment.displayName = "Attachment";
AttachmentUI.displayName = "Attachment";

namespace AttachmentRemove {
export type Element = HTMLButtonElement;
Expand Down Expand Up @@ -204,5 +204,5 @@ const exports = {
Remove: AttachmentRemove,
};

export default Object.assign(Attachment, exports) as typeof Attachment &
export default Object.assign(AttachmentUI, exports) as typeof AttachmentUI &
typeof exports;
2 changes: 1 addition & 1 deletion packages/react/src/ui/composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { CircleStopIcon } from "./base/CircleStopIcon";
import { ComposerPrimitive, ThreadPrimitive } from "../primitives";
import { useThread } from "../context/react/ThreadContext";
import Attachment from "./attachment";
import Attachment from "./attachment-ui";

const useAllowAttachments = (ensureCapability = false) => {
const { composer: { allowAttachments = true } = {} } = useThreadConfig();
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export { default as Composer } from "./composer";

export {
default as AttachmentUI, // TODO name collision with Attachment
} from "./attachment";
} from "./attachment-ui";

export { default as EditComposer } from "./edit-composer";

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ui/user-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { withDefaults } from "./utils/withDefaults";
import UserActionBar from "./user-action-bar";
import ContentPart from "./content-part";
import { MessagePrimitive } from "../primitives";
import Attachment from "./attachment";
import Attachment from "./attachment-ui";

const UserMessage: FC = () => {
return (
Expand Down

0 comments on commit fc42d01

Please sign in to comment.