Skip to content

feat: clear HeroUI components #557

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import{H as e}from"./index-Dk-2LbPC.js";const i=()=>e.jsxs("div",{children:[e.jsx("h1",{children:"Example Plugin"}),e.jsx("p",{children:"This is an example plugin."})]});export{i as default};
import{H as e}from"./index-COg_-1JS.js";const i=()=>e.jsxs("div",{children:[e.jsx("h1",{children:"Example Plugin"}),e.jsx("p",{children:"This is an example plugin."})]});export{i as default};

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

4 changes: 2 additions & 2 deletions packages/ragbits-chat/src/ragbits/chat/ui-build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/assets/ragbits-9U4hpuUb.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ragbits</title>
<script type="module" crossorigin src="/assets/index-Dk-2LbPC.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DxlHc-HZ.css">
<script type="module" crossorigin src="/assets/index-COg_-1JS.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-D23L4yB9.css">
</head>

<body class="h-full">
Expand Down
8 changes: 8 additions & 0 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ export default function Component() {
const handleScroll = useCallback(() => {
const AUTO_SCROLL_THRESHOLD = 25;
const SCROLL_DOWN_THRESHOLD = 100;

if (!scrollContainerRef.current) return;

const container = scrollContainerRef.current;
const offsetFromBottom =
container.scrollHeight - container.scrollTop - container.clientHeight;

setShowScrollDownButton(offsetFromBottom > SCROLL_DOWN_THRESHOLD);
setShouldAutoScroll(false);

if (offsetFromBottom > AUTO_SCROLL_THRESHOLD) {
setShouldAutoScroll(false);
} else {
Expand All @@ -58,6 +61,7 @@ export default function Component() {
useEffect(() => {
if (configRequest.data) {
const config = configRequest.data.data;

setConfig(config);
}
}, [configRequest.data]);
Expand All @@ -77,6 +81,7 @@ export default function Component() {

useEffect(() => {
setShouldAutoScroll(true);

if (history.length === 0) {
setShowScrollDownButton(false);
}
Expand All @@ -102,10 +107,12 @@ export default function Component() {

const scrollToBottom = useCallback(() => {
if (!scrollContainerRef.current) return;

scrollContainerRef.current.scrollTo({
top: scrollContainerRef.current.scrollHeight,
behavior: "smooth",
});

setShouldAutoScroll(true);
}, []);

Expand All @@ -126,6 +133,7 @@ export default function Component() {

const handleSubmit = () => {
sendMessage(message);
setMessage("");
};

const heroMessage = `Hello! I'm your AI assistant.\n\n How can I help you today?
Expand Down
4 changes: 3 additions & 1 deletion ui/src/core/components/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ const ChatMessage = forwardRef<HTMLDivElement, ChatMessageProps>(
ref,
) => {
const rightAlign = role === MessageRole.USER;

const [didAnimate, setDidAnimate] = useState(false);
const copyIconTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const [copyIcon, setCopyIcon] = useState("heroicons:clipboard");

const copyIconTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const { theme } = useThemeContext();

const onCopyClick = () => {
Expand Down
68 changes: 31 additions & 37 deletions ui/src/core/components/PromptInput/PromptInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ const PromptInput = ({
submit,
isLoading,
}: PromptInputProps) => {
const inputRef = React.useRef<HTMLTextAreaElement>(null);
const textAreaRef = React.useRef<HTMLTextAreaElement>(null);

const handleSubmit = useCallback(() => {
if (!prompt && !isLoading) return;
if (!message && !isLoading) return;

submit();
setMessage("");
inputRef?.current?.focus();
}, [setMessage, isLoading, submit]);
textAreaRef?.current?.focus();
}, [isLoading, submit, message]);

const onSubmit = useCallback(
(e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();

handleSubmit();
},
[handleSubmit],
Expand All @@ -50,52 +50,46 @@ const PromptInput = ({

return (
<Form
className="flex w-full flex-row items-start rounded-medium bg-default-100 dark:bg-default-100"
className="flex w-full flex-row items-center rounded-medium bg-default-100 pl-0 pr-2 dark:bg-default-100"
validationBehavior="native"
onSubmit={onSubmit}
>
<PromptInputText
ref={inputRef}
autoFocus
ref={textAreaRef}
aria-label="Message"
classNames={{
innerWrapper: "relative",
input: "text-medium h-auto w-full",
input: "text-medium",
inputWrapper:
"!bg-transparent shadow-none group-data-[focus-visible=true]:ring-0 group-data-[focus-visible=true]:ring-offset-0 pr-3 pl-[20px] pt-3 pb-4",
"!bg-transparent shadow-none group-data-[focus-visible=true]:ring-0 group-data-[focus-visible=true]:ring-offset-0 py-4",
}}
name="message"
placeholder="Enter a message here"
autoFocus
maxRows={16}
minRows={2}
name="content"
radius="lg"
spellCheck={"false"}
minRows={1}
value={message}
variant="flat"
onKeyDown={handleKeyDown}
onValueChange={setMessage}
/>
<div className="flex flex-row items-center justify-end p-3">
<Button
isIconOnly
color={!prompt ? "default" : "primary"}
isDisabled={!prompt || isLoading}
radius="full"
size="sm"
type="submit"
variant="solid"
>
<Icon
className={cn(
"[&>path]:stroke-[2px]",
!prompt ? "text-default-600" : "text-primary-foreground",
)}
icon="iconamoon:arrow-up-1-thin"
width={20}
/>
</Button>
</div>
<Button
isIconOnly
color={!message ? "default" : "primary"}
isDisabled={!message || isLoading}
radius="full"
size="sm"
type="submit"
>
<Icon
className={cn(
"[&>path]:stroke-[2px]",
!message ? "text-default-600" : "text-primary-foreground",
)}
icon="iconamoon:arrow-up-1-thin"
width={20}
/>
</Button>
</Form>
);
};

export default PromptInput;
PromptInput.displayName = "PromptInput";
52 changes: 0 additions & 52 deletions ui/src/core/components/PromptInput/PromptInputAssets.tsx

This file was deleted.

21 changes: 4 additions & 17 deletions ui/src/core/components/PromptInput/PromptInputText.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
import type { TextAreaProps } from "@heroui/react";

import React from "react";
import { forwardRef } from "react";
import { Textarea } from "@heroui/react";
import { cn } from "@heroui/react";

const PromptInputText = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(
const PromptInputText = forwardRef<HTMLTextAreaElement, TextAreaProps>(
({ classNames = {}, ...props }, ref) => {
return (
<Textarea
ref={ref}
aria-label="Prompt"
className="min-h-[40px]"
classNames={{
...classNames,
label: cn("hidden", classNames?.label),
input: cn("py-0", classNames?.input),
}}
minRows={1}
placeholder="Enter a prompt here"
radius="lg"
variant="bordered"
className="min-h-[50px]"
classNames={classNames}
{...props}
/>
);
},
);

export default PromptInputText;

PromptInputText.displayName = "PromptInputText";
112 changes: 0 additions & 112 deletions ui/src/core/components/SidebarDrawer.tsx

This file was deleted.