Skip to content

Commit f3ec307

Browse files
committed
Refactor icons and update navigation components
Replaced inline SVGs in NavMenu and MobileNav with new reusable Svelte icon components (IconBurger, IconSun, IconMoon). Updated IconNew to use a new SVG and adjusted its viewBox. This improves code maintainability and consistency across navigation UI.
1 parent c4e6586 commit f3ec307

File tree

6 files changed

+198
-72
lines changed

6 files changed

+198
-72
lines changed

src/lib/components/MobileNav.svelte

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
import { base } from "$app/paths";
1313
import { page } from "$app/state";
1414
import IconNew from "$lib/components/icons/IconNew.svelte";
15+
import IconBurger from "$lib/components/icons/IconBurger.svelte";
1516
import { Spring } from "svelte/motion";
1617
import CarbonClose from "~icons/carbon/close";
17-
import CarbonTextAlignJustify from "~icons/carbon/text-align-justify";
1818
import { pan, type GestureCustomEvent, type PanCustomEvent } from "svelte-gestures";
1919
interface Props {
2020
title: string | undefined;
@@ -81,17 +81,16 @@
8181
class="-ml-3 flex size-12 shrink-0 items-center justify-center text-lg"
8282
onclick={() => (isOpen = true)}
8383
aria-label="Open menu"
84-
bind:this={openEl}><CarbonTextAlignJustify /></button
84+
bind:this={openEl}><IconBurger /></button
8585
>
8686
<div class="flex h-full items-center justify-center overflow-hidden">
8787
{#if page.params?.id}
8888
<span class="max-w-full truncate px-4" data-testid="chat-title">{title}</span>
8989
{/if}
9090
</div>
91-
<a
92-
href="{base}/"
93-
class="-mr-3 flex size-12 shrink-0 items-center justify-center text-lg"><IconNew /></a
94-
>
91+
<a href="{base}/" class="-mr-3 flex size-12 shrink-0 items-center justify-center text-lg">
92+
<IconNew />
93+
</a>
9594
</nav>
9695

9796
<!-- Mobile drawer overlay - shows when drawer is open -->
@@ -155,14 +154,5 @@
155154
class="fixed bottom-0 left-0 top-0 z-30 grid max-h-screen
156155
grid-cols-1 grid-rows-[auto,1fr,auto,auto] bg-white pt-4 dark:bg-gray-900 md:hidden"
157156
>
158-
{#if page.url.pathname === base + "/"}
159-
<button
160-
type="button"
161-
class="absolute right-0 top-0 z-50 flex size-12 items-center justify-center text-lg"
162-
onclick={() => (isOpen = false)}
163-
aria-label="Close menu"
164-
bind:this={closeEl}><CarbonClose /></button
165-
>
166-
{/if}
167157
{@render children?.()}
168158
</nav>

src/lib/components/NavMenu.svelte

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import { base } from "$app/paths";
1212
1313
import Logo from "$lib/components/icons/Logo.svelte";
14+
import IconSun from "$lib/components/icons/IconSun.svelte";
15+
import IconMoon from "$lib/components/icons/IconMoon.svelte";
1416
import { switchTheme } from "$lib/switchTheme";
1517
import { isAborted } from "$lib/stores/isAborted";
1618
@@ -73,7 +75,7 @@
7375
})
7476
.then(handleResponse)
7577
.then((r) => r.conversations)
76-
.catch(() => []);
78+
.catch((): ConvSidebar[] => []);
7779
7880
if (newConvs.length === 0) {
7981
hasMore = false;
@@ -193,59 +195,9 @@
193195
>
194196
{#if browser}
195197
{#if theme === "dark"}
196-
<svg
197-
xmlns="http://www.w3.org/2000/svg"
198-
xmlns:xlink="http://www.w3.org/1999/xlink"
199-
aria-hidden="true"
200-
focusable="false"
201-
role="img"
202-
width="1em"
203-
height="1em"
204-
preserveAspectRatio="xMidYMid meet"
205-
viewBox="0 0 32 32"
206-
stroke-width="1.5"
207-
><path
208-
d="M16 12.005a4 4 0 1 1-4 4a4.005 4.005 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6z"
209-
fill="currentColor"
210-
stroke="currentColor"
211-
stroke-width="0.5"
212-
></path><path d="M5.394 6.813l1.414-1.415l3.506 3.506L8.9 10.318z" fill="currentColor"
213-
></path><path d="M2 15.005h5v2H2z" fill="currentColor"></path><path
214-
stroke="currentColor"
215-
stroke-width="0.5"
216-
d="M5.394 25.197L8.9 21.691l1.414 1.415l-3.506 3.505z"
217-
fill="currentColor"
218-
></path><path d="M15 25.005h2v5h-2z" fill="currentColor"></path><path
219-
stroke="currentColor"
220-
stroke-width="0.5"
221-
d="M21.687 23.106l1.414-1.415l3.506 3.506l-1.414 1.414z"
222-
fill="currentColor"
223-
></path><path d="M25 15.005h5v2h-5z" fill="currentColor"></path><path
224-
stroke="currentColor"
225-
stroke-width="0.5"
226-
d="M21.687 8.904l3.506-3.506l1.414 1.415l-3.506 3.505z"
227-
fill="currentColor"
228-
></path><path d="M15 2.005h2v5h-2z" fill="currentColor"></path></svg
229-
>
198+
<IconSun />
230199
{:else}
231-
<svg
232-
xmlns="http://www.w3.org/2000/svg"
233-
xmlns:xlink="http://www.w3.org/1999/xlink"
234-
aria-hidden="true"
235-
focusable="false"
236-
role="img"
237-
width="1em"
238-
height="1em"
239-
preserveAspectRatio="xMidYMid meet"
240-
viewBox="0 0 32 32"
241-
stroke-width="1.5"
242-
><path
243-
d="M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z"
244-
fill="currentColor"
245-
stroke="currentColor"
246-
stroke-width="0.5"
247-
></path></svg
248-
>
200+
<IconMoon />
249201
{/if}
250202
{/if}
251203
</button>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script lang="ts">
2+
interface Props {
3+
classNames?: string;
4+
}
5+
6+
let { classNames = "" }: Props = $props();
7+
</script>
8+
9+
<svg
10+
xmlns="http://www.w3.org/2000/svg"
11+
class={classNames}
12+
width="1em"
13+
height="1em"
14+
fill="none"
15+
viewBox="0 0 16 16"
16+
><path
17+
d="M8.795 10.418a.84.84 0 1 1 0 1.681H1.907a.84.84 0 0 1 0-1.681h6.888ZM14.093 3.9a.841.841 0 0 1 0 1.682H1.907a.84.84 0 0 1 0-1.682h12.186Z"
18+
fill="#000"
19+
/>
20+
</svg>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<script lang="ts">
2+
interface Props {
3+
classNames?: string;
4+
}
5+
6+
let { classNames = "" }: Props = $props();
7+
</script>
8+
9+
<svg
10+
width="49"
11+
height="49"
12+
viewBox="0 0 49 49"
13+
fill="none"
14+
xmlns="http://www.w3.org/2000/svg"
15+
class={classNames}
16+
>
17+
<mask
18+
id="mask0_3607_32"
19+
style="mask-type:alpha"
20+
maskUnits="userSpaceOnUse"
21+
x="6"
22+
y="6"
23+
width="37"
24+
height="37"
25+
>
26+
<path
27+
d="M24.5 42.5C19.4667 42.5 15.2087 40.758 11.726 37.274C8.24333 33.79 6.50133 29.532 6.5 24.5C6.5 19.9 8 15.908 11 12.524C14 9.13996 17.8333 7.16529 22.5 6.59996C22.9333 6.53329 23.3167 6.59196 23.65 6.77596C23.9833 6.95996 24.25 7.20129 24.45 7.49996C24.65 7.79863 24.7587 8.14863 24.776 8.54996C24.7933 8.95129 24.668 9.33463 24.4 9.69996C23.8333 10.5666 23.408 11.4833 23.124 12.45C22.84 13.4166 22.6987 14.4333 22.7 15.5C22.7 18.5 23.75 21.05 25.85 23.15C27.95 25.25 30.5 26.3 33.5 26.3C34.5333 26.3 35.5587 26.15 36.576 25.85C37.5933 25.55 38.5013 25.1333 39.3 24.6C39.6667 24.3666 40.042 24.2586 40.426 24.276C40.81 24.2933 41.1513 24.3846 41.45 24.55C41.7833 24.7166 42.042 24.9666 42.226 25.3C42.41 25.6333 42.468 26.0333 42.4 26.5C41.9333 31.1 39.9753 34.9166 36.526 37.95C33.0767 40.9833 29.068 42.5 24.5 42.5Z"
28+
fill="black"
29+
/>
30+
</mask>
31+
<g mask="url(#mask0_3607_32)">
32+
<path
33+
d="M24.5 42.5C19.4667 42.5 15.2087 40.758 11.726 37.274C8.24333 33.79 6.50133 29.532 6.5 24.5C6.5 19.9 8 15.908 11 12.524C14 9.13996 17.8333 7.16529 22.5 6.59996C22.9333 6.53329 23.3167 6.59196 23.65 6.77596C23.9833 6.95996 24.25 7.20129 24.45 7.49996C24.65 7.79863 24.7587 8.14863 24.776 8.54996C24.7933 8.95129 24.668 9.33463 24.4 9.69996C23.8333 10.5666 23.408 11.4833 23.124 12.45C22.84 13.4166 22.6987 14.4333 22.7 15.5C22.7 18.5 23.75 21.05 25.85 23.15C27.95 25.25 30.5 26.3 33.5 26.3C34.5333 26.3 35.5587 26.15 36.576 25.85C37.5933 25.55 38.5013 25.1333 39.3 24.6C39.6667 24.3666 40.042 24.2586 40.426 24.276C40.81 24.2933 41.1513 24.3846 41.45 24.55C41.7833 24.7166 42.042 24.9666 42.226 25.3C42.41 25.6333 42.468 26.0333 42.4 26.5C41.9333 31.1 39.9753 34.9166 36.526 37.95C33.0767 40.9833 29.068 42.5 24.5 42.5Z"
34+
fill="black"
35+
/>
36+
<path
37+
d="M24.5 42.5C19.4667 42.5 15.2087 40.758 11.726 37.274C8.24333 33.79 6.50133 29.532 6.5 24.5C6.5 19.9 8 15.908 11 12.524C14 9.13996 17.8333 7.16529 22.5 6.59996C22.9333 6.53329 23.3167 6.59196 23.65 6.77596C23.9833 6.95996 24.25 7.20129 24.45 7.49996C24.65 7.79863 24.7587 8.14863 24.776 8.54996C24.7933 8.95129 24.668 9.33463 24.4 9.69996C23.8333 10.5666 23.408 11.4833 23.124 12.45C22.84 13.4166 22.6987 14.4333 22.7 15.5C22.7 18.5 23.75 21.05 25.85 23.15C27.95 25.25 30.5 26.3 33.5 26.3C34.5333 26.3 35.5587 26.15 36.576 25.85C37.5933 25.55 38.5013 25.1333 39.3 24.6C39.6667 24.3666 40.042 24.2586 40.426 24.276C40.81 24.2933 41.1513 24.3846 41.45 24.55C41.7833 24.7166 42.042 24.9666 42.226 25.3C42.41 25.6333 42.468 26.0333 42.4 26.5C41.9333 31.1 39.9753 34.9166 36.526 37.95C33.0767 40.9833 29.068 42.5 24.5 42.5Z"
38+
fill="url(#paint0_radial_3607_32)"
39+
/>
40+
<g filter="url(#filter0_f_3607_32)">
41+
<path
42+
d="M19.9248 7.07642C18.9863 7.73469 18.1188 8.51292 17.3223 9.41138C14.8404 12.2109 13.5986 15.5131 13.5986 19.3186C13.5997 23.4815 15.0417 27.0038 17.9229 29.886C20.804 32.7682 24.3263 34.2092 28.4902 34.2092C32.269 34.2092 35.585 32.9548 38.4385 30.4456C40.1338 28.9547 41.3934 27.2347 42.2178 25.2864C42.2203 25.2909 42.223 25.2954 42.2256 25.3C42.4096 25.6334 42.4684 26.0336 42.4004 26.5002C41.9337 31.0999 39.9754 34.9163 36.5264 37.9495C33.077 40.9828 29.068 42.5002 24.5 42.5002C19.4667 42.5002 15.2083 40.7577 11.7256 37.2737C8.24321 33.7898 6.50141 29.5319 6.5 24.5002C6.5 19.9002 8 15.9077 11 12.5237C13.4287 9.78414 16.4038 7.96861 19.9248 7.07642Z"
43+
fill="#89969F"
44+
/>
45+
</g>
46+
</g>
47+
<defs>
48+
<filter
49+
id="filter0_f_3607_32"
50+
x="-0.130445"
51+
y="0.445971"
52+
width="49.1886"
53+
height="48.6847"
54+
filterUnits="userSpaceOnUse"
55+
color-interpolation-filters="sRGB"
56+
>
57+
<feFlood flood-opacity="0" result="BackgroundImageFix" />
58+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
59+
<feGaussianBlur stdDeviation="3.31522" result="effect1_foregroundBlur_3607_32" />
60+
</filter>
61+
<radialGradient
62+
id="paint0_radial_3607_32"
63+
cx="0"
64+
cy="0"
65+
r="1"
66+
gradientTransform="matrix(-10.7245 16.294 -16.2944 -10.7241 28.8768 19.7027)"
67+
gradientUnits="userSpaceOnUse"
68+
>
69+
<stop offset="0.228187" stop-color="white" />
70+
<stop offset="1" stop-color="#F8FAFC" />
71+
</radialGradient>
72+
</defs>
73+
</svg>

src/lib/components/icons/IconNew.svelte

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
width="1em"
1313
height="1em"
1414
fill="none"
15-
viewBox="0 0 32 32"
15+
viewBox="0 0 16 16"
1616
><path
17+
d="M7.258 1.856c.333 0 .66.024.979.07-.558.319-.972.86-1.123 1.503A5.254 5.254 0 1 0 9.32 13.513l.275-.127c.334-.17.712-.229 1.08-.17l.158.031.01.003 1.343.36-.359-1.345a1.77 1.77 0 0 1 .137-1.247 5.23 5.23 0 0 0 .538-2.041 2.356 2.356 0 0 0 1.544-1 6.808 6.808 0 0 1-.676 3.742v.001c-.034.066-.031.116-.025.14l.36 1.345a1.572 1.572 0 0 1-1.823 1.945l-.1-.024-1.334-.357a.2.2 0 0 0-.14.018l-.012.005A6.825 6.825 0 1 1 7.259 1.856Zm4.837-1.36c.434 0 .785.352.785.786v1.905h1.9a.785.785 0 0 1 0 1.57h-1.9v1.9a.786.786 0 1 1-1.57 0v-1.9H9.404a.785.785 0 0 1 0-1.57h1.906V1.282c0-.434.352-.787.785-.787Z"
1718
fill="currentColor"
18-
fill-rule="evenodd"
19-
d="M3.143 20.286h4.286v2.142H3.143A2.143 2.143 0 0 1 1 20.287V3.143A2.143 2.143 0 0 1 3.143 1h17.143a2.143 2.143 0 0 1 2.142 2.143v4.286h-2.142V3.143H3.143v17.143Zm9.643-12.857v3.214H16v2.143h-3.214V16h-2.143v-3.214H7.429v-2.143h3.214V7.429h2.143Zm14.185 2.639 3.533 3.532a1.7 1.7 0 0 1 0 2.4L15.5 31H9.57v-5.928l15-15.004a1.7 1.7 0 0 1 2.4 0Zm-15.257 18.79h2.897l10.116-10.116-2.899-2.897L11.714 25.96v2.897ZM23.346 14.33l2.897 2.897 2.429-2.43-2.897-2.896-2.43 2.429Z"
20-
clip-rule="evenodd"
2119
/></svg
2220
>

0 commit comments

Comments
 (0)