Adrien Denat commited on
Commit
0714764
1 Parent(s): 1ee9053

Styling improvements (#82)

Browse files

* add custom scrollbar everywhere

* fix scroll to bottom button positioning + add hover

* fix non-scrollable transparent area above input text

* replace slate color by gray

* add custom scrollbars for codeblock

* fix chat messages overflowing on small viewports

* fix codeblock scrollbar color on light mode + remove !important

* fix send icon hover + make disabled buttons default cursor

src/lib/components/CodeBlock.svelte CHANGED
@@ -16,8 +16,9 @@
16
  </script>
17
 
18
  <div class="group relative rounded-lg my-4">
19
- <pre class="overflow-auto px-5"><code class="language-{lang}"
20
- >{@html highlightedCode || code.replaceAll("<", "&lt;")}</code
 
21
  ></pre>
22
  <CopyToClipBoardBtn
23
  classNames="absolute top-2 right-2 invisible opacity-0 group-hover:visible group-hover:opacity-100"
 
16
  </script>
17
 
18
  <div class="group relative rounded-lg my-4">
19
+ <pre
20
+ class="overflow-auto scrollbar-custom scrollbar-thumb-gray-500 hover:scrollbar-thumb-gray-400 dark:scrollbar-thumb-white/10 dark:hover:scrollbar-thumb-white/20 px-5"><code
21
+ class="language-{lang}">{@html highlightedCode || code.replaceAll("<", "&lt;")}</code
22
  ></pre>
23
  <CopyToClipBoardBtn
24
  classNames="absolute top-2 right-2 invisible opacity-0 group-hover:visible group-hover:opacity-100"
src/lib/components/NavMenu.svelte CHANGED
@@ -32,7 +32,7 @@
32
  </a>
33
  </div>
34
  <div
35
- class="flex flex-col overflow-y-auto px-3 pb-3 pt-2 gap-1 bg-gradient-to-l from-gray-50 dark:from-gray-800/30 rounded-r-xl"
36
  >
37
  {#each conversations as conv}
38
  <a
 
32
  </a>
33
  </div>
34
  <div
35
+ class="flex flex-col overflow-y-auto scrollbar-custom px-3 pb-3 pt-2 gap-1 bg-gradient-to-l from-gray-50 dark:from-gray-800/30 rounded-r-xl"
36
  >
37
  {#each conversations as conv}
38
  <a
src/lib/components/ScrollToBottomBtn.svelte CHANGED
@@ -28,7 +28,7 @@
28
  <button
29
  transition:fade={{ duration: 150 }}
30
  on:click={() => scrollNode.scrollTo({ top: scrollNode.scrollHeight, behavior: "smooth" })}
31
- class="absolute flex rounded-full border w-10 h-10 items-center justify-center shadow bg-white dark:bg-gray-700 dark:border-gray-600 {className}"
32
- ><IconChevron /></button
33
  >
34
  {/if}
 
28
  <button
29
  transition:fade={{ duration: 150 }}
30
  on:click={() => scrollNode.scrollTo({ top: scrollNode.scrollHeight, behavior: "smooth" })}
31
+ class="btn absolute flex rounded-full border w-[41px] h-[41px] shadow-md dark:shadow-gray-950 bg-white dark:bg-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:border-gray-600 transition-all {className}"
32
+ ><IconChevron classNames="mt-[2px]" /></button
33
  >
34
  {/if}
src/lib/components/chat/ChatMessages.svelte CHANGED
@@ -24,7 +24,11 @@
24
  }
25
  </script>
26
 
27
- <div class="overflow-y-auto h-full" use:snapScrollToBottom={messages} bind:this={chatContainer}>
 
 
 
 
28
  <div class="max-w-3xl xl:max-w-4xl mx-auto px-5 pt-6 flex flex-col gap-5 sm:gap-8 h-full">
29
  {#each messages as message, i}
30
  <ChatMessage loading={loading && i === messages.length - 1} {message} />
@@ -36,5 +40,8 @@
36
  {/if}
37
  <div class="h-32 flex-none" />
38
  </div>
39
- <ScrollToBottomBtn class="bottom-10 right-12" scrollNode={chatContainer} />
 
 
 
40
  </div>
 
24
  }
25
  </script>
26
 
27
+ <div
28
+ class="overflow-y-auto h-full scrollbar-custom mr-1"
29
+ use:snapScrollToBottom={messages}
30
+ bind:this={chatContainer}
31
+ >
32
  <div class="max-w-3xl xl:max-w-4xl mx-auto px-5 pt-6 flex flex-col gap-5 sm:gap-8 h-full">
33
  {#each messages as message, i}
34
  <ChatMessage loading={loading && i === messages.length - 1} {message} />
 
40
  {/if}
41
  <div class="h-32 flex-none" />
42
  </div>
43
+ <ScrollToBottomBtn
44
+ class="max-md:hidden bottom-36 right-4 lg:right-10"
45
+ scrollNode={chatContainer}
46
+ />
47
  </div>
src/lib/components/chat/ChatWindow.svelte CHANGED
@@ -19,10 +19,10 @@
19
  const dispatch = createEventDispatcher<{ message: string; share: void }>();
20
  </script>
21
 
22
- <div class="relative min-h-0">
23
  <ChatMessages {loading} {pending} {messages} on:message />
24
  <div
25
- class="flex flex-col max-md:border-t dark:border-gray-800 items-center max-md:dark:bg-gray-900 max-md:bg-white bg-gradient-to-t from-white via-white/80 to-white/0 dark:from-gray-900 dark:via-gray-80 dark:to-gray-900/0 justify-center absolute inset-x-0 max-w-3xl xl:max-w-4xl mx-auto px-3.5 sm:px-5 bottom-0 py-4 md:py-8 w-full"
26
  >
27
  <form
28
  on:submit|preventDefault={() => {
@@ -35,13 +35,11 @@
35
  <div class="w-full flex flex-1 border-none bg-transparent">
36
  <ChatInput placeholder="Ask anything" bind:value={message} autofocus maxRows={10} />
37
  <button
38
- class="p-1 px-[0.7rem] group self-end my-1 h-[2.4rem] rounded-lg hover:bg-gray-100 enabled:dark:hover:text-gray-400 dark:hover:bg-gray-900 disabled:hover:bg-transparent dark:disabled:hover:bg-transparent disabled:opacity-60 dark:disabled:opacity-40 flex-shrink-0 transition-all mx-1"
39
  disabled={!message || loading || disabled}
40
  type="submit"
41
  >
42
- <CarbonSendAltFilled
43
- class="text-gray-400 group-hover:text-gray-800 group-disabled:text-gray-300"
44
- />
45
  </button>
46
  </div>
47
  </form>
 
19
  const dispatch = createEventDispatcher<{ message: string; share: void }>();
20
  </script>
21
 
22
+ <div class="relative min-h-0 min-w-0">
23
  <ChatMessages {loading} {pending} {messages} on:message />
24
  <div
25
+ class="flex flex-col pointer-events-none [&>*]:pointer-events-auto max-md:border-t dark:border-gray-800 items-center max-md:dark:bg-gray-900 max-md:bg-white bg-gradient-to-t from-white via-white/80 to-white/0 dark:from-gray-900 dark:via-gray-80 dark:to-gray-900/0 justify-center absolute inset-x-0 max-w-3xl xl:max-w-4xl mx-auto px-3.5 sm:px-5 bottom-0 py-4 md:py-8 w-full"
26
  >
27
  <form
28
  on:submit|preventDefault={() => {
 
35
  <div class="w-full flex flex-1 border-none bg-transparent">
36
  <ChatInput placeholder="Ask anything" bind:value={message} autofocus maxRows={10} />
37
  <button
38
+ class="btn p-1 px-[0.7rem] self-end bg-transparent my-1 h-[2.4rem] text-gray-400 rounded-lg enabled:dark:hover:text-gray-100 enabled:hover:text-gray-700 disabled:opacity-60 dark:disabled:opacity-40 mx-1"
39
  disabled={!message || loading || disabled}
40
  type="submit"
41
  >
42
+ <CarbonSendAltFilled />
 
 
43
  </button>
44
  </div>
45
  </form>
src/styles/main.css CHANGED
@@ -6,12 +6,12 @@
6
 
7
  @layer components {
8
  .btn {
9
- @apply cursor-pointer select-none inline-flex justify-center items-center whitespace-nowrap border focus:outline-none focus:ring;
10
  }
11
  }
12
 
13
  @layer utilities {
14
  .scrollbar-custom {
15
- @apply !scrollbar-thin !scrollbar-w-1 !scrollbar-thumb-rounded-full !scrollbar-track-transparent !scrollbar-thumb-black/10 dark:!scrollbar-thumb-white/10;
16
  }
17
  }
 
6
 
7
  @layer components {
8
  .btn {
9
+ @apply cursor-pointer disabled:cursor-default select-none inline-flex flex-shrink-0 justify-center items-center whitespace-nowrap outline-none focus:ring transition-all;
10
  }
11
  }
12
 
13
  @layer utilities {
14
  .scrollbar-custom {
15
+ @apply scrollbar-thin scrollbar-w-1 scrollbar-thumb-rounded-full scrollbar-track-transparent scrollbar-thumb-black/10 dark:scrollbar-thumb-white/10 hover:scrollbar-thumb-black/20 dark:hover:scrollbar-thumb-white/20;
16
  }
17
  }