enzostvs HF staff commited on
Commit
dd7ec11
β€’
1 Parent(s): a382c22

split in component

Browse files
src/lib/components/community/Card.svelte ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { REACTION_EMOJIS } from "$lib/utils";
3
+ import Reaction from "$lib/components/community/reactions/Reaction.svelte";
4
+ import Add from "$lib/components/community/reactions/Add.svelte";
5
+
6
+ $: reactions = REACTION_EMOJIS.sort(() => Math.random() - Math.random()).slice(0, 3);
7
+ </script>
8
+
9
+ <div
10
+ class="cursor-pointer group bg-neutral-700 rounded-xl h-[310px] relative flex items-start justify-between flex-col p-5 transition-all duration-200 brightness-75 hover:brightness-100 z-[1]"
11
+ >
12
+ <div class="w-full h-full absolute top-0 left-0 -z-[1] rounded-xl overflow-hidden">
13
+ <div class="w-full h-full bg-center bg-cover transition-all duration-200 group-hover:scale-110 " style="background-image: url('https://images.unsplash.com/photo-1682687220015-186f63b8850a?q=80&w=4075&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D');"></div>
14
+ </div>
15
+ <div class="bg-black/40 backdrop-blur-sm border border-white/30 rounded-lg px-6 py-3 text-white transition-all duration-200 opacity-0 group-hover:opacity-100">
16
+ <p class="text-white font-semibold text-base">A mini hamster in a wheat field</p>
17
+ <p class="text-white/75 font-regular text-sm">LoRA model name</p>
18
+ </div>
19
+ <div class="flex items-center justify-start gap-2">
20
+ {#each reactions as emoji}
21
+ <Reaction emoji={emoji} count={Math.floor(Math.random() * 100)} />
22
+ {/each}
23
+ <Add />
24
+ </div>
25
+ </div>
src/lib/components/community/reactions/Add.svelte ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { browser } from '$app/environment';
3
+ import Icon from "@iconify/svelte";
4
+ import { REACTION_EMOJIS } from "$lib/utils";
5
+
6
+ let isOpen: boolean = false;
7
+ $: uuid = Math.random().toString(36).substring(7);
8
+
9
+ const handleClick = (event: MouseEvent) => {
10
+ const target = event.target as HTMLElement;
11
+ const addReaction = document.getElementById(uuid);
12
+ if (!addReaction) return;
13
+
14
+ if (!addReaction.contains(target)) {
15
+ isOpen = false;
16
+ }
17
+ }
18
+ if (browser) {
19
+ window.addEventListener("click", handleClick);
20
+ }
21
+ </script>
22
+
23
+ <div
24
+ id="{uuid}"
25
+ class="rounded-full text-sm text-white/80 hover:text-white font-bold flex items-center justify-start gap-1.5 px-1.5 py-1 border border-dashed border-white/80 hover:border-white relative z-[2]"
26
+ class:!border-white={isOpen}
27
+ class:!text-white={isOpen}
28
+ >
29
+ <button on:click={() => isOpen = !isOpen}>
30
+ <Icon icon="fluent:emoji-add-16-regular" class="w-5 h-5" />
31
+ </button>
32
+ <div
33
+ class="opacity-0 pointer-events-none absolute left-0 top-0 max-w-max flex items-center justify-center bg-white px-4 py-1 rounded-full gap-0 text-2xl -translate-y-[calc(100%+8px)] -translate-x-1/2"
34
+ class:opacity-100={isOpen}
35
+ class:pointer-events-auto={isOpen}
36
+ >
37
+ {#each REACTION_EMOJIS as emoji}
38
+ <div class="w-9 h-9 hover:bg-neutral-200 rounded-full text-center flex items-center justify-center">{emoji}</div>
39
+ {/each}
40
+ </div>
41
+ </div>
src/lib/components/community/reactions/Reaction.svelte ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let emoji: string;
3
+ export let count: number;
4
+ </script>
5
+
6
+ <div 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">
7
+ <span>{emoji}</span>
8
+ {count}
9
+ </div>
src/lib/components/fields/Input.svelte ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let placeholder: string = "Search";
3
+ </script>
4
+
5
+ <div class="bg-neutral-900 border border-neutral-800 rounded-lg px-4 py-3 text-neutral-200 text-base">
6
+ <input type="text" {placeholder} class="bg-transparent outline-none border-none placeholder:text-neutral-500 w-full">
7
+ </div>
src/lib/components/sidebar/Sidebar.svelte CHANGED
@@ -28,8 +28,8 @@
28
  }]
29
  </script>
30
 
31
- <button class="bg-transparent absolute top-10 right-8 cursor-pointer" on:click="{handleClick}">
32
- <Icon icon="mdi:hamburger-minus" class="w-7 h-7 text-white" />
33
  </button>
34
  <aside class="bg-neutral-950 h-screen border-r border-neutral-800 w-full max-w-[344px] absolute -translate-x-full lg:translate-x-0 transition-all duration-200 lg:relative z-20" class:translate-x-0={isOpen}>
35
  <header class="text-white px-8 pb-8 pt-10 text-xl tracking-wider font-semibold">
 
28
  }]
29
  </script>
30
 
31
+ <button class="bg-transparent absolute top-10 right-8 cursor-pointer lg:hidden" on:click="{handleClick}">
32
+ <Icon icon="{isOpen ? "mdi:hamburger-remove" : "mdi:hamburger-minus"}" class="w-7 h-7 text-white" />
33
  </button>
34
  <aside class="bg-neutral-950 h-screen border-r border-neutral-800 w-full max-w-[344px] absolute -translate-x-full lg:translate-x-0 transition-all duration-200 lg:relative z-20" class:translate-x-0={isOpen}>
35
  <header class="text-white px-8 pb-8 pt-10 text-xl tracking-wider font-semibold">
src/lib/utils/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export const REACTION_EMOJIS = ["❀️", "🀩", "πŸŽ‰", "πŸ”₯"]
src/routes/+page.svelte CHANGED
@@ -1,5 +1,7 @@
1
  <script lang="ts">
2
  import Button from "$lib/components/Button.svelte";
 
 
3
  import Radio from "$lib/components/fields/Radio.svelte";
4
  import Icon from "@iconify/svelte";
5
 
@@ -39,35 +41,11 @@
39
  <Button icon="fluent:glance-horizontal-sparkles-16-filled" href="/generate" theme="pink" size="lg">Generate</Button>
40
  </div>
41
  </div>
 
 
 
42
  <div class="mx-auto grid grid-cols-5 gap-5 mt-8 lg:mt-10">
43
  {#each Array(40) as _, i}
44
- <div
45
- class="cursor-pointer group overflow-hidden bg-neutral-700 rounded-xl h-[310px] relative flex items-start justify-between flex-col p-5 bg-cover bg-center transition-all duration-200 brightness-75 hover:brightness-100"
46
- style="
47
- background-image: url('https://images.unsplash.com/photo-1682687220015-186f63b8850a?q=80&w=4075&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D');
48
- "
49
- >
50
- <div class="bg-black/40 backdrop-blur-sm border border-white/30 rounded-lg px-6 py-3 text-white transition-all duration-200 opacity-0 group-hover:opacity-100">
51
- <p class="text-white font-semibold text-base">A mini hamster in a wheat field</p>
52
- <p class="text-white/75 font-regular text-sm">LoRA model name</p>
53
- </div>
54
- <div class="flex items-center justify-start gap-2">
55
- <div 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">
56
- <span>❀️</span>
57
- 12
58
- </div>
59
- <div 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">
60
- <span>🀩</span>
61
- 56
62
- </div>
63
- <div 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">
64
- <span>⭐</span>
65
- 32
66
- </div>
67
- <div class="rounded-full text-sm text-white/80 hover:text-white font-bold flex items-center justify-start gap-1.5 px-1.5 py-1 border border-dashed border-white/80 hover:border-white">
68
- <Icon icon="fluent:emoji-add-16-regular" class="w-5 h-5" />
69
- </div>
70
- </div>
71
- </div>
72
  {/each}
73
  </div>
 
1
  <script lang="ts">
2
  import Button from "$lib/components/Button.svelte";
3
+ import Card from "$lib/components/community/Card.svelte";
4
+ import Input from "$lib/components/fields/Input.svelte";
5
  import Radio from "$lib/components/fields/Radio.svelte";
6
  import Icon from "@iconify/svelte";
7
 
 
41
  <Button icon="fluent:glance-horizontal-sparkles-16-filled" href="/generate" theme="pink" size="lg">Generate</Button>
42
  </div>
43
  </div>
44
+ <div class="mt-5">
45
+ <Input />
46
+ </div>
47
  <div class="mx-auto grid grid-cols-5 gap-5 mt-8 lg:mt-10">
48
  {#each Array(40) as _, i}
49
+ <Card />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  {/each}
51
  </div>