-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add floating action button to docsearch component
- Loading branch information
1 parent
c44be5e
commit 57d2ff1
Showing
9 changed files
with
98 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -73,31 +73,33 @@ declare module "solid-js" { | |
|
||
#### Props | ||
|
||
| Name | Type | Default | | ||
| -------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------ | | ||
| datasetId | string | '' | | ||
| apiKey | string | '' | | ||
| baseUrl | string | "https://api.trieve.ai" | | ||
| type | "docs" | "ecommerce" | "docs" | | ||
| useGroupSearch | boolean | false | | ||
| chat | boolean | true | | ||
| analytics | boolean | true | | ||
| placeholder | string | "Search..." | | ||
| onResultClick | () => void | () => {} | | ||
| theme | "light" or "dark" | "light" | | ||
| searchOptions | [AutocompleteReqPayload](https://ts-sdk.trieve.ai/types/types_gen.AutocompleteReqPayload.html) | `{ search_type: "fulltext" }` | | ||
| openKeyCombination | { key?: string; label?: string; ctrl?: boolean }[] | [{ ctrl: true }, { key: "k", label: "K" }] | | ||
| tags | { tag: string; label?: string; selected? boolean; iconClassName?: string }[] | [{tag: "docs", label: "dev docs", iconClassName: "fa-solid fa-info"}] | | ||
| ButtonEl | JSX.ElementType | null | | ||
| suggestedQueries | boolean | true | | ||
| defaultSearchQueries | string[] | [] | | ||
| defaultAiQuestions | string[] | [] | | ||
| brandLogoImgSrcUrl | string | null | | ||
| brandName | string | null | | ||
| brandColor | string | #CB53EB | | ||
| brandFontFamily | string | Maven Pro | | ||
| problemLink | string (example: "mailto:[email protected]?subject=") | null | | ||
| responsive | boolean | false | | ||
| Name | Type | Default | | ||
| ---------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------ | | ||
| datasetId | string | '' | | ||
| apiKey | string | '' | | ||
| baseUrl | string | "https://api.trieve.ai" | | ||
| type | "docs" | "ecommerce" | "docs" | | ||
| useGroupSearch | boolean | false | | ||
| chat | boolean | true | | ||
| analytics | boolean | true | | ||
| placeholder | string | "Search..." | | ||
| onResultClick | () => void | () => {} | | ||
| theme | "light" or "dark" | "light" | | ||
| searchOptions | [AutocompleteReqPayload](https://ts-sdk.trieve.ai/types/types_gen.AutocompleteReqPayload.html) | `{ search_type: "fulltext" }` | | ||
| openKeyCombination | { key?: string; label?: string; ctrl?: boolean }[] | [{ ctrl: true }, { key: "k", label: "K" }] | | ||
| tags | { tag: string; label?: string; selected? boolean; iconClassName?: string }[] | [{tag: "docs", label: "dev docs", iconClassName: "fa-solid fa-info"}] | | ||
| ButtonEl | JSX.ElementType | null | | ||
| suggestedQueries | boolean | true | | ||
| defaultSearchQueries | string[] | [] | | ||
| defaultAiQuestions | string[] | [] | | ||
| brandLogoImgSrcUrl | string | null | | ||
| brandName | string | null | | ||
| brandColor | string | #CB53EB | | ||
| brandFontFamily | string | Maven Pro | | ||
| problemLink | string (example: "mailto:[email protected]?subject=") | null | | ||
| responsive | boolean | false | | ||
| floatingButtonPosition | "top-left", "top-right", "bottom-left", or "bottom-right" | "bottom-right" | ||
| showFloatingButton | boolean | true | ||
|
||
### Search Results | ||
|
||
|
@@ -155,4 +157,4 @@ Run the example application | |
$clients/search-component cd example/ | ||
$clients/search-component yarn | ||
$clients/search-component yarn dev | ||
``` | ||
``` |
This file contains 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 |
---|---|---|
|
@@ -4,4 +4,6 @@ VITE_API_KEY="tr-zpPVGUq18FxOCmXgLfqGbmDOY4UMW00r" | |
VITE_BRAND_LOGO_SRC_URL="https://cdn.trieve.ai/trieve-logo.png" | ||
VITE_BRAND_NAME="Trieve" | ||
VITE_BRAND_COLOR="#CB53EB" | ||
VITE_PROBLEM_LINK="mailto:[email protected]?subject=" | ||
VITE_PROBLEM_LINK="mailto:[email protected]?subject=" | ||
VITE_SHOW_FLOATING_BTN="true" | ||
VITE_FLOATING_BTN_POSITION="bottom-right" |
This file contains 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
This file contains 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
This file contains 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
43 changes: 43 additions & 0 deletions
43
clients/search-component/src/TrieveModal/FloatingActionButton.tsx
This file contains 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,43 @@ | ||
import React, { startTransition } from "react"; | ||
import { useModalState } from "../utils/hooks/modal-context"; | ||
|
||
export const FloatingActionButton = () => { | ||
const { props, setOpen, setMode } = useModalState(); | ||
|
||
const setButtonPosition = (position: string) => { | ||
switch (position) { | ||
case "top-left": | ||
return { top: "20px", left: "20px" }; | ||
case "top-right": | ||
return { top: "20px", right: "20px" }; | ||
case "bottom-left": | ||
return { bottom: "20px", left: "20px" }; | ||
case "bottom-right": | ||
return { bottom: "20px", right: "20px" }; | ||
default: | ||
return { bottom: "20px", right: "20px" }; | ||
} | ||
}; | ||
|
||
return ( | ||
<button | ||
onClick={() => { | ||
startTransition(() => { | ||
setOpen(true); | ||
setMode("chat"); | ||
}); | ||
}} | ||
className="floating-action-button" | ||
style={{ | ||
...setButtonPosition(props.floatingButtonPosition || "bottom-right"), | ||
display: props.showFloatingButton ? "" : "none", | ||
}} | ||
> | ||
<i | ||
className="fa-solid fa-wand-magic-sparkles" | ||
style={{ fontSize: "14px" }} | ||
></i> | ||
Ask AI | ||
</button> | ||
); | ||
}; |
This file contains 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
This file contains 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
This file contains 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