Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add ai chat copy button #2142

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 81 additions & 59 deletions packages/fern-docs/ui/src/feedback/Feedback.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { FernButton, FernButtonGroup, toast } from "@fern-docs/components";
import {
CopyToClipboardButton,
FernButton,
FernButtonGroup,
toast,
} from "@fern-docs/components";
import { useKeyboardPress } from "@fern-ui/react-commons";
import clsx from "clsx";
import { ThumbsDown, ThumbsUp } from "iconoir-react";
Expand Down Expand Up @@ -107,70 +112,87 @@ export const Feedback: FC<FeedbackProps> = ({
return (
<div className={className} ref={ref}>
{!sent ? (
<div className="flex flex-wrap items-center justify-start gap-4">
<span className="t-muted text-sm font-medium">
{feedbackQuestion}
</span>
<FernButtonGroup>
<FeedbackFormDialog
content={
isHelpful && (
<FeedbackForm
isHelpful={isHelpful}
onSubmit={handleSubmitFeedback}
/>
)
}
trigger={
<FernButton
icon={
<ThumbsUp
className={clsx({
"animate-thumb-rock": isHelpful === "yes",
})}
<div className="flex w-full flex-wrap items-center justify-between gap-4">
<div className="flex items-center justify-start gap-2">
<span className="t-muted text-sm font-medium">
{feedbackQuestion}
</span>
<FernButtonGroup>
<FeedbackFormDialog
content={
isHelpful && (
<FeedbackForm
isHelpful={isHelpful}
onSubmit={handleSubmitFeedback}
/>
}
variant="outlined"
intent={isHelpful === "yes" ? "success" : "none"}
onClick={handleYes}
active={isHelpful === "yes"}
>
Yes
</FernButton>
}
/>
<FeedbackFormDialog
content={
isHelpful && (
<FeedbackForm
isHelpful={isHelpful}
onSubmit={handleSubmitFeedback}
/>
)
}
trigger={
<FernButton
icon={
<ThumbsDown
className={clsx({
"animate-thumb-rock": isHelpful === "no",
})}
)
}
trigger={
<FernButton
icon={
<ThumbsUp
className={clsx({
"animate-thumb-rock": isHelpful === "yes",
})}
/>
}
variant="outlined"
intent={isHelpful === "yes" ? "success" : "none"}
onClick={handleYes}
active={isHelpful === "yes"}
>
Yes
</FernButton>
}
/>
<FeedbackFormDialog
content={
isHelpful && (
<FeedbackForm
isHelpful={isHelpful}
onSubmit={handleSubmitFeedback}
/>
}
variant="outlined"
intent={isHelpful === "no" ? "danger" : "none"}
onClick={handleNo}
active={isHelpful === "no"}
>
No
</FernButton>
}
/>
</FernButtonGroup>
)
}
trigger={
<FernButton
icon={
<ThumbsDown
className={clsx({
"animate-thumb-rock": isHelpful === "no",
})}
/>
}
variant="outlined"
intent={isHelpful === "no" ? "danger" : "none"}
onClick={handleNo}
active={isHelpful === "no"}
>
No
</FernButton>
}
/>
</FernButtonGroup>
</div>
<CopyToClipboardButton
content={
typeof metadata === "function"
? (metadata().assistant as string)
: (metadata?.assistant as string | undefined)
}
/>
</div>
) : (
<div className="flex h-6 items-center">
<span className="t-muted text-xs">Thank you for your feedback!</span>
<CopyToClipboardButton
className="float-right"
content={
typeof metadata === "function"
? (metadata().assistant as string)
: (metadata?.assistant as string | undefined)
}
/>
</div>
)}
</div>
Expand Down
Loading