refac: styling

This commit is contained in:
Timothy J. Baek 2024-05-14 22:09:32 -10:00
parent aaaef3efd8
commit 13019acce6
9 changed files with 990 additions and 1018 deletions

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { toast } from 'svelte-sonner'; import { toast } from 'svelte-sonner';
import { onMount, tick, getContext } from 'svelte'; import { onMount, tick, getContext } from 'svelte';
import { modelfiles, settings, showSidebar } from '$lib/stores'; import { mobile, modelfiles, settings, showSidebar } from '$lib/stores';
import { blobToFile, calculateSHA256, findWordIndices } from '$lib/utils'; import { blobToFile, calculateSHA256, findWordIndices } from '$lib/utils';
import { import {
@ -765,7 +765,7 @@
bind:value={prompt} bind:value={prompt}
on:keypress={(e) => { on:keypress={(e) => {
if ( if (
window.innerWidth > 1024 || !$mobile ||
!( !(
'ontouchstart' in window || 'ontouchstart' in window ||
navigator.maxTouchPoints > 0 || navigator.maxTouchPoints > 0 ||

View File

@ -252,6 +252,10 @@
const newChatButton = document.getElementById('new-chat-button'); const newChatButton = document.getElementById('new-chat-button');
setTimeout(() => { setTimeout(() => {
newChatButton?.click(); newChatButton?.click();
if ($mobile) {
showSidebar.set(false);
}
}, 0); }, 0);
}} }}
> >
@ -380,7 +384,7 @@
</div> </div>
{#if $tags.length > 0} {#if $tags.length > 0}
<div class="px-2.5 mb-2 flex gap-0.5 flex-wrap"> <div class="px-2.5 mb-2 flex gap-1 flex-wrap">
<button <button
class="px-2.5 text-xs font-medium bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800 transition rounded-full" class="px-2.5 text-xs font-medium bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800 transition rounded-full"
on:click={async () => { on:click={async () => {
@ -462,7 +466,7 @@
href="/c/{chat.id}" href="/c/{chat.id}"
on:click={() => { on:click={() => {
selectedChatId = chat.id; selectedChatId = chat.id;
if (window.innerWidth < 1024) { if ($mobile) {
showSidebar.set(false); showSidebar.set(false);
} }
}} }}

View File

@ -82,7 +82,7 @@
<div class=" text-lg font-semibold mb-3">{$i18n.t('Modelfiles')}</div> <div class=" text-lg font-semibold mb-3">{$i18n.t('Modelfiles')}</div>
<a class=" flex space-x-4 cursor-pointer w-full mb-2 px-3 py-2" href="/modelfiles/create"> <a class=" flex space-x-4 cursor-pointer w-full mb-2 px-3 py-2" href="/workspace/modelfiles/create">
<div class=" self-center w-10"> <div class=" self-center w-10">
<div <div
class="w-full h-10 flex justify-center rounded-full bg-transparent dark:bg-gray-700 border border-dashed border-gray-200" class="w-full h-10 flex justify-center rounded-full bg-transparent dark:bg-gray-700 border border-dashed border-gray-200"
@ -135,7 +135,7 @@
<a <a
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl" class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
type="button" type="button"
href={`/modelfiles/edit?tag=${encodeURIComponent(modelfile.tagName)}`} href={`/workspace/modelfiles/edit?tag=${encodeURIComponent(modelfile.tagName)}`}
> >
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@ -159,7 +159,7 @@
on:click={() => { on:click={() => {
// console.log(modelfile); // console.log(modelfile);
sessionStorage.modelfile = JSON.stringify(modelfile); sessionStorage.modelfile = JSON.stringify(modelfile);
goto('/modelfiles/create'); goto('/workspace/modelfiles/create');
}} }}
> >
<svg <svg

View File

@ -74,7 +74,7 @@
<div> <div>
<a <a
class=" px-2 py-2 rounded-xl border border-gray-200 dark:border-gray-600 dark:border-0 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 transition font-medium text-sm flex items-center space-x-1" class=" px-2 py-2 rounded-xl border border-gray-200 dark:border-gray-600 dark:border-0 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 transition font-medium text-sm flex items-center space-x-1"
href="/prompts/create" href="/workspace/prompts/create"
> >
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@ -97,7 +97,7 @@
class=" flex space-x-4 cursor-pointer w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-xl" class=" flex space-x-4 cursor-pointer w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-xl"
> >
<div class=" flex flex-1 space-x-4 cursor-pointer w-full"> <div class=" flex flex-1 space-x-4 cursor-pointer w-full">
<a href={`/prompts/edit?command=${encodeURIComponent(prompt.command)}`}> <a href={`/workspace/prompts/edit?command=${encodeURIComponent(prompt.command)}`}>
<div class=" flex-1 self-center pl-5"> <div class=" flex-1 self-center pl-5">
<div class=" font-bold">{prompt.command}</div> <div class=" font-bold">{prompt.command}</div>
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1"> <div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
@ -110,7 +110,7 @@
<a <a
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl" class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
type="button" type="button"
href={`/prompts/edit?command=${encodeURIComponent(prompt.command)}`} href={`/workspace/prompts/edit?command=${encodeURIComponent(prompt.command)}`}
> >
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@ -134,7 +134,7 @@
on:click={() => { on:click={() => {
// console.log(modelfile); // console.log(modelfile);
sessionStorage.prompt = JSON.stringify(prompt); sessionStorage.prompt = JSON.stringify(prompt);
goto('/prompts/create'); goto('/workspace/prompts/create');
}} }}
> >
<svg <svg

View File

@ -14,7 +14,7 @@
</title> </title>
</svelte:head> </svelte:head>
<div class=" flex flex-col w-full min-h-screen"> <div class=" flex flex-col w-full min-h-screen max-h-screen">
<div class=" px-4 pt-3 mt-0.5 mb-1"> <div class=" px-4 pt-3 mt-0.5 mb-1">
<div class=" flex items-center gap-1"> <div class=" flex items-center gap-1">
<div class="{$showSidebar ? 'md:hidden' : ''} mr-1 self-start flex flex-none items-center"> <div class="{$showSidebar ? 'md:hidden' : ''} mr-1 self-start flex flex-none items-center">
@ -39,21 +39,21 @@
class="flex scrollbar-none overflow-x-auto w-fit text-center text-sm font-medium rounded-xl bg-transparent/10 p-1" class="flex scrollbar-none overflow-x-auto w-fit text-center text-sm font-medium rounded-xl bg-transparent/10 p-1"
> >
<a <a
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname === '/workspace/modelfiles' class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/modelfiles')
? 'bg-gray-50 dark:bg-gray-850' ? 'bg-gray-50 dark:bg-gray-850'
: ''} transition" : ''} transition"
href="/workspace/modelfiles">{$i18n.t('Modelfiles')}</a href="/workspace/modelfiles">{$i18n.t('Modelfiles')}</a
> >
<a <a
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname === '/workspace/prompts' class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/prompts')
? 'bg-gray-50 dark:bg-gray-850' ? 'bg-gray-50 dark:bg-gray-850'
: ''} transition" : ''} transition"
href="/workspace/prompts">{$i18n.t('Prompts')}</a href="/workspace/prompts">{$i18n.t('Prompts')}</a
> >
<a <a
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname === '/workspace/documents' class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/documents')
? 'bg-gray-50 dark:bg-gray-850' ? 'bg-gray-50 dark:bg-gray-850'
: ''} transition" : ''} transition"
href="/workspace/documents" href="/workspace/documents"
@ -62,7 +62,7 @@
</a> </a>
<a <a
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname === '/workspace/playground' class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/playground')
? 'bg-gray-50 dark:bg-gray-850' ? 'bg-gray-50 dark:bg-gray-850'
: ''} transition" : ''} transition"
href="/workspace/playground">{$i18n.t('Playground')}</a href="/workspace/playground">{$i18n.t('Playground')}</a
@ -72,7 +72,7 @@
<hr class=" my-2 dark:border-gray-850" /> <hr class=" my-2 dark:border-gray-850" />
<div class=" py-1 px-5 h-full"> <div class=" py-1 px-5 flex-1 max-h-full overflow-y-auto">
<slot /> <slot />
</div> </div>
</div> </div>

View File

@ -204,7 +204,7 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
categories: Object.keys(categories).filter((category) => categories[category]), categories: Object.keys(categories).filter((category) => categories[category]),
user: modelfileCreator !== null ? modelfileCreator : undefined user: modelfileCreator !== null ? modelfileCreator : undefined
}); });
await goto('/modelfiles'); await goto('/workspace/modelfiles');
} }
} }
loading = false; loading = false;
@ -283,9 +283,7 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
}); });
</script> </script>
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white"> <div class="w-full max-h-full">
<div class=" flex flex-col justify-between w-full overflow-y-auto">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
<input <input
bind:this={filesInputElement} bind:this={filesInputElement}
bind:files={inputFiles} bind:files={inputFiles}
@ -351,8 +349,6 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
}} }}
/> />
<div class=" text-2xl font-semibold mb-6">{$i18n.t('My Modelfiles')}</div>
<button <button
class="flex space-x-1" class="flex space-x-1"
on:click={() => { on:click={() => {
@ -375,10 +371,10 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
</div> </div>
<div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div> <div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div>
</button> </button>
<hr class="my-3 dark:border-gray-700" /> <!-- <hr class="my-3 dark:border-gray-700" /> -->
<form <form
class="flex flex-col" class="flex flex-col max-w-2xl mx-auto mt-4 mb-10"
on:submit|preventDefault={() => { on:submit|preventDefault={() => {
submitHandler(); submitHandler();
}} }}
@ -722,6 +718,4 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
</button> </button>
</div> </div>
</form> </form>
</div>
</div>
</div> </div>

View File

@ -80,7 +80,7 @@
categories[category.toLowerCase()] = true; categories[category.toLowerCase()] = true;
} }
} else { } else {
goto('/modelfiles'); goto('/workspace/modelfiles');
} }
}); });
@ -174,7 +174,7 @@
suggestionPrompts: suggestions.filter((prompt) => prompt.content !== ''), suggestionPrompts: suggestions.filter((prompt) => prompt.content !== ''),
categories: Object.keys(categories).filter((category) => categories[category]) categories: Object.keys(categories).filter((category) => categories[category])
}); });
await goto('/modelfiles'); await goto('/workspace/modelfiles');
} }
} }
loading = false; loading = false;
@ -182,9 +182,7 @@
}; };
</script> </script>
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white"> <div class="w-full max-h-full">
<div class="flex flex-col justify-between w-full overflow-y-auto">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
<input <input
bind:this={filesInputElement} bind:this={filesInputElement}
bind:files={inputFiles} bind:files={inputFiles}
@ -250,8 +248,6 @@
}} }}
/> />
<div class=" text-2xl font-semibold mb-6">{$i18n.t('My Modelfiles')}</div>
<button <button
class="flex space-x-1" class="flex space-x-1"
on:click={() => { on:click={() => {
@ -274,10 +270,8 @@
</div> </div>
<div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div> <div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div>
</button> </button>
<hr class="my-3 dark:border-gray-700" />
<form <form
class="flex flex-col" class="flex flex-col max-w-2xl mx-auto mt-4 mb-10"
on:submit|preventDefault={() => { on:submit|preventDefault={() => {
updateHandler(); updateHandler();
}} }}
@ -510,6 +504,4 @@
</button> </button>
</div> </div>
</form> </form>
</div>
</div>
</div> </div>

View File

@ -35,7 +35,7 @@
if (prompt) { if (prompt) {
await prompts.set(await getPrompts(localStorage.token)); await prompts.set(await getPrompts(localStorage.token));
await goto('/prompts'); await goto('/workspace/prompts');
} }
} else { } else {
toast.error( toast.error(
@ -93,11 +93,7 @@
}); });
</script> </script>
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white"> <div class="w-full max-h-full">
<div class=" flex flex-col justify-between w-full overflow-y-auto">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
<div class=" text-2xl font-semibold mb-6">{$i18n.t('My Prompts')}</div>
<button <button
class="flex space-x-1" class="flex space-x-1"
on:click={() => { on:click={() => {
@ -120,10 +116,9 @@
</div> </div>
<div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div> <div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div>
</button> </button>
<hr class="my-3 dark:border-gray-700" />
<form <form
class="flex flex-col" class="flex flex-col max-w-2xl mx-auto mt-4 mb-10"
on:submit|preventDefault={() => { on:submit|preventDefault={() => {
submitHandler(); submitHandler();
}} }}
@ -181,9 +176,7 @@
<div> <div>
<textarea <textarea
class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg" class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
placeholder={$i18n.t( placeholder={$i18n.t('Write a summary in 50 words that summarizes [topic or keyword].')}
'Write a summary in 50 words that summarizes [topic or keyword].'
)}
rows="6" rows="6"
bind:value={content} bind:value={content}
required required
@ -249,6 +242,4 @@
</button> </button>
</div> </div>
</form> </form>
</div>
</div>
</div> </div>

View File

@ -33,7 +33,7 @@
if (prompt) { if (prompt) {
await prompts.set(await getPrompts(localStorage.token)); await prompts.set(await getPrompts(localStorage.token));
await goto('/prompts'); await goto('/workspace/prompts');
} }
} else { } else {
toast.error( toast.error(
@ -67,19 +67,15 @@
command = prompt.command.slice(1); command = prompt.command.slice(1);
content = prompt.content; content = prompt.content;
} else { } else {
goto('/prompts'); goto('/workspace/prompts');
} }
} else { } else {
goto('/prompts'); goto('/workspace/prompts');
} }
}); });
</script> </script>
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white"> <div class="w-full max-h-full">
<div class="flex flex-col justify-between w-full overflow-y-auto">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
<div class=" text-2xl font-semibold mb-6">{$i18n.t('My Prompts')}</div>
<button <button
class="flex space-x-1" class="flex space-x-1"
on:click={() => { on:click={() => {
@ -102,10 +98,9 @@
</div> </div>
<div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div> <div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div>
</button> </button>
<hr class="my-3 dark:border-gray-700" />
<form <form
class="flex flex-col" class="flex flex-col max-w-2xl mx-auto mt-4 mb-10"
on:submit|preventDefault={() => { on:submit|preventDefault={() => {
updateHandler(); updateHandler();
}} }}
@ -164,9 +159,7 @@
<div> <div>
<textarea <textarea
class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg" class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
placeholder={$i18n.t( placeholder={$i18n.t(`Write a summary in 50 words that summarizes [topic or keyword].`)}
`Write a summary in 50 words that summarizes [topic or keyword].`
)}
rows="6" rows="6"
bind:value={content} bind:value={content}
required required
@ -232,6 +225,4 @@
</button> </button>
</div> </div>
</form> </form>
</div>
</div>
</div> </div>