refac: styling

This commit is contained in:
Timothy Jaeryang Baek 2025-11-20 19:57:11 -05:00
parent 557170c0b6
commit cd30152c83
4 changed files with 275 additions and 262 deletions

View file

@ -25,6 +25,7 @@
import ChevronDown from '$lib/components/icons/ChevronDown.svelte'; import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants'; import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
import { config } from '$lib/stores'; import { config } from '$lib/stores';
import Spinner from '$lib/components/common/Spinner.svelte';
let page = 1; let page = 1;
let items = null; let items = null;
@ -143,256 +144,266 @@
<FeedbackModal bind:show={showFeedbackModal} {selectedFeedback} onClose={closeFeedbackModal} /> <FeedbackModal bind:show={showFeedbackModal} {selectedFeedback} onClose={closeFeedbackModal} />
<div class="mt-0.5 mb-1 gap-1 flex flex-row justify-between"> {#if items === null || total === null}
<div class="flex md:self-center text-lg font-medium px-0.5"> <div class="my-10">
{$i18n.t('Feedback History')} <Spinner className="size-5" />
</div>
{:else}
<div class="mt-0.5 mb-1 gap-1 flex flex-row justify-between">
<div class="flex items-center md:self-center text-xl font-medium px-0.5 gap-2 shrink-0">
<div>
{$i18n.t('Feedback History')}
</div>
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" /> <div class="text-lg font-medium text-gray-500 dark:text-gray-500">
{total}
</div>
</div>
<span class="text-lg font-medium text-gray-500 dark:text-gray-300">{total}</span> {#if total > 0}
<div>
<Tooltip content={$i18n.t('Export')}>
<button
class=" p-2 rounded-xl hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-850 transition font-medium text-sm flex items-center space-x-1"
on:click={() => {
exportHandler();
}}
>
<Download className="size-3" />
</button>
</Tooltip>
</div>
{/if}
</div> </div>
{#if total > 0} <div class="scrollbar-hidden relative whitespace-nowrap overflow-x-auto max-w-full">
<div> {#if (items ?? []).length === 0}
<Tooltip content={$i18n.t('Export')}> <div class="text-center text-xs text-gray-500 dark:text-gray-400 py-1">
<button {$i18n.t('No feedbacks found')}
class=" p-2 rounded-xl hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-850 transition font-medium text-sm flex items-center space-x-1" </div>
on:click={() => { {:else}
exportHandler(); <table
}} class="w-full text-sm text-left text-gray-500 dark:text-gray-400 table-auto max-w-full"
> >
<Download className="size-3" /> <thead class="text-xs text-gray-800 uppercase bg-transparent dark:text-gray-200">
</button> <tr class=" border-b-[1.5px] border-gray-50 dark:border-gray-850">
</Tooltip> <th
</div> scope="col"
{/if} class="px-2.5 py-2 cursor-pointer select-none w-3"
</div> on:click={() => setSortKey('user')}
>
<div class="scrollbar-hidden relative whitespace-nowrap overflow-x-auto max-w-full"> <div class="flex gap-1.5 items-center justify-end">
{#if (items ?? []).length === 0} {$i18n.t('User')}
<div class="text-center text-xs text-gray-500 dark:text-gray-400 py-1"> {#if orderBy === 'user'}
{$i18n.t('No feedbacks found')} <span class="font-normal">
</div> {#if direction === 'asc'}
{:else} <ChevronUp className="size-2" />
<table class="w-full text-sm text-left text-gray-500 dark:text-gray-400 table-auto max-w-full"> {:else}
<thead class="text-xs text-gray-800 uppercase bg-transparent dark:text-gray-200"> <ChevronDown className="size-2" />
<tr class=" border-b-[1.5px] border-gray-50 dark:border-gray-850"> {/if}
<th </span>
scope="col" {:else}
class="px-2.5 py-2 cursor-pointer select-none w-3" <span class="invisible">
on:click={() => setSortKey('user')}
>
<div class="flex gap-1.5 items-center justify-end">
{$i18n.t('User')}
{#if orderBy === 'user'}
<span class="font-normal">
{#if direction === 'asc'}
<ChevronUp className="size-2" /> <ChevronUp className="size-2" />
{:else} </span>
<ChevronDown className="size-2" /> {/if}
{/if}
</span>
{:else}
<span class="invisible">
<ChevronUp className="size-2" />
</span>
{/if}
</div>
</th>
<th
scope="col"
class="px-2.5 py-2 cursor-pointer select-none"
on:click={() => setSortKey('model_id')}
>
<div class="flex gap-1.5 items-center">
{$i18n.t('Models')}
{#if orderBy === 'model_id'}
<span class="font-normal">
{#if direction === 'asc'}
<ChevronUp className="size-2" />
{:else}
<ChevronDown className="size-2" />
{/if}
</span>
{:else}
<span class="invisible">
<ChevronUp className="size-2" />
</span>
{/if}
</div>
</th>
<th
scope="col"
class="px-2.5 py-2 text-right cursor-pointer select-none w-fit"
on:click={() => setSortKey('rating')}
>
<div class="flex gap-1.5 items-center justify-end">
{$i18n.t('Result')}
{#if orderBy === 'rating'}
<span class="font-normal">
{#if direction === 'asc'}
<ChevronUp className="size-2" />
{:else}
<ChevronDown className="size-2" />
{/if}
</span>
{:else}
<span class="invisible">
<ChevronUp className="size-2" />
</span>
{/if}
</div>
</th>
<th
scope="col"
class="px-2.5 py-2 text-right cursor-pointer select-none w-0"
on:click={() => setSortKey('updated_at')}
>
<div class="flex gap-1.5 items-center justify-end">
{$i18n.t('Updated At')}
{#if orderBy === 'updated_at'}
<span class="font-normal">
{#if direction === 'asc'}
<ChevronUp className="size-2" />
{:else}
<ChevronDown className="size-2" />
{/if}
</span>
{:else}
<span class="invisible">
<ChevronUp className="size-2" />
</span>
{/if}
</div>
</th>
<th scope="col" class="px-2.5 py-2 text-right cursor-pointer select-none w-0"> </th>
</tr>
</thead>
<tbody class="">
{#each items as feedback (feedback.id)}
<tr
class="bg-white dark:bg-gray-900 dark:border-gray-850 text-xs cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-850/50 transition"
on:click={() => openFeedbackModal(feedback)}
>
<td class=" py-0.5 text-right font-semibold">
<div class="flex justify-center">
<Tooltip content={feedback?.user?.name}>
<div class="shrink-0">
<img
src={`${WEBUI_API_BASE_URL}/users/${feedback.user.id}/profile/image`}
alt={feedback?.user?.name}
class="size-5 rounded-full object-cover shrink-0"
/>
</div>
</Tooltip>
</div> </div>
</td> </th>
<td class=" py-1 pl-3 flex flex-col"> <th
<div class="flex flex-col items-start gap-0.5 h-full"> scope="col"
<div class="flex flex-col h-full"> class="px-2.5 py-2 cursor-pointer select-none"
{#if feedback.data?.sibling_model_ids} on:click={() => setSortKey('model_id')}
<div class="font-semibold text-gray-600 dark:text-gray-400 flex-1"> >
{feedback.data?.model_id} <div class="flex gap-1.5 items-center">
</div> {$i18n.t('Models')}
{#if orderBy === 'model_id'}
<Tooltip content={feedback.data.sibling_model_ids.join(', ')}> <span class="font-normal">
<div class=" text-[0.65rem] text-gray-600 dark:text-gray-400 line-clamp-1"> {#if direction === 'asc'}
{#if feedback.data.sibling_model_ids.length > 2} <ChevronUp className="size-2" />
<!-- {$i18n.t('and {{COUNT}} more')} --> {:else}
{feedback.data.sibling_model_ids.slice(0, 2).join(', ')}, {$i18n.t( <ChevronDown className="size-2" />
'and {{COUNT}} more', {/if}
{ COUNT: feedback.data.sibling_model_ids.length - 2 } </span>
)} {:else}
{:else} <span class="invisible">
{feedback.data.sibling_model_ids.join(', ')} <ChevronUp className="size-2" />
{/if} </span>
</div> {/if}
</Tooltip>
{:else}
<div
class=" text-sm font-medium text-gray-600 dark:text-gray-400 flex-1 py-1.5"
>
{feedback.data?.model_id}
</div>
{/if}
</div>
</div> </div>
</td> </th>
{#if feedback?.data?.rating} <th
<td class="px-3 py-1 text-right font-medium text-gray-900 dark:text-white w-max"> scope="col"
<div class=" flex justify-end"> class="px-2.5 py-2 text-right cursor-pointer select-none w-fit"
{#if feedback?.data?.rating.toString() === '1'} on:click={() => setSortKey('rating')}
<Badge type="info" content={$i18n.t('Won')} /> >
{:else if feedback?.data?.rating.toString() === '0'} <div class="flex gap-1.5 items-center justify-end">
<Badge type="muted" content={$i18n.t('Draw')} /> {$i18n.t('Result')}
{:else if feedback?.data?.rating.toString() === '-1'} {#if orderBy === 'rating'}
<Badge type="error" content={$i18n.t('Lost')} /> <span class="font-normal">
{/if} {#if direction === 'asc'}
<ChevronUp className="size-2" />
{:else}
<ChevronDown className="size-2" />
{/if}
</span>
{:else}
<span class="invisible">
<ChevronUp className="size-2" />
</span>
{/if}
</div>
</th>
<th
scope="col"
class="px-2.5 py-2 text-right cursor-pointer select-none w-0"
on:click={() => setSortKey('updated_at')}
>
<div class="flex gap-1.5 items-center justify-end">
{$i18n.t('Updated At')}
{#if orderBy === 'updated_at'}
<span class="font-normal">
{#if direction === 'asc'}
<ChevronUp className="size-2" />
{:else}
<ChevronDown className="size-2" />
{/if}
</span>
{:else}
<span class="invisible">
<ChevronUp className="size-2" />
</span>
{/if}
</div>
</th>
<th scope="col" class="px-2.5 py-2 text-right cursor-pointer select-none w-0"> </th>
</tr>
</thead>
<tbody class="">
{#each items as feedback (feedback.id)}
<tr
class="bg-white dark:bg-gray-900 dark:border-gray-850 text-xs cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-850/50 transition"
on:click={() => openFeedbackModal(feedback)}
>
<td class=" py-0.5 text-right font-semibold">
<div class="flex justify-center">
<Tooltip content={feedback?.user?.name}>
<div class="shrink-0">
<img
src={`${WEBUI_API_BASE_URL}/users/${feedback.user.id}/profile/image`}
alt={feedback?.user?.name}
class="size-5 rounded-full object-cover shrink-0"
/>
</div>
</Tooltip>
</div> </div>
</td> </td>
{/if}
<td class=" px-3 py-1 text-right font-medium"> <td class=" py-1 pl-3 flex flex-col">
{dayjs(feedback.updated_at * 1000).fromNow()} <div class="flex flex-col items-start gap-0.5 h-full">
</td> <div class="flex flex-col h-full">
{#if feedback.data?.sibling_model_ids}
<div class="font-semibold text-gray-600 dark:text-gray-400 flex-1">
{feedback.data?.model_id}
</div>
<td class=" px-3 py-1 text-right font-semibold" on:click={(e) => e.stopPropagation()}> <Tooltip content={feedback.data.sibling_model_ids.join(', ')}>
<FeedbackMenu <div class=" text-[0.65rem] text-gray-600 dark:text-gray-400 line-clamp-1">
on:delete={(e) => { {#if feedback.data.sibling_model_ids.length > 2}
deleteFeedbackHandler(feedback.id); <!-- {$i18n.t('and {{COUNT}} more')} -->
}} {feedback.data.sibling_model_ids.slice(0, 2).join(', ')}, {$i18n.t(
> 'and {{COUNT}} more',
<button { COUNT: feedback.data.sibling_model_ids.length - 2 }
class="self-center w-fit text-sm p-1.5 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl" )}
{:else}
{feedback.data.sibling_model_ids.join(', ')}
{/if}
</div>
</Tooltip>
{:else}
<div
class=" text-sm font-medium text-gray-600 dark:text-gray-400 flex-1 py-1.5"
>
{feedback.data?.model_id}
</div>
{/if}
</div>
</div>
</td>
{#if feedback?.data?.rating}
<td class="px-3 py-1 text-right font-medium text-gray-900 dark:text-white w-max">
<div class=" flex justify-end">
{#if feedback?.data?.rating.toString() === '1'}
<Badge type="info" content={$i18n.t('Won')} />
{:else if feedback?.data?.rating.toString() === '0'}
<Badge type="muted" content={$i18n.t('Draw')} />
{:else if feedback?.data?.rating.toString() === '-1'}
<Badge type="error" content={$i18n.t('Lost')} />
{/if}
</div>
</td>
{/if}
<td class=" px-3 py-1 text-right font-medium">
{dayjs(feedback.updated_at * 1000).fromNow()}
</td>
<td class=" px-3 py-1 text-right font-semibold" on:click={(e) => e.stopPropagation()}>
<FeedbackMenu
on:delete={(e) => {
deleteFeedbackHandler(feedback.id);
}}
> >
<EllipsisHorizontal /> <button
</button> class="self-center w-fit text-sm p-1.5 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
</FeedbackMenu> >
</td> <EllipsisHorizontal />
</tr> </button>
{/each} </FeedbackMenu>
</tbody> </td>
</table> </tr>
{/if} {/each}
</div> </tbody>
</table>
{#if total > 0 && $config?.features?.enable_community_sharing} {/if}
<div class=" flex flex-col justify-end w-full text-right gap-1">
<div class="line-clamp-1 text-gray-500 text-xs">
{$i18n.t('Help us create the best community leaderboard by sharing your feedback history!')}
</div>
<div class="flex space-x-1 ml-auto">
<Tooltip
content={$i18n.t(
'To protect your privacy, only ratings, model IDs, tags, and metadata are shared from your feedback—your chat logs remain private and are not included.'
)}
>
<button
class="flex text-xs items-center px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
on:click={async () => {
shareHandler();
}}
>
<div class=" self-center mr-2 font-medium line-clamp-1">
{$i18n.t('Share to Open WebUI Community')}
</div>
<div class=" self-center">
<CloudArrowUp className="size-3" strokeWidth="3" />
</div>
</button>
</Tooltip>
</div>
</div> </div>
{/if}
{#if total > 30} {#if total > 0 && $config?.features?.enable_community_sharing}
<Pagination bind:page count={total} perPage={30} /> <div class=" flex flex-col justify-end w-full text-right gap-1">
<div class="line-clamp-1 text-gray-500 text-xs">
{$i18n.t('Help us create the best community leaderboard by sharing your feedback history!')}
</div>
<div class="flex space-x-1 ml-auto">
<Tooltip
content={$i18n.t(
'To protect your privacy, only ratings, model IDs, tags, and metadata are shared from your feedback—your chat logs remain private and are not included.'
)}
>
<button
class="flex text-xs items-center px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
on:click={async () => {
shareHandler();
}}
>
<div class=" self-center mr-2 font-medium line-clamp-1">
{$i18n.t('Share to Open WebUI Community')}
</div>
<div class=" self-center">
<CloudArrowUp className="size-3" strokeWidth="3" />
</div>
</button>
</Tooltip>
</div>
</div>
{/if}
{#if total > 30}
<Pagination bind:page count={total} perPage={30} />
{/if}
{/if} {/if}

View file

@ -339,16 +339,14 @@
<div <div
class="pt-0.5 pb-1 gap-1 flex flex-col md:flex-row justify-between sticky top-0 z-10 bg-white dark:bg-gray-900" class="pt-0.5 pb-1 gap-1 flex flex-col md:flex-row justify-between sticky top-0 z-10 bg-white dark:bg-gray-900"
> >
<div class="flex md:self-center text-lg font-medium px-0.5 shrink-0 items-center"> <div class="flex items-center md:self-center text-xl font-medium px-0.5 gap-2 shrink-0">
<div class=" gap-1"> <div>
{$i18n.t('Leaderboard')} {$i18n.t('Leaderboard')}
</div> </div>
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" /> <div class="text-lg font-medium text-gray-500 dark:text-gray-500">
{rankedModels.length}
<span class="text-lg font-medium text-gray-500 dark:text-gray-300 mr-1.5" </div>
>{rankedModels.length}</span
>
</div> </div>
<div class=" flex space-x-2"> <div class=" flex space-x-2">

View file

@ -105,11 +105,14 @@
/> />
<div class="mt-0.5 mb-2 gap-1 flex flex-col md:flex-row justify-between"> <div class="mt-0.5 mb-2 gap-1 flex flex-col md:flex-row justify-between">
<div class="flex md:self-center text-lg font-medium px-0.5"> <div class="flex items-center md:self-center text-xl font-medium px-0.5 gap-2 shrink-0">
{$i18n.t('Groups')} <div>
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" /> {$i18n.t('Groups')}
</div>
<span class="text-lg font-medium text-gray-500 dark:text-gray-300">{groups.length}</span> <div class="text-lg font-medium text-gray-500 dark:text-gray-500">
{groups.length}
</div>
</div> </div>
<div class="flex gap-1"> <div class="flex gap-1">

View file

@ -154,27 +154,28 @@
<div <div
class="pt-0.5 pb-1 gap-1 flex flex-col md:flex-row justify-between sticky top-0 z-10 bg-white dark:bg-gray-900" class="pt-0.5 pb-1 gap-1 flex flex-col md:flex-row justify-between sticky top-0 z-10 bg-white dark:bg-gray-900"
> >
<div class="flex md:self-center text-lg font-medium px-0.5"> <div class="flex md:self-center text-lg font-medium px-0.5 gap-2">
<div class="flex-shrink-0"> <div class="flex-shrink-0">
{$i18n.t('Users')} {$i18n.t('Users')}
</div> </div>
<div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-50 dark:bg-gray-850" />
{#if ($config?.license_metadata?.seats ?? null) !== null} <div>
{#if total > $config?.license_metadata?.seats} {#if ($config?.license_metadata?.seats ?? null) !== null}
<span class="text-lg font-medium text-red-500" {#if total > $config?.license_metadata?.seats}
>{total} of {$config?.license_metadata?.seats} <span class="text-lg font-medium text-red-500"
<span class="text-sm font-normal">{$i18n.t('available users')}</span></span >{total} of {$config?.license_metadata?.seats}
> <span class="text-sm font-normal">{$i18n.t('available users')}</span></span
>
{:else}
<span class="text-lg font-medium text-gray-500 dark:text-gray-300"
>{total} of {$config?.license_metadata?.seats}
<span class="text-sm font-normal">{$i18n.t('available users')}</span></span
>
{/if}
{:else} {:else}
<span class="text-lg font-medium text-gray-500 dark:text-gray-300" <span class="text-lg font-medium text-gray-500 dark:text-gray-300">{total}</span>
>{total} of {$config?.license_metadata?.seats}
<span class="text-sm font-normal">{$i18n.t('available users')}</span></span
>
{/if} {/if}
{:else} </div>
<span class="text-lg font-medium text-gray-500 dark:text-gray-300">{total}</span>
{/if}
</div> </div>
<div class="flex gap-1"> <div class="flex gap-1">