Skip to content

Commit 84c7039

Browse files
committed
feature: prevent switching modes
1 parent c43d9c8 commit 84c7039

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export default function Home() {
111111
brandLogoImgSrcUrl="https://avatars.githubusercontent.com/u/76905799?s=200&v=4"
112112
brandName="SigNoz"
113113
brandColor="#E75536"
114+
allowSwitchingModes={false}
114115
/>
115116

116117
<div className="mt-8 text-sm rounded overflow-hidden max-w-[100vw]">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ body {
381381
}
382382

383383
img {
384-
@apply w-7 max-h-7 sm:w-3/4 sm:h-3/4 sm:mx-auto sm:mt-2;
384+
@apply w-7 sm:w-3/4 sm:h-3/4 sm:mx-auto sm:mt-2;
385385
}
386386

387387
svg {

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ const Modal = () => {
2121
useEffect(() => {
2222
document.documentElement.style.setProperty(
2323
"--tv-prop-brand-color",
24-
props.brandColor ?? "#CB53EB"
24+
props.brandColor ?? "#CB53EB",
2525
);
2626

2727
// depending on the theme, set the background color of ::-webkit-scrollbar-thumb for #trieve-search-modal
2828
if (props.theme === "dark") {
2929
document.documentElement.style.setProperty(
3030
"--tv-prop-scrollbar-thumb-color",
31-
"var(--tv-zinc-700)"
31+
"var(--tv-zinc-700)",
3232
);
3333
} else {
3434
document.documentElement.style.setProperty(
3535
"--tv-prop-scrollbar-thumb-color",
36-
"var(--tv-zinc-300)"
36+
"var(--tv-zinc-300)",
3737
);
3838
}
3939
}, [props.brandColor]);
@@ -44,8 +44,7 @@ const Modal = () => {
4444
onOpenChange={(value) => {
4545
setOpen(value);
4646
setMode(props.defaultSearchMode || "search");
47-
}}
48-
>
47+
}}>
4948
<OpenModalButton />
5049
<Dialog.Portal>
5150
<Dialog.DialogTitle className="sr-only">Search</Dialog.DialogTitle>
@@ -58,16 +57,14 @@ const Modal = () => {
5857
className={
5958
(mode === "chat" ? "chat-modal-mobile " : " ") +
6059
(props.theme === "dark" ? "dark " : "")
61-
}
62-
>
63-
<ModeSwitch />
60+
}>
61+
{props.allowSwitchingModes && <ModeSwitch />}
6462
<div style={{ display: mode === "search" ? "block" : "none" }}>
6563
<SearchMode />
6664
</div>
6765
<div
6866
className={mode === "chat" ? " chat-container" : " "}
69-
style={{ display: mode === "chat" ? "block" : "none" }}
70-
>
67+
style={{ display: mode === "chat" ? "block" : "none" }}>
7168
<ChatMode />
7269
</div>
7370
</Dialog.Content>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export type ModalProps = {
4646
}[];
4747
defaultSearchMode?: SearchModes;
4848
type?: ModalTypes;
49+
allowSwitchingModes?: boolean;
4950
defaultCurrency?: string;
5051
currencyPosition?: currencyPosition;
5152
};
@@ -63,6 +64,7 @@ const defaultProps = {
6364
trieve: (() => {}) as unknown as TrieveSDK,
6465
openKeyCombination: [{ ctrl: true }, { key: "k", label: "K" }],
6566
type: "docs" as ModalTypes,
67+
allowSwitchingModes: true,
6668
currencyPosition: "after" as currencyPosition,
6769
};
6870

0 commit comments

Comments
 (0)