-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
feat(orama): use new UI components #7971
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
aileenvl
wants to merge
22
commits into
nodejs:main
Choose a base branch
from
oramasearch:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7c4f8e5
feat: add new searchbox - initial setup
g-francesca e4d0c1d
style: search button
g-francesca 086dd84
style: searchbox empty state
g-francesca 8451f80
style: modal search
g-francesca 8ecdf9e
style: prompt wrapper
g-francesca 6ac3d65
fix: layout sliding panel
g-francesca 87db2f9
style: chat sources
g-francesca 40ea1c8
refactor: search component
g-francesca 31273fd
feat: add translations for search component
g-francesca 31e2db8
update orama core and update logo
aileenvl 2a22940
update sync
aileenvl 65ecd9f
update pnpm-lock
aileenvl 834636f
Update apps/site/components/Common/Searchbox/Chat.tsx
aileenvl f088203
Update apps/site/components/Common/Searchbox/Chat.tsx
aileenvl 3d582dd
Update apps/site/components/Common/Searchbox/Search.tsx
aileenvl b1fff6a
Update apps/site/components/Common/Searchbox/Search.tsx
aileenvl e09fa32
Update apps/site/components/Common/Searchbox/Search.tsx
aileenvl d37297f
fix height and pr comments
aileenvl 954ee99
Merge branch 'main' of https://github.com/oramasearch/nodejs.org
aileenvl ff59f5b
fix import and add directories for Search and Chat
aileenvl 8d7657e
update icon and orama ui components
aileenvl 43c56bd
rollback translation changes
aileenvl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
'use client'; | ||
aileenvl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import { ArrowUpIcon } from '@heroicons/react/20/solid'; | ||
import { | ||
ArrowPathRoundedSquareIcon, | ||
ClipboardIcon, | ||
DocumentCheckIcon, | ||
} from '@heroicons/react/24/outline'; | ||
import { | ||
ArrowDownIcon, | ||
PauseCircleIcon, | ||
XMarkIcon, | ||
} from '@heroicons/react/24/solid'; | ||
import Skeleton from '@node-core/ui-components/Common/Skeleton'; | ||
import { | ||
ChatInteractions, | ||
PromptTextArea, | ||
SlidingPanel, | ||
} from '@orama/ui/components'; | ||
import { useScrollableContainer } from '@orama/ui/hooks/useScrollableContainer'; | ||
import Link from 'next/link'; | ||
import { useLocale, useTranslations } from 'next-intl'; | ||
import { type FC, type PropsWithChildren } from 'react'; | ||
aileenvl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import styles from './chat.module.css'; | ||
|
||
type SlidingChatPanelProps = PropsWithChildren & { | ||
open: boolean; | ||
onClose: () => void; | ||
}; | ||
aileenvl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export const SlidingChatPanel: FC<SlidingChatPanelProps> = ({ | ||
open, | ||
onClose, | ||
}) => { | ||
const locale = useLocale(); | ||
const t = useTranslations(); | ||
const { | ||
containerRef, | ||
showGoToBottomButton, | ||
scrollToBottom, | ||
recalculateGoToBottomButton, | ||
} = useScrollableContainer(); | ||
|
||
return ( | ||
<> | ||
<SlidingPanel.Wrapper open={open} onClose={onClose}> | ||
<SlidingPanel.Backdrop /> | ||
<SlidingPanel.Content className={styles.slidingPanelContent}> | ||
<SlidingPanel.Close | ||
className={styles.slidingPanelCloseButton} | ||
aria-label={t('components.search.closeChat')} | ||
> | ||
<XMarkIcon /> | ||
</SlidingPanel.Close> | ||
<div className={styles.slidingPanelInner}> | ||
<div className={styles.slidingPanelTop}> | ||
<ChatInteractions.Wrapper | ||
ref={containerRef} | ||
onScroll={recalculateGoToBottomButton} | ||
onStreaming={recalculateGoToBottomButton} | ||
onNewInteraction={() => scrollToBottom({ animated: true })} | ||
className={styles.chatInteractionsWrapper} | ||
> | ||
{(interaction, index, totalInteractions) => ( | ||
<> | ||
<ChatInteractions.UserPrompt | ||
className={styles.chatUserPrompt} | ||
> | ||
<p>{interaction.query}</p> | ||
</ChatInteractions.UserPrompt> | ||
|
||
{interaction.loading && !interaction.response ? ( | ||
<Skeleton className={styles.chatLoader} /> | ||
) : ( | ||
<> | ||
<ChatInteractions.Sources | ||
sources={ | ||
Array.isArray(interaction.sources) | ||
? interaction.sources | ||
: [] | ||
} | ||
className={styles.chatSources} | ||
itemClassName={styles.chatSourceItem} | ||
> | ||
{(document, index: number) => ( | ||
<div className={styles.chatSource} key={index}> | ||
<Link | ||
data-focus-on-arrow-nav | ||
className={styles.chatSourceLink} | ||
href={ | ||
( | ||
document.siteSection as string | ||
).toLowerCase() === 'docs' | ||
? `/${document.path}` | ||
: `/${locale}/${document.path}` | ||
} | ||
> | ||
<span className={styles.chatSourceTitle}> | ||
{document?.pageSectionTitle as string} | ||
</span> | ||
</Link> | ||
</div> | ||
)} | ||
</ChatInteractions.Sources> | ||
|
||
<div className={styles.chatAssistantMessageWrapper}> | ||
<ChatInteractions.AssistantMessage | ||
className={styles.chatAssistantMessage} | ||
> | ||
{interaction.response} | ||
</ChatInteractions.AssistantMessage> | ||
|
||
{!interaction.loading && ( | ||
<div className={styles.chatActionsContainer}> | ||
<ul className={styles.chatActionsList}> | ||
{index === totalInteractions && ( | ||
<li> | ||
<ChatInteractions.RegenerateLatest | ||
className={styles.chatAction} | ||
> | ||
<ArrowPathRoundedSquareIcon /> | ||
</ChatInteractions.RegenerateLatest> | ||
</li> | ||
)} | ||
<li> | ||
<ChatInteractions.CopyMessage | ||
className={styles.chatAction} | ||
interaction={interaction} | ||
copiedContent={ | ||
<DocumentCheckIcon | ||
className={ | ||
styles.chatActionIconSelected | ||
} | ||
/> | ||
} | ||
> | ||
<ClipboardIcon /> | ||
</ChatInteractions.CopyMessage> | ||
</li> | ||
</ul> | ||
</div> | ||
)} | ||
</div> | ||
</> | ||
)} | ||
</> | ||
)} | ||
</ChatInteractions.Wrapper> | ||
</div> | ||
<div className={styles.slidingPanelBottom}> | ||
{showGoToBottomButton && ( | ||
<button | ||
onClick={() => scrollToBottom({ animated: true })} | ||
className={styles.scrollDownButton} | ||
aria-label={t('components.search.scrollToBottom')} | ||
> | ||
<ArrowDownIcon /> | ||
</button> | ||
)} | ||
<PromptTextArea.Wrapper className={styles.promptTextAreaWrapper}> | ||
<PromptTextArea.Field | ||
placeholder={t('components.search.chatPlaceholder')} | ||
rows={1} | ||
maxLength={500} | ||
autoFocus | ||
className={styles.promptTextAreaField} | ||
/> | ||
<PromptTextArea.Button | ||
abortContent={<PauseCircleIcon />} | ||
className={styles.promptTextAreaButton} | ||
> | ||
<ArrowUpIcon /> | ||
</PromptTextArea.Button> | ||
</PromptTextArea.Wrapper> | ||
<div className={styles.slidingPanelFooter}> | ||
<small>{t('components.search.disclaimer')}</small> | ||
</div> | ||
</div> | ||
</div> | ||
</SlidingPanel.Content> | ||
</SlidingPanel.Wrapper> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.