add a login button when users are logged out (#381)
Browse files
src/lib/components/NavMenu.svelte
CHANGED
@@ -18,7 +18,11 @@
|
|
18 |
id: string;
|
19 |
title: string;
|
20 |
}> = [];
|
|
|
|
|
21 |
export let user: LayoutData["user"];
|
|
|
|
|
22 |
</script>
|
23 |
|
24 |
<div class="sticky top-0 flex flex-none items-center justify-between px-3 py-3.5 max-sm:pt-0">
|
@@ -61,6 +65,15 @@
|
|
61 |
</button>
|
62 |
</form>
|
63 |
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
<button
|
65 |
on:click={switchTheme}
|
66 |
type="button"
|
|
|
18 |
id: string;
|
19 |
title: string;
|
20 |
}> = [];
|
21 |
+
|
22 |
+
export let canLogin: boolean;
|
23 |
export let user: LayoutData["user"];
|
24 |
+
|
25 |
+
export let loginModalVisible;
|
26 |
</script>
|
27 |
|
28 |
<div class="sticky top-0 flex flex-none items-center justify-between px-3 py-3.5 max-sm:pt-0">
|
|
|
65 |
</button>
|
66 |
</form>
|
67 |
{/if}
|
68 |
+
{#if canLogin}
|
69 |
+
<button
|
70 |
+
on:click={() => (loginModalVisible = true)}
|
71 |
+
type="button"
|
72 |
+
class="flex h-9 flex-none items-center gap-1.5 rounded-lg pl-3 pr-2 text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700"
|
73 |
+
>
|
74 |
+
Login
|
75 |
+
</button>
|
76 |
+
{/if}
|
77 |
<button
|
78 |
on:click={switchTheme}
|
79 |
type="button"
|
src/routes/+layout.svelte
CHANGED
@@ -99,6 +99,8 @@
|
|
99 |
(data.requiresLogin
|
100 |
? !data.user
|
101 |
: !data.settings.ethicsModalAcceptedAt && !!PUBLIC_APP_DISCLAIMER);
|
|
|
|
|
102 |
</script>
|
103 |
|
104 |
<svelte:head>
|
@@ -156,6 +158,8 @@
|
|
156 |
<NavMenu
|
157 |
conversations={data.conversations}
|
158 |
user={data.user}
|
|
|
|
|
159 |
on:shareConversation={(ev) => shareConversation(ev.detail.id, ev.detail.title)}
|
160 |
on:deleteConversation={(ev) => deleteConversation(ev.detail)}
|
161 |
on:clickSettings={() => (isSettingsOpen = true)}
|
@@ -166,6 +170,8 @@
|
|
166 |
<NavMenu
|
167 |
conversations={data.conversations}
|
168 |
user={data.user}
|
|
|
|
|
169 |
on:shareConversation={(ev) => shareConversation(ev.detail.id, ev.detail.title)}
|
170 |
on:deleteConversation={(ev) => deleteConversation(ev.detail)}
|
171 |
on:clickSettings={() => (isSettingsOpen = true)}
|
@@ -182,7 +188,7 @@
|
|
182 |
models={data.models}
|
183 |
/>
|
184 |
{/if}
|
185 |
-
{#if requiresLogin && data.messagesBeforeLogin === 0}
|
186 |
<LoginModal settings={data.settings} />
|
187 |
{/if}
|
188 |
<slot />
|
|
|
99 |
(data.requiresLogin
|
100 |
? !data.user
|
101 |
: !data.settings.ethicsModalAcceptedAt && !!PUBLIC_APP_DISCLAIMER);
|
102 |
+
|
103 |
+
let loginModalVisible = false;
|
104 |
</script>
|
105 |
|
106 |
<svelte:head>
|
|
|
158 |
<NavMenu
|
159 |
conversations={data.conversations}
|
160 |
user={data.user}
|
161 |
+
canLogin={data.user === undefined && data.requiresLogin}
|
162 |
+
bind:loginModalVisible
|
163 |
on:shareConversation={(ev) => shareConversation(ev.detail.id, ev.detail.title)}
|
164 |
on:deleteConversation={(ev) => deleteConversation(ev.detail)}
|
165 |
on:clickSettings={() => (isSettingsOpen = true)}
|
|
|
170 |
<NavMenu
|
171 |
conversations={data.conversations}
|
172 |
user={data.user}
|
173 |
+
canLogin={data.user === undefined && data.requiresLogin}
|
174 |
+
bind:loginModalVisible
|
175 |
on:shareConversation={(ev) => shareConversation(ev.detail.id, ev.detail.title)}
|
176 |
on:deleteConversation={(ev) => deleteConversation(ev.detail)}
|
177 |
on:clickSettings={() => (isSettingsOpen = true)}
|
|
|
188 |
models={data.models}
|
189 |
/>
|
190 |
{/if}
|
191 |
+
{#if (requiresLogin && data.messagesBeforeLogin === 0) || loginModalVisible}
|
192 |
<LoginModal settings={data.settings} />
|
193 |
{/if}
|
194 |
<slot />
|