mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 11:07:55 -05:00
refac
This commit is contained in:
1 parent
f329d2bcfb
commit
d69c8ee947
72 files changed
+327
-45
No files matched your search
@@ -5,6 +5,7 @@
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
import DropdownMenu from '$lib/components/common/DropdownMenu.svelte';
|
||||
import CalendarIcon from '$lib/components/icons/Calendar.svelte';
|
||||
import DatePicker from '$lib/components/common/DatePicker.svelte';
|
||||
|
||||
const i18n = getContext<typeof import('$lib/i18n').default>('i18n');
|
||||
|
||||
@@ -17,6 +18,13 @@
|
||||
export let onChange: (date: string | null) => void;
|
||||
|
||||
const day = (offset: number) => dayjs().add(offset, 'day').format('YYYY-MM-DD');
|
||||
// Quick picks, each with the date it lands on; the week ends on Sunday, as the grid's does.
|
||||
$: quick = [
|
||||
[$i18n.t('Today'), day(0)],
|
||||
[$i18n.t('Tomorrow'), day(1)],
|
||||
[$i18n.t('End of this week'), day((7 - dayjs().day()) % 7)],
|
||||
[$i18n.t('In one week'), day(7)]
|
||||
];
|
||||
const pick = (value: string | null) => {
|
||||
show = false;
|
||||
if (value !== date) onChange(value);
|
||||
@@ -43,20 +51,18 @@
|
||||
{#if labeled || !date}<CalendarIcon className="size-3.5" strokeWidth="1.75" />{/if}
|
||||
{#if labeled || date}<span class="truncate">{label}</span>{/if}
|
||||
</button>
|
||||
<DropdownMenu slot="content" className="w-48">
|
||||
<button type="button" on:click={() => pick(day(0))}>{$i18n.t('Today')}</button>
|
||||
<button type="button" on:click={() => pick(day(1))}>{$i18n.t('Tomorrow')}</button>
|
||||
<button type="button" on:click={() => pick(day(7))}>{$i18n.t('Next week')}</button>
|
||||
<DropdownMenu slot="content" className="w-60">
|
||||
{#each quick as [label, value]}
|
||||
<button type="button" on:click={() => pick(value)}>
|
||||
<CalendarIcon className="size-3.5 shrink-0 text-base-400" strokeWidth="1.75" />
|
||||
<span class="flex-1 text-left">{label}</span>
|
||||
<span class="text-xs text-base-400 tabular-nums dark:text-base-500"
|
||||
>{dayjs(value).locale($i18n.language).format('ddd, MMM D')}</span
|
||||
>
|
||||
</button>
|
||||
{/each}
|
||||
<hr class="border-base-50/30 dark:border-base-800/30" />
|
||||
<div class="px-2 py-1">
|
||||
<input
|
||||
type="date"
|
||||
class="w-full bg-transparent text-xs outline-none"
|
||||
aria-label={$i18n.t('Due date')}
|
||||
value={date ?? ''}
|
||||
on:change={(event) => pick(event.currentTarget.value || null)}
|
||||
/>
|
||||
</div>
|
||||
<DatePicker value={date} onSelect={pick} />
|
||||
{#if date}
|
||||
<hr class="border-base-50/30 dark:border-base-800/30" />
|
||||
<button type="button" on:click={() => pick(null)}>{$i18n.t('Clear')}</button>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<h3 class="sticky top-0 z-[1] mt-1.5 first:mt-0">
|
||||
<button
|
||||
type="button"
|
||||
class="group/header flex h-8 w-full items-center gap-2 rounded-xl pr-3 pl-2 text-left backdrop-blur-md"
|
||||
class="group-header group/header flex h-8 w-full items-center gap-2 rounded-xl pr-3 pl-2 text-left backdrop-blur-md"
|
||||
aria-expanded={!collapsed[group.id]}
|
||||
aria-label={collapsed[group.id]
|
||||
? $i18n.t('Expand {{name}}', { name: group.label })
|
||||
@@ -247,3 +247,13 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* A translucent tint, so the frosted header picks up the page background, as in chat lists. */
|
||||
.group-header {
|
||||
background: color-mix(in oklab, var(--color-base-50) 80%, transparent);
|
||||
}
|
||||
:global(.dark) .group-header {
|
||||
background: color-mix(in oklab, var(--color-base-850) 60%, transparent);
|
||||
}
|
||||
</style>
|
||||
@@ -178,17 +178,21 @@
|
||||
{/if}
|
||||
<TaskDueDate date={dueDate} labeled onChange={(next) => (dueDate = next)} />
|
||||
{#if target}
|
||||
<!-- No id yet: the picker keeps the chosen tags here until the task is created. -->
|
||||
<FolderTags
|
||||
resourceType="tasks"
|
||||
chat={{ id: '', title: title || $i18n.t('New task'), tags }}
|
||||
folderId={target.id}
|
||||
editable
|
||||
max={4}
|
||||
onChange={(next) => {
|
||||
tags = next;
|
||||
}}
|
||||
/>
|
||||
<!-- No id yet: the picker keeps the chosen tags here until the task is created.
|
||||
Not a row, so its "+ Tag" chip shows without hovering. -->
|
||||
<div class="flex" data-tags-shown>
|
||||
<FolderTags
|
||||
resourceType="tasks"
|
||||
chat={{ id: '', title: title || $i18n.t('New task'), tags }}
|
||||
folderId={target.id}
|
||||
editable
|
||||
labeled
|
||||
max={4}
|
||||
onChange={(next) => {
|
||||
tags = next;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user