Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
user is logged in front check
Browse files- prisma/dev.db +0 -0
- src/lib/components/UserIsLogged.svelte +24 -0
- src/lib/components/community/reactions/Add.svelte +9 -6
- src/lib/components/community/reactions/Reaction.svelte +11 -7
- src/lib/stores/use-login-modal.ts +4 -0
- src/routes/+layout.svelte +28 -0
- src/routes/+page.svelte +22 -17
- src/routes/gallery/+page.svelte +7 -2
- tailwind.config.js +5 -1
prisma/dev.db
CHANGED
Binary files a/prisma/dev.db and b/prisma/dev.db differ
|
|
src/lib/components/UserIsLogged.svelte
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
import { get } from "svelte/store";
|
3 |
+
import { loginModalStore } from "$lib/stores/use-login-modal";
|
4 |
+
import { userStore } from "$lib/stores/use-user";
|
5 |
+
|
6 |
+
let user = get(userStore);
|
7 |
+
|
8 |
+
const handleClick = (e: any) => {
|
9 |
+
if (!user) {
|
10 |
+
loginModalStore.update(() => true);
|
11 |
+
}
|
12 |
+
};
|
13 |
+
</script>
|
14 |
+
|
15 |
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
16 |
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
17 |
+
<div
|
18 |
+
class="w-full cursor-pointer"
|
19 |
+
on:click={handleClick}
|
20 |
+
>
|
21 |
+
<div class:pointer-events-none={!user}>
|
22 |
+
<slot />
|
23 |
+
</div>
|
24 |
+
</div>
|
src/lib/components/community/reactions/Add.svelte
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
import { browser } from '$app/environment';
|
3 |
import Icon from "@iconify/svelte";
|
4 |
import { REACTION_EMOJIS } from "$lib/utils";
|
|
|
5 |
|
6 |
export let count: number;
|
7 |
export let reactions: Array<{ emoji: string, count: number }> = [];
|
@@ -59,12 +60,14 @@
|
|
59 |
class:pointer-events-auto={isOpen}
|
60 |
>
|
61 |
{#each AVAILABLE_EMOJIS as emoji}
|
62 |
-
<
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
68 |
{/each}
|
69 |
</div>
|
70 |
</div>
|
|
|
2 |
import { browser } from '$app/environment';
|
3 |
import Icon from "@iconify/svelte";
|
4 |
import { REACTION_EMOJIS } from "$lib/utils";
|
5 |
+
import UserIsLogged from '$lib/components/UserIsLogged.svelte';
|
6 |
|
7 |
export let count: number;
|
8 |
export let reactions: Array<{ emoji: string, count: number }> = [];
|
|
|
60 |
class:pointer-events-auto={isOpen}
|
61 |
>
|
62 |
{#each AVAILABLE_EMOJIS as emoji}
|
63 |
+
<UserIsLogged>
|
64 |
+
<button
|
65 |
+
class="w-8 h-8 hover:bg-neutral-200 rounded-full text-center flex items-center justify-center"
|
66 |
+
on:click={() => handleReaction(emoji)}
|
67 |
+
>
|
68 |
+
{emoji}
|
69 |
+
</button>
|
70 |
+
</UserIsLogged>
|
71 |
{/each}
|
72 |
</div>
|
73 |
</div>
|
src/lib/components/community/reactions/Reaction.svelte
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
<script lang="ts">
|
|
|
|
|
2 |
export let emoji: string;
|
3 |
export let count: number;
|
4 |
export let gallery_id: string;
|
@@ -19,10 +21,12 @@
|
|
19 |
}
|
20 |
</script>
|
21 |
|
22 |
-
<
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
1 |
<script lang="ts">
|
2 |
+
import UserIsLogged from "$lib/components/UserIsLogged.svelte";
|
3 |
+
|
4 |
export let emoji: string;
|
5 |
export let count: number;
|
6 |
export let gallery_id: string;
|
|
|
21 |
}
|
22 |
</script>
|
23 |
|
24 |
+
<UserIsLogged>
|
25 |
+
<button
|
26 |
+
class="rounded-full bg-white text-sm text-neutral-800 font-bold flex items-center justify-start gap-1.5 px-2.5 py-1 border border-white hover:bg-neutral-200"
|
27 |
+
on:click={() => handleReaction(emoji)}
|
28 |
+
>
|
29 |
+
<span>{emoji}</span>
|
30 |
+
{count}
|
31 |
+
</button>
|
32 |
+
</UserIsLogged>
|
src/lib/stores/use-login-modal.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { writable } from "svelte/store";
|
2 |
+
|
3 |
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
4 |
+
export const loginModalStore = writable<boolean>(false);
|
src/routes/+layout.svelte
CHANGED
@@ -1,10 +1,20 @@
|
|
1 |
<script>
|
|
|
2 |
import Sidebar from "$lib/components/sidebar/Sidebar.svelte";
|
3 |
import "$lib/styles/tailwind.css"
|
4 |
import { userStore } from "$lib/stores/use-user";
|
|
|
|
|
|
|
5 |
|
6 |
export let data;
|
7 |
userStore.set(data?.user?.user);
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
</script>
|
9 |
|
10 |
<div class="flex items-start">
|
@@ -12,4 +22,22 @@
|
|
12 |
<main id="app" class="flex-1 h-screen overflow-y-auto">
|
13 |
<slot />
|
14 |
</main>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
</div>
|
|
|
1 |
<script>
|
2 |
+
import { get } from "svelte/store";
|
3 |
import Sidebar from "$lib/components/sidebar/Sidebar.svelte";
|
4 |
import "$lib/styles/tailwind.css"
|
5 |
import { userStore } from "$lib/stores/use-user";
|
6 |
+
import Dialog from "$lib/components/dialog/Dialog.svelte";
|
7 |
+
import { loginModalStore } from "$lib/stores/use-login-modal";
|
8 |
+
import Icon from "@iconify/svelte";
|
9 |
|
10 |
export let data;
|
11 |
userStore.set(data?.user?.user);
|
12 |
+
|
13 |
+
let open = get(loginModalStore);
|
14 |
+
|
15 |
+
loginModalStore.subscribe((v) => {
|
16 |
+
open = v;
|
17 |
+
});
|
18 |
</script>
|
19 |
|
20 |
<div class="flex items-start">
|
|
|
22 |
<main id="app" class="flex-1 h-screen overflow-y-auto">
|
23 |
<slot />
|
24 |
</main>
|
25 |
+
<Dialog {open} onClose={() => loginModalStore.set(false)}>
|
26 |
+
<div class="grid grid-cols-1 gap-7 text-center">
|
27 |
+
<Icon icon="fluent-emoji:sparkles" class="w-12 h-12 mx-auto" />
|
28 |
+
<header>
|
29 |
+
<p class="text-white font-semibold text-lg">
|
30 |
+
Login to LoRA Studio
|
31 |
+
</p>
|
32 |
+
<p class="text-neutral-300 text-base mt-1">
|
33 |
+
Login to get a full access and get the most out of LoRA Studio.
|
34 |
+
</p>
|
35 |
+
</header>
|
36 |
+
<main>
|
37 |
+
<a href="/api/auth/login">
|
38 |
+
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/sign-in-with-huggingface-lg.svg" alt="Sign in with Hugging Face" class="mx-auto" />
|
39 |
+
</a>
|
40 |
+
</main>
|
41 |
+
</div>
|
42 |
+
</Dialog>
|
43 |
</div>
|
src/routes/+page.svelte
CHANGED
@@ -9,6 +9,7 @@
|
|
9 |
import GoTop from "$lib/components/GoTop.svelte";
|
10 |
import Dialog from "$lib/components/dialog/Dialog.svelte";
|
11 |
import SubmitModel from "$lib/components/models/Submit.svelte";
|
|
|
12 |
|
13 |
export let data
|
14 |
|
@@ -60,31 +61,35 @@
|
|
60 |
<Radio options={MODELS_FILTER_OPTIONS} value="{form.filter}" onChange={handleChangeFilter} />
|
61 |
<div class="items-center justify-end gap-5 hidden lg:flex">
|
62 |
<Button href="https://huggingface.co/new/stable-diffusion-lora" target="_blank" icon="ic:round-plus" theme="dark" size="lg">Create</Button>
|
63 |
-
<
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
71 |
</div>
|
72 |
<div class="items-center justify-end gap-3 flex lg:hidden">
|
73 |
<Button href="https://huggingface.co/new/stable-diffusion-lora" target="_blank" icon="ic:round-plus" theme="dark" size="md">Create</Button>
|
74 |
-
<
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
82 |
</div>
|
83 |
</div>
|
84 |
<div class="mt-5 max-w-sm">
|
85 |
<Input value={form.search} placeholder="Search a model" onChange={handleChangeSearch} />
|
86 |
</div>
|
87 |
-
<div class="mx-auto grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3
|
88 |
{#each data.cards as card}
|
89 |
<Card card={card} />
|
90 |
{/each}
|
|
|
9 |
import GoTop from "$lib/components/GoTop.svelte";
|
10 |
import Dialog from "$lib/components/dialog/Dialog.svelte";
|
11 |
import SubmitModel from "$lib/components/models/Submit.svelte";
|
12 |
+
import UserIsLogged from "$lib/components/UserIsLogged.svelte";
|
13 |
|
14 |
export let data
|
15 |
|
|
|
61 |
<Radio options={MODELS_FILTER_OPTIONS} value="{form.filter}" onChange={handleChangeFilter} />
|
62 |
<div class="items-center justify-end gap-5 hidden lg:flex">
|
63 |
<Button href="https://huggingface.co/new/stable-diffusion-lora" target="_blank" icon="ic:round-plus" theme="dark" size="lg">Create</Button>
|
64 |
+
<UserIsLogged>
|
65 |
+
<Button
|
66 |
+
icon="octicon:upload-16"
|
67 |
+
theme="blue"
|
68 |
+
size="lg"
|
69 |
+
onClick={() => submitModelDialog = true}
|
70 |
+
>
|
71 |
+
Upload model
|
72 |
+
</Button>
|
73 |
+
</UserIsLogged>
|
74 |
</div>
|
75 |
<div class="items-center justify-end gap-3 flex lg:hidden">
|
76 |
<Button href="https://huggingface.co/new/stable-diffusion-lora" target="_blank" icon="ic:round-plus" theme="dark" size="md">Create</Button>
|
77 |
+
<UserIsLogged>
|
78 |
+
<Button
|
79 |
+
icon="octicon:upload-16"
|
80 |
+
theme="blue"
|
81 |
+
size="md"
|
82 |
+
onClick={() => submitModelDialog = true}
|
83 |
+
>
|
84 |
+
Upload model
|
85 |
+
</Button>
|
86 |
+
</UserIsLogged>
|
87 |
</div>
|
88 |
</div>
|
89 |
<div class="mt-5 max-w-sm">
|
90 |
<Input value={form.search} placeholder="Search a model" onChange={handleChangeSearch} />
|
91 |
</div>
|
92 |
+
<div class="mx-auto grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-3 xl:grid-cols-4 3xl:grid-cols-5 gap-5 mt-8 lg:mt-10">
|
93 |
{#each data.cards as card}
|
94 |
<Card card={card} />
|
95 |
{/each}
|
src/routes/gallery/+page.svelte
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
import Radio from "$lib/components/fields/Radio.svelte";
|
9 |
import { COMMUNITY_FILTER_OPTIONS } from "$lib/utils/index.js";
|
10 |
import GoTop from "$lib/components/GoTop.svelte";
|
|
|
11 |
|
12 |
export let data
|
13 |
|
@@ -54,11 +55,15 @@
|
|
54 |
<div class="flex items-center justify-between mt-5">
|
55 |
<Radio options={COMMUNITY_FILTER_OPTIONS} value="{form.filter}" onChange={handleChangeFilter} />
|
56 |
<div class="items-center justify-end gap-5 hidden lg:flex">
|
57 |
-
<
|
|
|
|
|
58 |
<Button icon="fluent:glance-horizontal-sparkles-16-filled" href="/generate" theme="pink" size="lg">Generate</Button>
|
59 |
</div>
|
60 |
<div class="items-center justify-end gap-3 flex lg:hidden">
|
61 |
-
<
|
|
|
|
|
62 |
<Button icon="fluent:glance-horizontal-sparkles-16-filled" href="/generate" theme="pink" size="md">Generate</Button>
|
63 |
</div>
|
64 |
</div>
|
|
|
8 |
import Radio from "$lib/components/fields/Radio.svelte";
|
9 |
import { COMMUNITY_FILTER_OPTIONS } from "$lib/utils/index.js";
|
10 |
import GoTop from "$lib/components/GoTop.svelte";
|
11 |
+
import UserIsLogged from "$lib/components/UserIsLogged.svelte";
|
12 |
|
13 |
export let data
|
14 |
|
|
|
55 |
<div class="flex items-center justify-between mt-5">
|
56 |
<Radio options={COMMUNITY_FILTER_OPTIONS} value="{form.filter}" onChange={handleChangeFilter} />
|
57 |
<div class="items-center justify-end gap-5 hidden lg:flex">
|
58 |
+
<UserIsLogged>
|
59 |
+
<Button icon="ic:round-plus" theme="dark" size="lg">Upload own Image</Button>
|
60 |
+
</UserIsLogged>
|
61 |
<Button icon="fluent:glance-horizontal-sparkles-16-filled" href="/generate" theme="pink" size="lg">Generate</Button>
|
62 |
</div>
|
63 |
<div class="items-center justify-end gap-3 flex lg:hidden">
|
64 |
+
<UserIsLogged>
|
65 |
+
<Button icon="ic:round-plus" theme="dark" size="md">Upload own Image</Button>
|
66 |
+
</UserIsLogged>
|
67 |
<Button icon="fluent:glance-horizontal-sparkles-16-filled" href="/generate" theme="pink" size="md">Generate</Button>
|
68 |
</div>
|
69 |
</div>
|
tailwind.config.js
CHANGED
@@ -5,7 +5,11 @@ export default {
|
|
5 |
fontFamily: {
|
6 |
sans: ['DM Sans', 'IBM Plex Mono'],
|
7 |
},
|
8 |
-
extend: {
|
|
|
|
|
|
|
|
|
9 |
},
|
10 |
plugins: [],
|
11 |
}
|
|
|
5 |
fontFamily: {
|
6 |
sans: ['DM Sans', 'IBM Plex Mono'],
|
7 |
},
|
8 |
+
extend: {
|
9 |
+
screens: {
|
10 |
+
'3xl': '1920px',
|
11 |
+
}
|
12 |
+
},
|
13 |
},
|
14 |
plugins: [],
|
15 |
}
|