enzostvs HF staff commited on
Commit
ad49b80
·
1 Parent(s): a805a6c

wip space result

Browse files
src/lib/components/result/space/Readme.svelte ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- enzostvs/stable-diffusion-tpu -->
2
+ <script lang="ts">
3
+ import Icon from "@iconify/svelte";
4
+
5
+ const cardData: {
6
+ app_port?: number;
7
+ colorFrom?: string;
8
+ colorTo?: string;
9
+ bgFrom?: string;
10
+ bgTo?: string;
11
+ emoji?: string;
12
+ title?: string;
13
+ sdk?: string;
14
+ license?: string;
15
+ pinned?: boolean;
16
+ } = {
17
+ app_port: 8501,
18
+ colorFrom: "from-pink-600",
19
+ colorTo: "to-blue-600",
20
+ bgFrom: "bg-pink-600",
21
+ bgTo: "bg-blue-700",
22
+ emoji: "🔥",
23
+ title: "Stable Diffusion TPU",
24
+ sdk: "tensorflow",
25
+ license: "Apache-2.0",
26
+ pinned: true,
27
+ };
28
+
29
+ </script>
30
+
31
+ <div class="rounded-2xl bg-white p-6 shadow col-span-2">
32
+ <div class="text-zinc-700 flex items-center gap-2 mb-4">
33
+ <Icon icon="la:readme" class="w-6 h-6" />
34
+ <p class="font-semibold text-sm">README.md</p>
35
+ </div>
36
+ <div class="grid grid-cols-3 gap-4">
37
+ {#if cardData?.bgFrom}
38
+ <div class="border rounded-lg border-zinc-300/70 p-3 flex items-center justify-start gap-3">
39
+ <div class={`w-6 h-6 rounded ${cardData.bgFrom}`}></div>
40
+ <p class="uppercase text-sm text-black/60 font-semibold font-title">
41
+ Primary color
42
+ </p>
43
+ </div>
44
+ {/if}
45
+ {#if cardData?.bgTo}
46
+ <div class="border rounded-lg border-zinc-300/70 p-3 flex items-center justify-start gap-3">
47
+ <div class={`w-6 h-6 rounded ${cardData.bgTo}`}></div>
48
+ <p class="uppercase text-sm text-black/60 font-semibold font-title">
49
+ Secondary color
50
+ </p>
51
+ </div>
52
+ {/if}
53
+ {#if cardData?.colorFrom && cardData?.colorTo}
54
+ <div class="border rounded-lg border-zinc-300/70 p-3 flex items-center justify-start gap-3">
55
+ <div class={`w-6 h-6 rounded bg-gradient-to-br ${cardData.colorFrom} ${cardData.colorTo}`}></div>
56
+ <p class="uppercase text-sm text-black/60 font-semibold font-title">
57
+ Gradient color
58
+ </p>
59
+ </div>
60
+ {/if}
61
+ {#if cardData?.emoji}
62
+ <div class="border rounded-lg border-zinc-300/70 p-3 flex items-center justify-start gap-3">
63
+ <p class="w-6 h-6 text-center scale-125">{cardData.emoji}</p>
64
+ <p class="uppercase text-sm text-black/60 font-semibold font-title">
65
+ Emoji
66
+ </p>
67
+ </div>
68
+ {/if}
69
+ {#if cardData?.sdk}
70
+ <div class="border rounded-lg border-zinc-300/70 p-3 flex items-center justify-start gap-3">
71
+ <Icon icon="tabler:sdk" class="w-6 h-6 text-gray-500" />
72
+ <p class="uppercase text-sm text-black/60 font-semibold font-title">
73
+ {cardData.sdk}
74
+ </p>
75
+ </div>
76
+ {/if}
77
+ {#if cardData?.app_port}
78
+ <div class="border rounded-lg border-zinc-300/70 p-3 flex items-center justify-start gap-3">
79
+ <Icon icon="solar:earth-bold-duotone" class="w-6 h-6 text-gray-500" />
80
+ <p class="uppercase text-sm text-black/60 font-semibold font-title">
81
+ :{cardData.app_port}
82
+ </p>
83
+ </div>
84
+ {/if}
85
+ {#if cardData?.license}
86
+ <div class="border rounded-lg border-zinc-300/70 p-3 flex items-center justify-start gap-3">
87
+ <Icon icon="solar:shield-bold-duotone" class="w-6 h-6 text-gray-500" />
88
+ <p class="uppercase text-sm text-black/60 font-semibold font-title">
89
+ {cardData.license}
90
+ </p>
91
+ </div>
92
+ {/if}
93
+ {#if typeof cardData?.pinned !== "undefined"}
94
+ <div class="border rounded-lg border-zinc-300/70 p-3 flex items-center justify-start gap-3">
95
+ <Icon icon="solar:pin-bold-duotone" class="w-6 h-6 text-gray-500" />
96
+ <p class="uppercase text-sm text-black/60 font-semibold font-title">
97
+ {cardData.pinned ? "Pinned" : "Not pinned"}
98
+ </p>
99
+ </div>
100
+ {/if}
101
+ </div>
102
+ </div>
src/lib/components/result/space/Space.svelte ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import Icon from "@iconify/svelte";
3
+ import Readme from "./Readme.svelte";
4
+
5
+ export let data: Record<string, any> | null = {};
6
+
7
+ $: console.log(data);
8
+ </script>
9
+
10
+ <div class="grid grid-cols-3 gap-8">
11
+ <div class="rounded-2xl bg-white p-4 shadow">
12
+ <div class={`flex flex-col items-center justify-center bg-gradient-to-br p-4 filter brightness-110 rounded-xl relative ${data?.cardData?.colorFrom} ${data?.cardData?.colorTo} h-full`}>
13
+ <div class="absolute opacity-60 text-8xl mb-2 ">
14
+ {data?.cardData?.emoji}
15
+ </div>
16
+ <p class="z-40 max-w-full truncate text-center font-bold leading-tight text-blue-50 text-2xl" style="text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.25);">
17
+ {data?.cardData?.title}
18
+ </p>
19
+ </div>
20
+ </div>
21
+ <Readme {...data?.cardData} />
22
+ </div>
src/routes/+layout.svelte CHANGED
@@ -25,20 +25,20 @@
25
 
26
  <div class="p-0 h-screen flex items-center justify-center gap-6 flex-col relative z-[1]">
27
  <div class="absolute top-0 left-0 w-full">
28
- <div class="container mx-auto flex items-center justify-between px-6 pt-4">
29
  <p></p>
30
  <button
31
- class="flex items-center justify-center gap-2 bg-gradient-to-br from-indigo-500 to-teal-500 shadow-sm px-3 py-2.5 rounded-lg text-white dark:text-zinc-950 font-medium font-title text-sm transition-all duration-200 hover:bg-indigo-600"
32
  on:click={() => {
33
  darkmodeStore.update((v) => !v);
34
  }}
35
  >
36
  {#if $darkmodeStore}
37
- <Icon icon="tabler:bulb-off" class="w-5 h-5" />
38
- Turn off the lights
39
- {:else}
40
  <Icon icon="heroicons-outline:light-bulb" class="w-5 h-5" />
41
  Turn on the lights
 
 
 
42
  {/if}
43
  </button>
44
  </div>
 
25
 
26
  <div class="p-0 h-screen flex items-center justify-center gap-6 flex-col relative z-[1]">
27
  <div class="absolute top-0 left-0 w-full">
28
+ <div class="container mx-auto flex items-center justify-between px-6 pt-6">
29
  <p></p>
30
  <button
31
+ class="flex items-center justify-center gap-2 bg-gradient-to-br from-black dark:from-teal-500 dark:to-indigo-500 to-zinc-700 shadow-sm px-5 py-2.5 rounded-full text-white dark:text-zinc-100 font-medium font-title text-sm transition-all duration-200 hover:bg-indigo-600"
32
  on:click={() => {
33
  darkmodeStore.update((v) => !v);
34
  }}
35
  >
36
  {#if $darkmodeStore}
 
 
 
37
  <Icon icon="heroicons-outline:light-bulb" class="w-5 h-5" />
38
  Turn on the lights
39
+ {:else}
40
+ <Icon icon="tabler:bulb-off" class="w-5 h-5" />
41
+ Turn off the lights
42
  {/if}
43
  </button>
44
  </div>
src/routes/+page.svelte CHANGED
@@ -4,19 +4,21 @@
4
  import HeroHeader from '$lib/components/HeroHeader.svelte';
5
  import Search from '$lib/components/search/Search.svelte';
6
  import { requestStore } from '$lib/stores/use-request';
 
7
 
8
  let data = get(requestStore);
9
 
10
  requestStore.subscribe((v) => {
11
  data = v;
12
  });
13
-
14
  </script>
15
 
16
  <div class="container w-full grid grid-cols-1 gap-8">
17
  <HeroHeader />
18
  <Search />
19
- <div class="bg-blue-900 rounded-xl shadow-lg text-white whitespace-pre-wrap p-6 max-w-6xl w-full mx-auto">
20
- {JSON.stringify(data)}
21
- </div>
 
 
22
  </div>
 
4
  import HeroHeader from '$lib/components/HeroHeader.svelte';
5
  import Search from '$lib/components/search/Search.svelte';
6
  import { requestStore } from '$lib/stores/use-request';
7
+ import Space from '$lib/components/result/space/Space.svelte';
8
 
9
  let data = get(requestStore);
10
 
11
  requestStore.subscribe((v) => {
12
  data = v;
13
  });
 
14
  </script>
15
 
16
  <div class="container w-full grid grid-cols-1 gap-8">
17
  <HeroHeader />
18
  <Search />
19
+ {#if data?.data}
20
+ <div class="w-full grid grid-cols-1 gap-8 p-6 max-w-6xl mx-auto">
21
+ <Space data={data.data} />
22
+ </div>
23
+ {/if}
24
  </div>
src/routes/api/search/+server.ts CHANGED
@@ -17,6 +17,17 @@ export async function POST({ request }: RequestEvent) {
17
  if (data.error) {
18
  throw error(response.status, data.error);
19
  }
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- return json(data);
22
  }
 
17
  if (data.error) {
18
  throw error(response.status, data.error);
19
  }
20
+
21
+ const formattedData = {
22
+ ...data,
23
+ cardData: {
24
+ ...data.cardData,
25
+ colorFrom: `from-${data?.cardData?.colorFrom}-600` ?? "from-pink-600",
26
+ colorTo: `to-${data?.cardData?.colorTo}-600` ?? "to-blue-600",
27
+ bgFrom: `bg-${data?.cardData?.colorFrom}-600` ?? "bg-pink-600",
28
+ bgTo: `bg-${data?.cardData?.colorTo}-600` ?? "bg-blue-600",
29
+ }
30
+ }
31
 
32
+ return json(formattedData);
33
  }