refac: styling

This commit is contained in:
Timothy J. Baek 2024-04-30 15:31:50 -07:00
parent 3043e43418
commit 6318282873
2 changed files with 80 additions and 78 deletions

View file

@ -277,85 +277,87 @@
// }; // };
</script> </script>
{#if messages.length == 0} <div class="h-full">
<Placeholder {#if messages.length == 0}
models={selectedModels} <Placeholder
modelfiles={selectedModelfiles} models={selectedModels}
{suggestionPrompts} modelfiles={selectedModelfiles}
submitPrompt={async (p) => { {suggestionPrompts}
const chatTextAreaElement = document.getElementById('chat-textarea'); submitPrompt={async (p) => {
if (chatTextAreaElement) { const chatTextAreaElement = document.getElementById('chat-textarea');
prompt = p; if (chatTextAreaElement) {
prompt = p;
await tick(); await tick();
chatTextAreaElement.style.height = ''; chatTextAreaElement.style.height = '';
chatTextAreaElement.style.height = Math.min(chatTextAreaElement.scrollHeight, 200) + 'px'; chatTextAreaElement.style.height = Math.min(chatTextAreaElement.scrollHeight, 200) + 'px';
chatTextAreaElement.focus(); chatTextAreaElement.focus();
} }
}} }}
/> />
{:else} {:else}
<div class="pt-2 pb-10"> <div class="pt-2 pb-10">
{#key chatId} {#key chatId}
{#each messages as message, messageIdx} {#each messages as message, messageIdx}
<div class=" w-full"> <div class=" w-full">
<div <div
class="flex flex-col justify-between px-5 mb-3 {$settings?.fullScreenMode ?? null class="flex flex-col justify-between px-5 mb-3 {$settings?.fullScreenMode ?? null
? 'max-w-full' ? 'max-w-full'
: 'max-w-3xl'} mx-auto rounded-lg group" : 'max-w-3xl'} mx-auto rounded-lg group"
> >
{#if message.role === 'user'} {#if message.role === 'user'}
<UserMessage <UserMessage
on:delete={() => messageDeleteHandler(message.id)} on:delete={() => messageDeleteHandler(message.id)}
user={$user} user={$user}
{readOnly} {readOnly}
{message} {message}
isFirstMessage={messageIdx === 0} isFirstMessage={messageIdx === 0}
siblings={message.parentId !== null siblings={message.parentId !== null
? history.messages[message.parentId]?.childrenIds ?? [] ? history.messages[message.parentId]?.childrenIds ?? []
: Object.values(history.messages) : Object.values(history.messages)
.filter((message) => message.parentId === null) .filter((message) => message.parentId === null)
.map((message) => message.id) ?? []} .map((message) => message.id) ?? []}
{confirmEditMessage} {confirmEditMessage}
{showPreviousMessage} {showPreviousMessage}
{showNextMessage} {showNextMessage}
copyToClipboard={copyToClipboardWithToast} copyToClipboard={copyToClipboardWithToast}
/> />
{:else} {:else}
<ResponseMessage <ResponseMessage
{message} {message}
modelfiles={selectedModelfiles} modelfiles={selectedModelfiles}
siblings={history.messages[message.parentId]?.childrenIds ?? []} siblings={history.messages[message.parentId]?.childrenIds ?? []}
isLastMessage={messageIdx + 1 === messages.length} isLastMessage={messageIdx + 1 === messages.length}
{readOnly} {readOnly}
{updateChatMessages} {updateChatMessages}
{confirmEditResponseMessage} {confirmEditResponseMessage}
{showPreviousMessage} {showPreviousMessage}
{showNextMessage} {showNextMessage}
{rateMessage} {rateMessage}
copyToClipboard={copyToClipboardWithToast} copyToClipboard={copyToClipboardWithToast}
{continueGeneration} {continueGeneration}
{regenerateResponse} {regenerateResponse}
on:save={async (e) => { on:save={async (e) => {
console.log('save', e); console.log('save', e);
const message = e.detail; const message = e.detail;
history.messages[message.id] = message; history.messages[message.id] = message;
await updateChatById(localStorage.token, chatId, { await updateChatById(localStorage.token, chatId, {
messages: messages, messages: messages,
history: history history: history
}); });
}} }}
/> />
{/if} {/if}
</div>
</div> </div>
</div> {/each}
{/each}
{#if bottomPadding} {#if bottomPadding}
<div class=" mb-10" /> <div class=" mb-10" />
{/if} {/if}
{/key} {/key}
</div> </div>
{/if} {/if}
</div>

View file

@ -24,7 +24,7 @@
</script> </script>
{#if models.length > 0} {#if models.length > 0}
<div class=" my-auto text-center pb-10 md:pb-32"> <div class=" text-center py-24 md:py-36">
<div class="m-auto max-w-3xl px-8"> <div class="m-auto max-w-3xl px-8">
<div class="flex justify-start mt-8"> <div class="flex justify-start mt-8">
<div class="flex -space-x-4 mb-0.5"> <div class="flex -space-x-4 mb-0.5">