Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/huggingface/chat-ui into fr…
Browse files Browse the repository at this point in the history
…ont/setting_page_theme

Fixes huggingface#746: Settings dark mode - merge
  • Loading branch information
KartikGS committed Feb 6, 2024
2 parents be637cd + 2128ce0 commit 41f24b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/lib/components/Pagination.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
$: pageIndex = parseInt($page.url.searchParams.get("p") ?? "0");
$: pageIndexes = getPageIndexes(pageIndex, numTotalPages);
function getHref(pageIdx: number) {
const newUrl = new URL($page.url);
function getHref(url: URL | string, pageIdx: number) {
const newUrl = new URL(url);
newUrl.searchParams.set("p", pageIdx.toString());
return newUrl.toString();
}
Expand Down Expand Up @@ -66,7 +66,7 @@
>
<li>
<PaginationArrow
href={getHref(pageIndex - 1)}
href={getHref($page.url, pageIndex - 1)}
direction="previous"
isDisabled={pageIndex - 1 < 0}
/>
Expand All @@ -81,15 +81,15 @@
: ''}
"
class:pointer-events-none={pageIdx === ELLIPSIS_IDX || pageIndex === pageIdx}
href={getHref(pageIdx)}
href={getHref($page.url, pageIdx)}
>
{pageIdx === ELLIPSIS_IDX ? "..." : pageIdx + 1}
</a>
</li>
{/each}
<li>
<PaginationArrow
href={getHref(pageIndex + 1)}
href={getHref($page.url, pageIndex + 1)}
direction="next"
isDisabled={pageIndex + 1 >= numTotalPages}
/>
Expand Down
1 change: 1 addition & 0 deletions src/routes/assistants/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const load = async ({ url }) => {

return {
assistants: JSON.parse(JSON.stringify(assistants)) as Array<Assistant>,
selectedModel: modelId ?? "",
numTotalItems,
numItemsPerPage: NUM_PER_PAGE,
};
Expand Down
9 changes: 3 additions & 6 deletions src/routes/assistants/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
export let data: PageData;
let selectedModel = $page.url.searchParams.get("modelId") ?? "";
const onModelChange = (e: Event) => {
const newUrl = new URL($page.url);
if ((e.target as HTMLSelectElement).value === "") {
newUrl.searchParams.delete("modelId");
} else {
newUrl.search = ""; // clear searchParams (such as "p" for pagination)
if ((e.target as HTMLSelectElement).value) {
newUrl.searchParams.set("modelId", (e.target as HTMLSelectElement).value);
}
goto(newUrl);
Expand Down Expand Up @@ -66,7 +63,7 @@
<div class="mt-6 flex justify-between gap-2 max-sm:flex-col sm:items-center">
<select
class="mt-1 h-[34px] rounded-lg border border-gray-300 bg-gray-50 px-2 text-sm text-gray-900 focus:border-blue-700 focus:ring-blue-700 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400"
bind:value={selectedModel}
bind:value={data.selectedModel}
on:change={onModelChange}
>
<option value="">All models</option>
Expand Down

0 comments on commit 41f24b2

Please sign in to comment.