enzostvs HF staff commited on
Commit
98b0aa6
·
1 Parent(s): a8ab833

models list

Browse files
src/lib/components/models/Card.svelte ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { CommunityCard } from "$lib/type";
3
+ import Button from "$lib/components/Button.svelte";
4
+ import Icon from "@iconify/svelte";
5
+
6
+ export let card: CommunityCard;
7
+
8
+ </script>
9
+
10
+ <div
11
+ class="cursor-pointer group bg-neutral-900 rounded-xl relative flex items-start justify-between flex-col p-3 border border-neutral-800 transition-all duration-200 brightness-75 hover:brightness-100 z-[1]"
12
+ >
13
+ <div class="w-full h-[250px] relative z-[1] mb-3 overflow-hidden">
14
+ <div class="w-full h-full bg-center bg-cover rounded-lg" style="background-image: url('{card.image}');"></div>
15
+ <div class="group-hover:opacity-100 opacity-0 translate-x-full group-hover:translate-x-0 transition-all duration-200 absolute right-3 bottom-3">
16
+ <Button theme="light" size="md">
17
+ Try it now
18
+ </Button>
19
+ </div>
20
+ </div>
21
+ <div class="flex items-center justify-between w-full">
22
+ <p class="text-white font-semibold text-base mb-1">{card.model_name}</p>
23
+ <div class="text-white text-sm flex items-center justify-end gap-1.5">
24
+ <Icon icon="solar:heart-bold" class="w-5 h-5 text-red-500" />
25
+ 234
26
+ </div>
27
+ </div>
28
+ </div>
src/routes/api/models/+server.ts ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { error, json, type RequestEvent } from '@sveltejs/kit';
2
+ // import { env } from '$env/dynamic/private'
3
+
4
+ import jsonData from "$lib/cards.json";
5
+
6
+ /** @type {import('./$types').RequestHandler} */
7
+
8
+ export async function GET(request : RequestEvent) {
9
+ const hasError = false
10
+
11
+ const page = parseInt(request.url.searchParams.get('page') || '0')
12
+ if (hasError) {
13
+ return error(500, 'Internal Server Error')
14
+ }
15
+
16
+ const cards = jsonData.slice(page * 25, page * 25 + 25)
17
+
18
+ return json({
19
+ cards,
20
+ total_items: jsonData.length,
21
+ })
22
+ }
src/routes/models/+page.svelte CHANGED
@@ -3,7 +3,7 @@
3
  import InfiniteScroll from "svelte-infinite-scroll";
4
 
5
  import Button from "$lib/components/Button.svelte";
6
- import Card from "$lib/components/community/Card.svelte";
7
  import Input from "$lib/components/fields/Input.svelte";
8
  import Radio from "$lib/components/fields/Radio.svelte";
9
  import { MODELS_FILTER_OPTIONS } from "$lib/utils/index.js";
 
3
  import InfiniteScroll from "svelte-infinite-scroll";
4
 
5
  import Button from "$lib/components/Button.svelte";
6
+ import Card from "$lib/components/models/Card.svelte";
7
  import Input from "$lib/components/fields/Input.svelte";
8
  import Radio from "$lib/components/fields/Radio.svelte";
9
  import { MODELS_FILTER_OPTIONS } from "$lib/utils/index.js";
src/routes/models/+page.ts CHANGED
@@ -1,5 +1,5 @@
1
  export async function load({ fetch }) {
2
- const response = await fetch("/api/community?page=1", {
3
  method: "GET",
4
  headers: {
5
  "Content-Type": "application/json"
 
1
  export async function load({ fetch }) {
2
+ const response = await fetch("/api/models?page=1", {
3
  method: "GET",
4
  headers: {
5
  "Content-Type": "application/json"