Skip to content

Commit

Permalink
Refactor form components and add search functionality to Select inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
n4ze3m committed Dec 24, 2023
1 parent 19aa2cc commit 6f297c4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
32 changes: 18 additions & 14 deletions app/ui/src/components/Bot/Settings/SettingsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,21 @@ export const SettingsCard: React.FC<BotSettings> = ({
},
]}
>
<Select options={chatModel} />
<Select
showSearch
filterOption={(input, option) =>
(option?.label
? option?.label?.toLowerCase()
: ""
).includes(input?.toLowerCase())
}
filterSort={(optionA, optionB) =>
(optionA?.label ?? "")
.toLowerCase()
.localeCompare((optionB?.label ?? "").toLowerCase())
}
options={chatModel}
/>
</Form.Item>

<Form.Item
Expand Down Expand Up @@ -211,10 +225,7 @@ export const SettingsCard: React.FC<BotSettings> = ({
/>
</Form.Item>

<Form.Item
label={"Embedding Method"}
name="embedding"
>
<Form.Item label={"Embedding Method"} name="embedding">
<Select
disabled
placeholder="Select an embedding method"
Expand All @@ -232,11 +243,7 @@ export const SettingsCard: React.FC<BotSettings> = ({
},
]}
>
<Input.TextArea
size="large"
rows={5}
placeholder=""
/>
<Input.TextArea size="large" rows={5} placeholder="" />
</Form.Item>
<div className="flex flex-row justify-start gap-4">
<button
Expand Down Expand Up @@ -273,10 +280,7 @@ export const SettingsCard: React.FC<BotSettings> = ({
},
]}
>
<Input.TextArea
size="large"
rows={5}
/>
<Input.TextArea size="large" rows={5} />
</Form.Item>

<Form.Item
Expand Down
29 changes: 26 additions & 3 deletions app/ui/src/components/Common/BotForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,12 @@ export const BotForm = ({
value={source}
className={({ checked, active }) =>
classNames(
checked ? "border-transparent" : "border-gray-300 dark:border-gray-700",
active ? "border-indigo-500 ring-0 ring-indigo-500 dark:border-gray-700 dark:ring-gray-900" : "",
checked
? "border-transparent"
: "border-gray-300 dark:border-gray-700",
active
? "border-indigo-500 ring-0 ring-indigo-500 dark:border-gray-700 dark:ring-gray-900"
: "",
"relative items-center justify-center flex cursor-pointer rounded-lg border bg-white p-4 shadow-sm focus:outline-none dark:bg-[#141414]"
)
}
Expand Down Expand Up @@ -543,6 +547,17 @@ export const BotForm = ({
name="model"
>
<Select
showSearch
filterOption={(input, option) =>
(option?.label ? option?.label?.toLowerCase() : "").includes(
input?.toLowerCase()
)
}
filterSort={(optionA, optionB) =>
(optionA?.label ?? "")
.toLowerCase()
.localeCompare((optionB?.label ?? "").toLowerCase())
}
placeholder="Select a chat model"
options={botConfig.chatModel}
/>
Expand All @@ -557,7 +572,15 @@ export const BotForm = ({
name="embedding"
>
<Select
placeholder="Select an embedding method"
showSearch
filterOption={(input, option) =>
(option?.label ?? "").includes(input)
}
filterSort={(optionA, optionB) =>
(optionA?.label ?? "")
.toLowerCase()
.localeCompare((optionB?.label ?? "").toLowerCase())
}
options={botConfig.embeddingModel}
/>
</Form.Item>
Expand Down
9 changes: 7 additions & 2 deletions app/ui/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

* {
font-family: "Inter", sans-serif !important;

}

@tailwind base;
Expand Down Expand Up @@ -46,7 +45,13 @@ pre:has(div.code) {
margin: 0;
}

markdown-processing {
markdown-processing {
white-space: pre-wrap;
word-wrap: break-word;
}

/* make focus 0 without any border */
.ant-select-selection-search-input {
border: none !important;
box-shadow: none !important;
}

0 comments on commit 6f297c4

Please sign in to comment.