Skip to content

Commit cc1a9fd

Browse files
committed
add inline parameter
1 parent 20e114d commit cc1a9fd

7 files changed

Lines changed: 48 additions & 18 deletions

File tree

clients/search-component/example/src/routeTree.gen.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
/* prettier-ignore-start */
2+
13
/* eslint-disable */
24

35
// @ts-nocheck
46

57
// noinspection JSUnusedGlobalSymbols
68

7-
// This file was automatically generated by TanStack Router.
8-
// You should NOT make any changes in this file as it will be overwritten.
9-
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
9+
// This file is auto-generated by TanStack Router
1010

1111
import { createFileRoute } from '@tanstack/react-router'
1212

@@ -22,13 +22,11 @@ const IndexLazyImport = createFileRoute('/')()
2222
// Create/Update Routes
2323

2424
const EcommerceRoute = EcommerceImport.update({
25-
id: '/ecommerce',
2625
path: '/ecommerce',
2726
getParentRoute: () => rootRoute,
2827
} as any)
2928

3029
const IndexLazyRoute = IndexLazyImport.update({
31-
id: '/',
3230
path: '/',
3331
getParentRoute: () => rootRoute,
3432
} as any).lazy(() => import('./routes/index.lazy').then((d) => d.Route))
@@ -95,6 +93,8 @@ export const routeTree = rootRoute
9593
._addFileChildren(rootRouteChildren)
9694
._addFileTypes<FileRouteTypes>()
9795

96+
/* prettier-ignore-end */
97+
9898
/* ROUTE_MANIFEST_START
9999
{
100100
"routes": {

clients/search-component/example/src/routes/ecommerce.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ export default function ECommerce() {
3333
);
3434
const defaultSearchMode =
3535
import.meta.env.VITE_DEFAULT_SEARCH_MODE ?? "search";
36-
3736
const defaultAIQuestions = (
3837
import.meta.env.VITE_DEFAULT_AI_QUESTIONS ?? ""
3938
).split(",");
39+
const inline =
40+
import.meta.env.VITE_INLINE == "true";
4041

4142
const [theme, setTheme] = useState<"light" | "dark">("light");
4243
const [component, setComponent] = useState(0);
@@ -108,6 +109,7 @@ export default function ECommerce() {
108109
floatingSearchIconPosition={floatingSearchIconPosition}
109110
showFloatingSearchIcon={showFloatingSearchIcon}
110111
showFloatingInput={showFloatingInput}
112+
inline={inline}
111113
/>
112114
</>
113115
) : (

clients/search-component/example/src/routes/index.lazy.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export default function Home() {
3434
const defaultAiQuestions = (
3535
import.meta.env.VITE_DEFAULT_AI_QUESTIONS ?? "What is Trieve?,How to perform autocomplete search?,How do I install the TS SDK?"
3636
).split(",");
37+
const inline =
38+
import.meta.env.VITE_INLINE == "true";
3739

3840
const [theme, setTheme] = useState<"light" | "dark">("light");
3941
const [component, setComponent] = useState(0);
@@ -159,6 +161,7 @@ export default function Home() {
159161
showFloatingButton={showFloatingButton}
160162
showFloatingSearchIcon={showFloatingSearchIcon}
161163
showFloatingInput={showFloatingInput}
164+
inline={inline}
162165
/>
163166
</>
164167
) : (

clients/search-component/src/TrieveModal/Chat/ChatMode.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export const ChatMode = () => {
3737

3838
return (
3939
<Suspense>
40-
<div className="chat-outer-wrapper" ref={modalRef}>
40+
<div className={`chat-outer-wrapper ${props.inline ? "": "chat-outer-popup"}`} ref={modalRef}>
41+
42+
{!props.inline &&
4143
<div
4244
className={`close-modal-button chat ${props.type}`}
4345
onClick={() => setOpen(false)}
@@ -59,7 +61,7 @@ export const ChatMode = () => {
5961
<line x1="6" y1="6" x2="18" y2="18" />
6062
</svg>
6163
<span>Close</span>
62-
</div>
64+
</div>}
6365
<div
6466
className={`system-information-wrapper${
6567
currentGroup ? " with-group" : ""

clients/search-component/src/TrieveModal/index.css

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ body {
2323
}
2424

2525
#trieve-search-modal {
26-
@apply animate-contentShow scroll-smooth fixed top-[calc(40%-30vh)] left-[50%] max-h-[60vh] w-[90vw] sm:max-w-[800px] -translate-x-[50%] rounded-lg shadow-2xl focus:outline-none z-[999] overflow-hidden text-base;
26+
@apply animate-contentShow scroll-smooth max-h-[60vh] w-[90vw] sm:max-w-[800px] rounded-lg focus:outline-none overflow-hidden text-base;
2727

2828
color: var(--tv-zinc-950);
2929
background-color: var(--tv-zinc-50);
3030
font-family: var(--tv-prop-brand-font-family);
3131

32+
&.trieve-popup-modal {
33+
@apply top-[calc(40%-30vh)] left-[50%] shadow-2xl fixed -translate-x-[50%];
34+
}
35+
3236
.group-chat-carousel {
3337
@apply pl-4 flex gap-2 w-full overflow-x-auto;
3438
}
@@ -67,7 +71,11 @@ body {
6771
}
6872

6973
.chat-outer-wrapper {
70-
@apply justify-between w-full h-full mt-10 sm:mt-12;
74+
@apply justify-between w-full h-full;
75+
76+
&.chat-outer-popup {
77+
@apply mt-10 sm:mt-12;
78+
}
7179
}
7280
}
7381

@@ -132,7 +140,7 @@ body {
132140
}
133141

134142
.mode-switch-wrapper {
135-
@apply flex items-center justify-end mt-2 absolute top-2.5 right-4 z-30 font-medium;
143+
@apply flex items-center justify-end mt-2 absolute font-medium;
136144

137145
&.docs.chat, &.pdf.chat {
138146
@apply top-0;
@@ -545,17 +553,26 @@ body {
545553

546554
@media (max-height: 800px) {
547555
.chat-outer-wrapper {
548-
@apply pb-6;
556+
&.chat-outer-popup {
557+
@apply pb-6;
558+
}
549559
}
560+
550561
}
551562
@media (max-height: 600px) {
552563
.chat-outer-wrapper {
553-
@apply pb-16;
564+
&.chat-outer-popup {
565+
@apply pb-16;
566+
}
554567
}
555568
}
556569

557570
.chat-outer-wrapper {
558-
@apply flex flex-col mt-12 px-4 scroll-smooth;
571+
@apply flex flex-col px-4 scroll-smooth mt-0;
572+
573+
&.chat-outer-popup {
574+
@apply mt-12;
575+
}
559576

560577
.ai-message {
561578
.message-wrapper {

clients/search-component/src/TrieveModal/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,31 +175,35 @@ const Modal = () => {
175175

176176
return (
177177
<>
178-
<OpenModalButton
178+
{!props.inline && <OpenModalButton
179179
setOpen={() => {
180180
startTransition(() => {
181181
setOpen(true);
182182
setMode(props.defaultSearchMode || "search");
183183
});
184184
}}
185-
/>
186-
{open && (
185+
/>}
186+
{(props.inline || open) && (
187187
<>
188+
{!props.inline &&
188189
<div
189190
onClick={() => {
190191
setOpen(false);
191192
}}
192193
id="trieve-search-modal-overlay"
193194
style={{ zIndex: props.zIndex ?? 1000 }}
194195
></div>
196+
}
195197
<div
196198
id="trieve-search-modal"
197199
className={`${mode === "chat" ? "chat-modal-mobile " : ""} ${
198200
props.theme === "dark" ? "dark " : ""
201+
} ${
202+
props.inline ? "trieve-inline-modal" : "trieve-popup-modal"
199203
} ${props.type}`.trim()}
200204
style={{ zIndex: props.zIndex ? props.zIndex + 1 : 1001 }}
201205
>
202-
{props.allowSwitchingModes && <ModeSwitch />}
206+
{props.allowSwitchingModes && !props.inline && <ModeSwitch />}
203207
<div
204208
className="search-container"
205209
style={{ display: mode === "search" ? "block" : "none" }}

clients/search-component/src/utils/hooks/modal-context.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export type ModalProps = {
9696
mode: SearchModes;
9797
removeListeners?: boolean;
9898
}[];
99+
inline: boolean;
99100
zIndex?: number;
100101
showFloatingButton?: boolean;
101102
floatingButtonPosition?:
@@ -146,6 +147,7 @@ const defaultProps = {
146147
floatingSearchIconPosition: "right" as "left" | "right",
147148
showFloatingSearchIcon: false,
148149
showFloatingInput: false,
150+
inline: false,
149151
};
150152

151153
const ModalContext = createContext<{

0 commit comments

Comments
 (0)